зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1311876: P2. Recreate audio decoder when an error occurs. r=gerald
MozReview-Commit-ID: CwQMZwSNndO --HG-- extra : rebase_source : d76bd3c15f4d4fc54fcb6f4659ad3d501433f8be
This commit is contained in:
Родитель
f0515f7a99
Коммит
83df18207f
|
@ -29,6 +29,7 @@ AppleATDecoder::AppleATDecoder(const AudioInfo& aConfig,
|
||||||
, mStream(nullptr)
|
, mStream(nullptr)
|
||||||
, mIsFlushing(false)
|
, mIsFlushing(false)
|
||||||
, mParsedFramesForAACMagicCookie(0)
|
, mParsedFramesForAACMagicCookie(0)
|
||||||
|
, mErrored(false)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(AppleATDecoder);
|
MOZ_COUNT_CTOR(AppleATDecoder);
|
||||||
LOG("Creating Apple AudioToolbox decoder");
|
LOG("Creating Apple AudioToolbox decoder");
|
||||||
|
@ -89,9 +90,17 @@ AppleATDecoder::ProcessFlush()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||||
mQueuedSamples.Clear();
|
mQueuedSamples.Clear();
|
||||||
OSStatus rv = AudioConverterReset(mConverter);
|
if (mConverter) {
|
||||||
if (rv) {
|
OSStatus rv = AudioConverterReset(mConverter);
|
||||||
LOG("Error %d resetting AudioConverter", rv);
|
if (rv) {
|
||||||
|
LOG("Error %d resetting AudioConverter", rv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mErrored) {
|
||||||
|
mParsedFramesForAACMagicCookie = 0;
|
||||||
|
mMagicCookie.Clear();
|
||||||
|
ProcessShutdown();
|
||||||
|
mErrored = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,24 +130,33 @@ void
|
||||||
AppleATDecoder::Shutdown()
|
AppleATDecoder::Shutdown()
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||||
|
nsCOMPtr<nsIRunnable> runnable =
|
||||||
|
NewRunnableMethod(this, &AppleATDecoder::ProcessShutdown);
|
||||||
|
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
||||||
|
}
|
||||||
|
|
||||||
LOG("Shutdown: Apple AudioToolbox AAC decoder");
|
void
|
||||||
mQueuedSamples.Clear();
|
AppleATDecoder::ProcessShutdown()
|
||||||
OSStatus rv = AudioConverterDispose(mConverter);
|
{
|
||||||
if (rv) {
|
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||||
LOG("error %d disposing of AudioConverter", rv);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mConverter = nullptr;
|
|
||||||
|
|
||||||
if (mStream) {
|
if (mStream) {
|
||||||
rv = AudioFileStreamClose(mStream);
|
OSStatus rv = AudioFileStreamClose(mStream);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
LOG("error %d disposing of AudioFileStream", rv);
|
LOG("error %d disposing of AudioFileStream", rv);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mStream = nullptr;
|
mStream = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mConverter) {
|
||||||
|
LOG("Shutdown: Apple AudioToolbox AAC decoder");
|
||||||
|
OSStatus rv = AudioConverterDispose(mConverter);
|
||||||
|
if (rv) {
|
||||||
|
LOG("error %d disposing of AudioConverter", rv);
|
||||||
|
}
|
||||||
|
mConverter = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PassthroughUserData {
|
struct PassthroughUserData {
|
||||||
|
@ -207,7 +225,7 @@ AppleATDecoder::SubmitSample(MediaRawData* aSample)
|
||||||
for (size_t i = 0; i < mQueuedSamples.Length(); i++) {
|
for (size_t i = 0; i < mQueuedSamples.Length(); i++) {
|
||||||
rv = DecodeSample(mQueuedSamples[i]);
|
rv = DecodeSample(mQueuedSamples[i]);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
mQueuedSamples.Clear();
|
mErrored = true;
|
||||||
mCallback->Error(MediaResult(
|
mCallback->Error(MediaResult(
|
||||||
rv, RESULT_DETAIL("Unable to decode sample %lld", aSample->mTime)));
|
rv, RESULT_DETAIL("Unable to decode sample %lld", aSample->mTime)));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -59,6 +59,7 @@ private:
|
||||||
Atomic<bool> mIsFlushing;
|
Atomic<bool> mIsFlushing;
|
||||||
|
|
||||||
void ProcessFlush();
|
void ProcessFlush();
|
||||||
|
void ProcessShutdown();
|
||||||
void SubmitSample(MediaRawData* aSample);
|
void SubmitSample(MediaRawData* aSample);
|
||||||
nsresult DecodeSample(MediaRawData* aSample);
|
nsresult DecodeSample(MediaRawData* aSample);
|
||||||
nsresult GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
|
nsresult GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
|
||||||
|
@ -69,6 +70,7 @@ private:
|
||||||
nsresult GetImplicitAACMagicCookie(const MediaRawData* aSample);
|
nsresult GetImplicitAACMagicCookie(const MediaRawData* aSample);
|
||||||
nsresult SetupChannelLayout();
|
nsresult SetupChannelLayout();
|
||||||
uint32_t mParsedFramesForAACMagicCookie;
|
uint32_t mParsedFramesForAACMagicCookie;
|
||||||
|
bool mErrored;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
Загрузка…
Ссылка в новой задаче