Bug 1187817. Part 5 - assert some code in the audio thread and don't enter the monitor. r=kinetik.

This commit is contained in:
JW Wang 2015-07-28 20:21:27 +08:00
Родитель cd7d8ab800
Коммит 22c6800f16
1 изменённых файлов: 13 добавлений и 19 удалений

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

@ -250,21 +250,18 @@ AudioSink::InitializeAudioStream()
void void
AudioSink::Drain() AudioSink::Drain()
{ {
AssertOnAudioThread();
MOZ_ASSERT(mPlaying && !mAudioStream->IsPaused()); MOZ_ASSERT(mPlaying && !mAudioStream->IsPaused());
AssertCurrentThreadInMonitor();
// If the media was too short to trigger the start of the audio stream, // If the media was too short to trigger the start of the audio stream,
// start it now. // start it now.
mAudioStream->Start(); mAudioStream->Start();
{ mAudioStream->Drain();
ReentrantMonitorAutoExit exit(GetReentrantMonitor());
mAudioStream->Drain();
}
} }
void void
AudioSink::Cleanup() AudioSink::Cleanup()
{ {
AssertCurrentThreadInMonitor(); AssertOnAudioThread();
mEndPromise.Resolve(true, __func__); mEndPromise.Resolve(true, __func__);
// Since the promise if resolved asynchronously, we don't shutdown // Since the promise if resolved asynchronously, we don't shutdown
// AudioStream here so MDSM::ResyncAudioClock can get the correct // AudioStream here so MDSM::ResyncAudioClock can get the correct
@ -280,9 +277,9 @@ AudioSink::ExpectMoreAudioData()
bool bool
AudioSink::WaitingForAudioToPlay() AudioSink::WaitingForAudioToPlay()
{ {
AssertOnAudioThread();
// Return true if we're not playing, and we're not shutting down, or we're // 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. // playing and we've got no audio to play.
AssertCurrentThreadInMonitor();
if (!mStopAudioThread && (!mPlaying || ExpectMoreAudioData())) { if (!mStopAudioThread && (!mPlaying || ExpectMoreAudioData())) {
return true; return true;
} }
@ -292,7 +289,7 @@ AudioSink::WaitingForAudioToPlay()
bool bool
AudioSink::IsPlaybackContinuing() AudioSink::IsPlaybackContinuing()
{ {
AssertCurrentThreadInMonitor(); AssertOnAudioThread();
// If we're shutting down, captured, or at EOS, break out and exit the audio // If we're shutting down, captured, or at EOS, break out and exit the audio
// thread. // thread.
if (mStopAudioThread || AudioQueue().AtEndOfStream()) { if (mStopAudioThread || AudioQueue().AtEndOfStream()) {
@ -323,16 +320,13 @@ AudioSink::AudioLoop()
} }
case AUDIOSINK_STATE_PLAYING: { case AUDIOSINK_STATE_PLAYING: {
{ if (WaitingForAudioToPlay()) {
ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); // NotifyData() will schedule next loop.
if (WaitingForAudioToPlay()) { break;
// NotifyData() will schedule next loop. }
break; if (!IsPlaybackContinuing()) {
} SetState(AUDIOSINK_STATE_COMPLETE);
if (!IsPlaybackContinuing()) { break;
SetState(AUDIOSINK_STATE_COMPLETE);
break;
}
} }
if (!PlayAudio()) { if (!PlayAudio()) {
SetState(AUDIOSINK_STATE_COMPLETE); SetState(AUDIOSINK_STATE_COMPLETE);
@ -405,7 +399,7 @@ AudioSink::PlayAudio()
void void
AudioSink::FinishAudioLoop() AudioSink::FinishAudioLoop()
{ {
ReentrantMonitorAutoEnter mon(GetReentrantMonitor()); AssertOnAudioThread();
MOZ_ASSERT(mStopAudioThread || AudioQueue().AtEndOfStream()); MOZ_ASSERT(mStopAudioThread || AudioQueue().AtEndOfStream());
if (!mStopAudioThread && mPlaying) { if (!mStopAudioThread && mPlaying) {
Drain(); Drain();