mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 493109. Shut down step-decode thread from the main decoder thread, instead of synchronously on the main thread at bad times. r=doublec
--HG-- extra : rebase_source : 3a1a053308fc209181f7f23b234ba2f396de2a6e
This commit is contained in:
parent
fc6c9fa798
commit
017c3d03e8
@ -1110,15 +1110,6 @@ void nsOggDecodeStateMachine::Shutdown()
|
||||
mBufferExhausted = PR_FALSE;
|
||||
oggplay_prepare_for_close(mPlayer);
|
||||
}
|
||||
if (mStepDecodeThread) {
|
||||
// nsOggDecodeStateMachine::Shutdown is called at a safe
|
||||
// time to spin the event loop. This makes the following call
|
||||
// also safe.
|
||||
mon.Exit();
|
||||
mStepDecodeThread->Shutdown();
|
||||
mon.Enter();
|
||||
mStepDecodeThread = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
void nsOggDecodeStateMachine::Decode()
|
||||
@ -1156,6 +1147,19 @@ nsresult nsOggDecodeStateMachine::Run()
|
||||
if (mPlaying) {
|
||||
StopPlayback();
|
||||
}
|
||||
// Ensure mStepDecodeThread exits
|
||||
if (mStepDecodeThread) {
|
||||
mDecodingCompleted = PR_TRUE;
|
||||
mBufferExhausted = PR_FALSE;
|
||||
mon.NotifyAll();
|
||||
|
||||
mon.Exit();
|
||||
mStepDecodeThread->Shutdown();
|
||||
mon.Enter();
|
||||
NS_ASSERTION(mState == DECODER_STATE_SHUTDOWN,
|
||||
"How did we escape from the shutdown state???");
|
||||
mStepDecodeThread = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
case DECODER_STATE_DECODING_METADATA:
|
||||
@ -1237,6 +1241,9 @@ nsresult nsOggDecodeStateMachine::Run()
|
||||
mDecodingCompleted = PR_FALSE;
|
||||
mBufferExhausted = PR_FALSE;
|
||||
mon.NotifyAll();
|
||||
// We can call Shutdown here without releasing our monitor
|
||||
// because mStepDecodeThread has already exited
|
||||
// nsOggStepDecodeEvent.
|
||||
mStepDecodeThread->Shutdown();
|
||||
mStepDecodeThread = nsnull;
|
||||
continue;
|
||||
@ -1767,11 +1774,13 @@ public:
|
||||
|
||||
NS_IMETHOD Run() {
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be called on main thread");
|
||||
|
||||
// The decode thread must die before the state machine can die.
|
||||
// The state machine must die before the reader.
|
||||
// The state machine must die before the decoder.
|
||||
if (mDecodeThread)
|
||||
mDecodeThread->Shutdown();
|
||||
|
||||
mDecodeThread = nsnull;
|
||||
mDecodeStateMachine = nsnull;
|
||||
mReader = nsnull;
|
||||
@ -1830,7 +1839,6 @@ void nsOggDecoder::Stop()
|
||||
mDecodeThread);
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
|
||||
// Null data fields. They can be reinitialized in future Load()s safely now.
|
||||
mDecodeThread = nsnull;
|
||||
mDecodeStateMachine = nsnull;
|
||||
UnregisterShutdownObserver();
|
||||
|
Loading…
Reference in New Issue
Block a user