Bug 1274189. Part 2 - remove use of FlushableTaskQueue::Flush(). r=jya.

MozReview-Commit-ID: I079lp6vSqu

--HG--
extra : rebase_source : 4cd655365a45123de748791100bd308e229d650c
This commit is contained in:
JW Wang 2016-05-25 10:15:24 +08:00
Родитель ecc1e85308
Коммит ef34d3ad83
2 изменённых файлов: 16 добавлений и 3 удалений

Просмотреть файл

@ -10,6 +10,7 @@
#include "VorbisDecoder.h" // For VorbisLayout
#include "mozilla/Endian.h"
#include "mozilla/PodOperations.h"
#include "mozilla/SyncRunnable.h"
#include <stdint.h>
#include <inttypes.h> // For PRId64
@ -31,6 +32,7 @@ OpusDataDecoder::OpusDataDecoder(const AudioInfo& aConfig,
, mDecodedHeader(false)
, mPaddingDiscarded(false)
, mFrames(0)
, mIsFlushing(false)
{
}
@ -141,6 +143,9 @@ OpusDataDecoder::Input(MediaRawData* aSample)
void
OpusDataDecoder::ProcessDecode(MediaRawData* aSample)
{
if (mIsFlushing) {
return;
}
if (DoDecode(aSample) == -1) {
mCallback->Error();
} else if(mTaskQueue->IsEmpty()) {
@ -313,14 +318,20 @@ OpusDataDecoder::Drain()
nsresult
OpusDataDecoder::Flush()
{
mTaskQueue->Flush();
if (mOpusDecoder) {
if (!mOpusDecoder) {
return NS_OK;
}
mIsFlushing = true;
nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableFunction([this] () {
MOZ_ASSERT(mOpusDecoder);
// Reset the decoder.
opus_multistream_decoder_ctl(mOpusDecoder, OPUS_RESET_STATE);
mSkip = mOpusParser->mPreSkip;
mPaddingDiscarded = false;
mLastFrameTime.reset();
}
});
SyncRunnable::DispatchToThread(mTaskQueue, runnable);
mIsFlushing = false;
return NS_OK;
}

Просмотреть файл

@ -60,6 +60,8 @@ private:
int64_t mFrames;
Maybe<int64_t> mLastFrameTime;
uint8_t mMappingTable[MAX_AUDIO_CHANNELS]; // Channel mapping table.
Atomic<bool> mIsFlushing;
};
} // namespace mozilla