Bug 826104 - Fix audio thread shutdown crash. r=roc

This commit is contained in:
Matthew Gregan 2013-01-14 18:25:02 +13:00
parent d24645d8fc
commit 9036474989

View File

@ -1016,7 +1016,6 @@ void MediaDecoderStateMachine::AudioLoop()
}
}
while (1) {
// Wait while we're not playing, and we're not shutting down, or we're
// playing and we've got no audio to play.
{
@ -1286,7 +1285,7 @@ void MediaDecoderStateMachine::StartPlayback()
NS_ASSERTION(!IsPlaying(), "Shouldn't be playing when StartPlayback() is called");
mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
LOG(PR_LOG_DEBUG, ("%p StartPlayback", mDecoder.get()));
mDecoder->NotifyPlaybackStarted();
mPlayStartTime = TimeStamp::Now();
@ -2058,6 +2057,14 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
StopPlayback();
}
StopAudioThread();
// If mAudioThread is non-null after StopAudioThread completes, we are
// running in a nested event loop waiting for Shutdown() on
// mAudioThread to complete. Return to the event loop and let it
// finish processing before continuing with shutdown.
if (mAudioThread) {
MOZ_ASSERT(mStopAudioThread);
return NS_OK;
}
StopDecodeThread();
// Now that those threads are stopped, there's no possibility of
// mPendingWakeDecoder being needed again. Revoke it.
@ -2220,7 +2227,7 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
NS_ASSERTION(IsStateMachineScheduled(), "Must have timer scheduled");
return NS_OK;
}
StopAudioThread();
if (mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING) {
int64_t videoTime = HasVideo() ? mVideoFrameEndTime : 0;
@ -2659,7 +2666,7 @@ void MediaDecoderStateMachine::TimeoutExpired()
void MediaDecoderStateMachine::ScheduleStateMachineWithLockAndWakeDecoder() {
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
mon.NotifyAll();
ScheduleStateMachine(0);
ScheduleStateMachine();
}
nsresult MediaDecoderStateMachine::ScheduleStateMachine(int64_t aUsecs) {