From 22c6800f16545d508f67210f3422aa9be60c46cc Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 28 Jul 2015 20:21:27 +0800 Subject: [PATCH] Bug 1187817. Part 5 - assert some code in the audio thread and don't enter the monitor. r=kinetik. --- dom/media/AudioSink.cpp | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/dom/media/AudioSink.cpp b/dom/media/AudioSink.cpp index c9e51c2a85ca..8be1516efc8c 100644 --- a/dom/media/AudioSink.cpp +++ b/dom/media/AudioSink.cpp @@ -250,21 +250,18 @@ AudioSink::InitializeAudioStream() void AudioSink::Drain() { + AssertOnAudioThread(); MOZ_ASSERT(mPlaying && !mAudioStream->IsPaused()); - AssertCurrentThreadInMonitor(); // If the media was too short to trigger the start of the audio stream, // start it now. mAudioStream->Start(); - { - ReentrantMonitorAutoExit exit(GetReentrantMonitor()); - mAudioStream->Drain(); - } + mAudioStream->Drain(); } void AudioSink::Cleanup() { - AssertCurrentThreadInMonitor(); + AssertOnAudioThread(); mEndPromise.Resolve(true, __func__); // Since the promise if resolved asynchronously, we don't shutdown // AudioStream here so MDSM::ResyncAudioClock can get the correct @@ -280,9 +277,9 @@ AudioSink::ExpectMoreAudioData() bool AudioSink::WaitingForAudioToPlay() { + AssertOnAudioThread(); // Return true if we're not playing, and we're not shutting down, or we're // playing and we've got no audio to play. - AssertCurrentThreadInMonitor(); if (!mStopAudioThread && (!mPlaying || ExpectMoreAudioData())) { return true; } @@ -292,7 +289,7 @@ AudioSink::WaitingForAudioToPlay() bool AudioSink::IsPlaybackContinuing() { - AssertCurrentThreadInMonitor(); + AssertOnAudioThread(); // If we're shutting down, captured, or at EOS, break out and exit the audio // thread. if (mStopAudioThread || AudioQueue().AtEndOfStream()) { @@ -323,16 +320,13 @@ AudioSink::AudioLoop() } case AUDIOSINK_STATE_PLAYING: { - { - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); - if (WaitingForAudioToPlay()) { - // NotifyData() will schedule next loop. - break; - } - if (!IsPlaybackContinuing()) { - SetState(AUDIOSINK_STATE_COMPLETE); - break; - } + if (WaitingForAudioToPlay()) { + // NotifyData() will schedule next loop. + break; + } + if (!IsPlaybackContinuing()) { + SetState(AUDIOSINK_STATE_COMPLETE); + break; } if (!PlayAudio()) { SetState(AUDIOSINK_STATE_COMPLETE); @@ -405,7 +399,7 @@ AudioSink::PlayAudio() void AudioSink::FinishAudioLoop() { - ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); + AssertOnAudioThread(); MOZ_ASSERT(mStopAudioThread || AudioQueue().AtEndOfStream()); if (!mStopAudioThread && mPlaying) { Drain();