Bug 1145686 - Make MDSM::StartBuffering happen on the state machine thread. r=jww

This commit is contained in:
Bobby Holley 2015-03-24 17:12:54 -07:00
parent f63bfb2b8b
commit 4843f048ee
3 changed files with 12 additions and 6 deletions

View File

@ -1497,9 +1497,8 @@ void MediaDecoder::Resume(bool aForceBuffering)
mResource->Resume();
}
if (aForceBuffering) {
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (mDecoderStateMachine) {
mDecoderStateMachine->StartBuffering();
mDecoderStateMachine->DispatchStartBuffering();
}
}
}

View File

@ -3205,7 +3205,8 @@ bool MediaDecoderStateMachine::JustExitedQuickBuffering()
void MediaDecoderStateMachine::StartBuffering()
{
AssertCurrentThreadInMonitor();
MOZ_ASSERT(OnTaskQueue());
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
if (mState != DECODER_STATE_DECODING) {
// We only move into BUFFERING state if we're actually decoding.

View File

@ -254,11 +254,17 @@ public:
// the decode monitor held.
void UpdatePlaybackPosition(int64_t aTime);
private:
// Causes the state machine to switch to buffering state, and to
// immediately stop playback and buffer downloaded data. Must be called
// with the decode monitor held. Called on the state machine thread and
// the main thread.
// immediately stop playback and buffer downloaded data. Called on
// the state machine thread.
void StartBuffering();
public:
void DispatchStartBuffering()
{
TaskQueue()->Dispatch(NS_NewRunnableMethod(this, &MediaDecoderStateMachine::StartBuffering));
}
// This is called on the state machine thread and audio thread.
// The decoder monitor must be obtained before calling this.