Bug 1306813 - Don't puslish events to mOnOutput after DecodedStream::Stop() is called. r=pehrsons

Because the TaskQueue of MDSM will shut down soon and TaskQueue::Dispatch() will fail (via mOnOutput.Notify()).
We reset mStream in Forget() on the TaskQueue thread of MDSM so NotifyOutput() can check it
and ensure mOnOutput.Notify() always happen before DecodedStream::Stop().

MozReview-Commit-ID: 4sCXk1KAfCC

--HG--
extra : rebase_source : 1ec50a86fa1519c4fc8caa1087f2794411aa23b0
This commit is contained in:
JW Wang 2016-10-04 14:54:23 +08:00
Родитель 3e934c8f5c
Коммит 15fc2d73c6
1 изменённых файлов: 13 добавлений и 3 удалений

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

@ -61,13 +61,16 @@ public:
void DoNotifyFinished() void DoNotifyFinished()
{ {
MOZ_ASSERT(NS_IsMainThread());
mFinishPromise.ResolveIfExists(true, __func__); mFinishPromise.ResolveIfExists(true, __func__);
} }
void Forget() void Forget()
{ {
MOZ_ASSERT(NS_IsMainThread()); AbstractThread::MainThread()->Dispatch(NS_NewRunnableFunction([this] () {
mFinishPromise.ResolveIfExists(true, __func__); MOZ_ASSERT(NS_IsMainThread());
mFinishPromise.ResolveIfExists(true, __func__);
}));
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
mStream = nullptr; mStream = nullptr;
} }
@ -123,6 +126,7 @@ public:
~DecodedStreamData(); ~DecodedStreamData();
void SetPlaying(bool aPlaying); void SetPlaying(bool aPlaying);
MediaEventSource<int64_t>& OnOutput(); MediaEventSource<int64_t>& OnOutput();
void Forget();
/* The following group of fields are protected by the decoder's monitor /* The following group of fields are protected by the decoder's monitor
* and can be read or written on any thread. * and can be read or written on any thread.
@ -188,7 +192,6 @@ DecodedStreamData::DecodedStreamData(OutputStreamManager* aOutputStreamManager,
DecodedStreamData::~DecodedStreamData() DecodedStreamData::~DecodedStreamData()
{ {
mOutputStreamManager->Disconnect(); mOutputStreamManager->Disconnect();
mListener->Forget();
mStream->Destroy(); mStream->Destroy();
} }
@ -207,6 +210,12 @@ DecodedStreamData::SetPlaying(bool aPlaying)
} }
} }
void
DecodedStreamData::Forget()
{
mListener->Forget();
}
DecodedStream::DecodedStream(AbstractThread* aOwnerThread, DecodedStream::DecodedStream(AbstractThread* aOwnerThread,
MediaQueue<MediaData>& aAudioQueue, MediaQueue<MediaData>& aAudioQueue,
MediaQueue<MediaData>& aVideoQueue, MediaQueue<MediaData>& aVideoQueue,
@ -363,6 +372,7 @@ DecodedStream::DestroyData(UniquePtr<DecodedStreamData> aData)
mOutputListener.Disconnect(); mOutputListener.Disconnect();
DecodedStreamData* data = aData.release(); DecodedStreamData* data = aData.release();
data->Forget();
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () { nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([=] () {
delete data; delete data;
}); });