зеркало из 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)
|
||||
, mIsFlushing(false)
|
||||
, mParsedFramesForAACMagicCookie(0)
|
||||
, mErrored(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(AppleATDecoder);
|
||||
LOG("Creating Apple AudioToolbox decoder");
|
||||
|
@ -89,10 +90,18 @@ AppleATDecoder::ProcessFlush()
|
|||
{
|
||||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||
mQueuedSamples.Clear();
|
||||
if (mConverter) {
|
||||
OSStatus rv = AudioConverterReset(mConverter);
|
||||
if (rv) {
|
||||
LOG("Error %d resetting AudioConverter", rv);
|
||||
}
|
||||
}
|
||||
if (mErrored) {
|
||||
mParsedFramesForAACMagicCookie = 0;
|
||||
mMagicCookie.Clear();
|
||||
ProcessShutdown();
|
||||
mErrored = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -121,24 +130,33 @@ void
|
|||
AppleATDecoder::Shutdown()
|
||||
{
|
||||
MOZ_ASSERT(mCallback->OnReaderTaskQueue());
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
NewRunnableMethod(this, &AppleATDecoder::ProcessShutdown);
|
||||
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
|
||||
}
|
||||
|
||||
LOG("Shutdown: Apple AudioToolbox AAC decoder");
|
||||
mQueuedSamples.Clear();
|
||||
OSStatus rv = AudioConverterDispose(mConverter);
|
||||
if (rv) {
|
||||
LOG("error %d disposing of AudioConverter", rv);
|
||||
return;
|
||||
}
|
||||
mConverter = nullptr;
|
||||
void
|
||||
AppleATDecoder::ProcessShutdown()
|
||||
{
|
||||
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
|
||||
|
||||
if (mStream) {
|
||||
rv = AudioFileStreamClose(mStream);
|
||||
OSStatus rv = AudioFileStreamClose(mStream);
|
||||
if (rv) {
|
||||
LOG("error %d disposing of AudioFileStream", rv);
|
||||
return;
|
||||
}
|
||||
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 {
|
||||
|
@ -207,7 +225,7 @@ AppleATDecoder::SubmitSample(MediaRawData* aSample)
|
|||
for (size_t i = 0; i < mQueuedSamples.Length(); i++) {
|
||||
rv = DecodeSample(mQueuedSamples[i]);
|
||||
if (NS_FAILED(rv)) {
|
||||
mQueuedSamples.Clear();
|
||||
mErrored = true;
|
||||
mCallback->Error(MediaResult(
|
||||
rv, RESULT_DETAIL("Unable to decode sample %lld", aSample->mTime)));
|
||||
return;
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
Atomic<bool> mIsFlushing;
|
||||
|
||||
void ProcessFlush();
|
||||
void ProcessShutdown();
|
||||
void SubmitSample(MediaRawData* aSample);
|
||||
nsresult DecodeSample(MediaRawData* aSample);
|
||||
nsresult GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
|
||||
|
@ -69,6 +70,7 @@ private:
|
|||
nsresult GetImplicitAACMagicCookie(const MediaRawData* aSample);
|
||||
nsresult SetupChannelLayout();
|
||||
uint32_t mParsedFramesForAACMagicCookie;
|
||||
bool mErrored;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
Загрузка…
Ссылка в новой задаче