From 3dffe95932ffb4d062728ce9885da55a4b396086 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Wed, 4 Sep 2013 23:13:06 +1200 Subject: [PATCH] Bug 904926. Remove unnecessary lock. r=cpearce --HG-- extra : rebase_source : 0088907b65ff3ce2e1f15b2bb1b5e0cdb7126f24 --- content/media/MediaDecoder.cpp | 6 ++---- content/media/MediaDecoder.h | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index 11457dcd96e..c1ff95aa917 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -362,7 +362,6 @@ MediaDecoder::MediaDecoder() : mInitialVolume(0.0), mInitialPlaybackRate(1.0), mInitialPreservesPitch(true), - mRequestedSeekTime(-1.0), mDuration(-1), mTransportSeekable(true), mMediaSeekable(true), @@ -372,6 +371,7 @@ MediaDecoder::MediaDecoder() : mIsExitingDormant(false), mPlayState(PLAY_STATE_PAUSED), mNextState(PLAY_STATE_PAUSED), + mRequestedSeekTime(-1.0), mCalledResourceLoaded(false), mIgnoreProgressData(false), mInfiniteStream(false), @@ -708,8 +708,7 @@ bool MediaDecoder::IsDataCachedToEndOfResource() { NS_ASSERTION(!mShuttingDown, "Don't call during shutdown!"); - GetReentrantMonitor().AssertCurrentThreadIn(); - + ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); return (mResource && mResource->IsDataCachedToEndOfResource(mDecoderPosition)); } @@ -755,7 +754,6 @@ void MediaDecoder::MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool // Only inform the element of FirstFrameLoaded if not doing a load() in order // to fulfill a seek, otherwise we'll get multiple loadedfirstframe events. - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); bool notifyResourceIsLoaded = !mCalledResourceLoaded && IsDataCachedToEndOfResource(); if (mOwner) { diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h index 78ea87dcfb3..65d62454c4a 100644 --- a/content/media/MediaDecoder.h +++ b/content/media/MediaDecoder.h @@ -692,7 +692,7 @@ public: // Call on the main thread only. void FirstFrameLoaded(); - // Returns true if the resource has been loaded. Must be in monitor. + // Returns true if the resource has been loaded. Acquires the monitor. // Call from any thread. virtual bool IsDataCachedToEndOfResource(); @@ -946,13 +946,6 @@ public: double mInitialPlaybackRate; bool mInitialPreservesPitch; - // Position to seek to when the seek notification is received by the - // decode thread. Written by the main thread and read via the - // decode thread. Synchronised using mReentrantMonitor. If the - // value is negative then no seek has been requested. When a seek is - // started this is reset to negative. - double mRequestedSeekTime; - // Duration of the media resource. Set to -1 if unknown. // Set when the metadata is loaded. Accessed on the main thread // only. @@ -1055,6 +1048,15 @@ public: // This can only be PLAY_STATE_PAUSED or PLAY_STATE_PLAYING. PlayState mNextState; + // Position to seek to when the seek notification is received by the + // decode thread. + // This can only be changed on the main thread while holding the decoder + // monitor. Thus, it can be safely read while holding the decoder monitor + // OR on the main thread. + // If the value is negative then no seek has been requested. When a seek is + // started this is reset to negative. + double mRequestedSeekTime; + // True when we have fully loaded the resource and reported that // to the element (i.e. reached NETWORK_LOADED state). // Accessed on the main thread only.