Bug 1273405. Part 4 - add assertions. r=jya.
MozReview-Commit-ID: 6tbA0aj5Rto
--- a/dom/media/platforms/agnostic/VorbisDecoder.cpp
+++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp
@@ -126,38 +126,42 @@ VorbisDataDecoder::DecodeHeader(const un
&mVorbisComment,
&pkt);
return r == 0 ? NS_OK : NS_ERROR_FAILURE;
}
nsresult
VorbisDataDecoder::Input(MediaRawData* aSample)
{
+ MOZ_ASSERT(mCallback->OnReaderTaskQueue());
mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>(
this, &VorbisDataDecoder::ProcessDecode, aSample));
return NS_OK;
}
void
VorbisDataDecoder::ProcessDecode(MediaRawData* aSample)
{
+ MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
if (mIsFlushing) {
return;
}
if (DoDecode(aSample) == -1) {
mCallback->Error();
} else if (mTaskQueue->IsEmpty()) {
mCallback->InputExhausted();
}
}
int
VorbisDataDecoder::DoDecode(MediaRawData* aSample)
{
+ MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
+
const unsigned char* aData = aSample->Data();
size_t aLength = aSample->Size();
int64_t aOffset = aSample->mOffset;
uint64_t aTstampUsecs = aSample->mTime;
int64_t aTotalFrames = 0;
MOZ_ASSERT(mPacketCount >= 3);
@@ -256,29 +260,32 @@ VorbisDataDecoder::DoDecode(MediaRawData
}
return aTotalFrames > 0 ? 1 : 0;
}
void
VorbisDataDecoder::ProcessDrain()
{
+ MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
mCallback->DrainComplete();
}
nsresult
VorbisDataDecoder::Drain()
{
+ MOZ_ASSERT(mCallback->OnReaderTaskQueue());
mTaskQueue->Dispatch(NewRunnableMethod(this, &VorbisDataDecoder::ProcessDrain));
return NS_OK;
}
nsresult
VorbisDataDecoder::Flush()
{
+ MOZ_ASSERT(mCallback->OnReaderTaskQueue());
mIsFlushing = true;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([this] () {
// Ignore failed results from vorbis_synthesis_restart. They
// aren't fatal and it fails when ResetDecode is called at a
// time when no vorbis data has been read.
vorbis_synthesis_restart(&mVorbisDsp);
mLastFrameTime.reset();
});