Bug 1408987 - Part 1: Add OnTaskQueue() assertion to clarify functions' running thread. r=jya

MozReview-Commit-ID: 36sqB5SlOd
This commit is contained in:
Alastor Wu 2017-10-17 15:58:44 +08:00
parent 6b9e774ce9
commit bbdf374f35
2 changed files with 19 additions and 1 deletions

View File

@ -354,6 +354,7 @@ MediaSourceTrackDemuxer::Reset()
if (!self->mManager) {
return;
}
MOZ_ASSERT(self->OnTaskQueue());
self->mManager->Seek(self->mType, TimeUnit::Zero(), TimeUnit::Zero());
{
MonitorAutoLock mon(self->mMonitor);
@ -397,8 +398,8 @@ MediaSourceTrackDemuxer::BreakCycles()
RefPtr<MediaSourceTrackDemuxer> self = this;
nsCOMPtr<nsIRunnable> task =
NS_NewRunnableFunction("MediaSourceTrackDemuxer::BreakCycles", [self]() {
self->mParent = nullptr;
self->DetachManager();
self->mParent = nullptr;
});
mParent->GetTaskQueue()->Dispatch(task.forget());
}
@ -411,6 +412,8 @@ MediaSourceTrackDemuxer::DoSeek(const TimeUnit& aTime)
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
RESULT_DETAIL("manager is detached.")), __func__);
}
MOZ_ASSERT(OnTaskQueue());
TimeIntervals buffered = mManager->Buffered(mType);
// Fuzz factor represents a +/- threshold. So when seeking it allows the gap
// to be twice as big as the fuzz value. We only want to allow EOS_FUZZ gap.
@ -463,6 +466,8 @@ MediaSourceTrackDemuxer::DoGetSamples(int32_t aNumSamples)
MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
RESULT_DETAIL("manager is detached.")), __func__);
}
MOZ_ASSERT(OnTaskQueue());
if (mReset) {
// If a seek (or reset) was recently performed, we ensure that the data
// we are about to retrieve is still available.
@ -516,6 +521,8 @@ MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint(
SkipFailureHolder(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR,
RESULT_DETAIL("manager is detached.")), 0), __func__);
}
MOZ_ASSERT(OnTaskQueue());
uint32_t parsed = 0;
// Ensure that the data we are about to skip to is still available.
TimeIntervals buffered = mManager->Buffered(mType);
@ -539,12 +546,14 @@ MediaSourceTrackDemuxer::DoSkipToNextRandomAccessPoint(
bool
MediaSourceTrackDemuxer::HasManager(TrackBuffersManager* aManager) const
{
MOZ_ASSERT(OnTaskQueue());
return mManager == aManager;
}
void
MediaSourceTrackDemuxer::DetachManager()
{
MOZ_ASSERT(OnTaskQueue());
mManager = nullptr;
}

View File

@ -120,6 +120,15 @@ public:
void DetachManager();
private:
bool OnTaskQueue() const
{
MOZ_ASSERT(mParent);
auto taskQueue = mParent->GetTaskQueue();
MOZ_ASSERT(taskQueue);
return taskQueue->IsCurrentThreadIn();
}
RefPtr<SeekPromise> DoSeek(const media::TimeUnit& aTime);
RefPtr<SamplesPromise> DoGetSamples(int32_t aNumSamples);
RefPtr<SkipAccessPointPromise> DoSkipToNextRandomAccessPoint(