From be027d47bd0e5735d8d2b0c563d8b29b42f0446b Mon Sep 17 00:00:00 2001 From: JW Wang Date: Mon, 24 Aug 2015 21:05:32 +0800 Subject: [PATCH] Bug 1196112. Part 2 - Remove DecodedStream::mMonitor. r=roc. --- dom/media/DecodedStream.cpp | 26 +------------------------- dom/media/DecodedStream.h | 10 ---------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/dom/media/DecodedStream.cpp b/dom/media/DecodedStream.cpp index bd2625e6b124..63d50cccea08 100644 --- a/dom/media/DecodedStream.cpp +++ b/dom/media/DecodedStream.cpp @@ -357,7 +357,6 @@ DecodedStream::DecodedStream(AbstractThread* aOwnerThread, MediaQueue& aVideoQueue) : mOwnerThread(aOwnerThread) , mShuttingDown(false) - , mMonitor("DecodedStream::mMonitor") , mPlaying(false) , mVolume(1.0) , mAudioQueue(aAudioQueue) @@ -381,7 +380,6 @@ nsRefPtr DecodedStream::StartPlayback(int64_t aStartTime, const MediaInfo& aInfo) { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); MOZ_ASSERT(mStartTime.isNothing(), "playback already started."); mStartTime.emplace(aStartTime); @@ -419,7 +417,7 @@ DecodedStream::StartPlayback(int64_t aStartTime, const MediaInfo& aInfo) void DecodedStream::StopPlayback() { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); + // Playback didn't even start at all. if (mStartTime.isNothing()) { return; @@ -437,7 +435,6 @@ void DecodedStream::DestroyData(UniquePtr aData) { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); if (!aData) { return; @@ -456,7 +453,6 @@ void DecodedStream::CreateData(MozPromiseHolder&& aPromise) { MOZ_ASSERT(NS_IsMainThread()); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); // No need to create a source stream when there are no output streams. This // happens when RemoveOutput() is called immediately after StartPlayback(). @@ -504,7 +500,6 @@ void DecodedStream::OnDataCreated(UniquePtr aData) { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); MOZ_ASSERT(!mData, "Already created."); // Start to send data to the stream immediately @@ -519,12 +514,6 @@ DecodedStream::OnDataCreated(UniquePtr aData) DestroyData(Move(aData)); } -ReentrantMonitor& -DecodedStream::GetReentrantMonitor() const -{ - return mMonitor; -} - void DecodedStream::AddOutput(ProcessedMediaStream* aStream, bool aFinishWhenEnded) { @@ -541,7 +530,6 @@ void DecodedStream::SetPlaying(bool aPlaying) { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); mPlaying = aPlaying; if (mData) { mData->SetPlaying(aPlaying); @@ -552,7 +540,6 @@ void DecodedStream::SetVolume(double aVolume) { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); mVolume = aVolume; } @@ -560,7 +547,6 @@ void DecodedStream::SetSameOrigin(bool aSameOrigin) { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); mSameOrigin = aSameOrigin; } @@ -568,7 +554,6 @@ void DecodedStream::InitTracks() { AssertOwnerThread(); - GetReentrantMonitor().AssertCurrentThreadIn(); if (mData->mStreamInitialized) { return; @@ -649,7 +634,6 @@ void DecodedStream::SendAudio(double aVolume, bool aIsSameOrigin) { AssertOwnerThread(); - GetReentrantMonitor().AssertCurrentThreadIn(); if (!mInfo.HasAudio()) { return; @@ -715,7 +699,6 @@ void DecodedStream::SendVideo(bool aIsSameOrigin) { AssertOwnerThread(); - GetReentrantMonitor().AssertCurrentThreadIn(); if (!mInfo.HasVideo()) { return; @@ -794,7 +777,6 @@ void DecodedStream::AdvanceTracks() { AssertOwnerThread(); - GetReentrantMonitor().AssertCurrentThreadIn(); StreamTime endPosition = 0; @@ -819,7 +801,6 @@ void DecodedStream::SendData() { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); MOZ_ASSERT(mStartTime.isSome(), "Must be called after StartPlayback()"); // Not yet created on the main thread. MDSM will try again later. @@ -850,7 +831,6 @@ int64_t DecodedStream::AudioEndTime() const { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); if (mStartTime.isSome() && mInfo.HasAudio() && mData) { CheckedInt64 t = mStartTime.ref() + FramesToUsecs(mData->mAudioFramesWritten, mInfo.mAudio.mRate); @@ -865,7 +845,6 @@ int64_t DecodedStream::GetPosition() const { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); // This is only called after MDSM starts playback. So mStartTime is // guaranteed to be something. MOZ_ASSERT(mStartTime.isSome()); @@ -876,7 +855,6 @@ bool DecodedStream::IsFinished() const { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); return mData && mData->IsFinished(); } @@ -884,7 +862,6 @@ void DecodedStream::ConnectListener() { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); mAudioPushListener = mAudioQueue.PushEvent().Connect( mOwnerThread, this, &DecodedStream::SendData); @@ -900,7 +877,6 @@ void DecodedStream::DisconnectListener() { AssertOwnerThread(); - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); mAudioPushListener.Disconnect(); mVideoPushListener.Disconnect(); diff --git a/dom/media/DecodedStream.h b/dom/media/DecodedStream.h index 8665ab5dac4b..463bd4ae2f07 100644 --- a/dom/media/DecodedStream.h +++ b/dom/media/DecodedStream.h @@ -134,7 +134,6 @@ protected: virtual ~DecodedStream(); private: - ReentrantMonitor& GetReentrantMonitor() const; void CreateData(MozPromiseHolder&& aPromise); void DestroyData(UniquePtr aData); void OnDataCreated(UniquePtr aData); @@ -161,15 +160,6 @@ private: // True if MDSM has begun shutdown. bool mShuttingDown; - // TODO: This is a temp solution to get rid of decoder monitor on the main - // thread in MDSM::AddOutputStream and MDSM::RecreateDecodedStream as - // required by bug 1146482. DecodedStream needs to release monitor before - // calling back into MDSM functions in order to prevent deadlocks. - // - // Please move all capture-stream related code from MDSM into DecodedStream - // and apply "dispatch + mirroring" to get rid of this monitor in the future. - mutable ReentrantMonitor mMonitor; - /* * Worker thread only members. */