mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b=969089 allow an offline graph to shutdown before it's AudioDestinationNode is unlinked r=roc
A non-realtime graph does not start up again after finished processing, so it can safely enter LIFECYCLE_WAITING_FOR_STREAM_DESTRUCTION. --HG-- extra : transplant_source : %AF%98D%D5%EE%CA7zfv.%B4%F4%D8%05Q7%C2%8D%A7
This commit is contained in:
parent
ef330e24cd
commit
6ce60700bf
@ -1277,10 +1277,10 @@ MediaStreamGraphImpl::RunThread()
|
||||
// Enter shutdown mode. The stable-state handler will detect this
|
||||
// and complete shutdown. Destroy any streams immediately.
|
||||
STREAM_LOG(PR_LOG_DEBUG, ("MediaStreamGraph %p waiting for main thread cleanup", this));
|
||||
// Commit to shutting down this graph object.
|
||||
// We'll shut down this graph object if it does not get restarted.
|
||||
mLifecycleState = LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP;
|
||||
// No need to Destroy streams here. The main-thread owner of each
|
||||
// stream is responsible for calling Destroy them.
|
||||
// stream is responsible for calling Destroy on them.
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1421,11 +1421,15 @@ public:
|
||||
|
||||
// mGraph's thread is not running so it's OK to do whatever here
|
||||
if (mGraph->IsEmpty()) {
|
||||
// mGraph is no longer needed, so delete it. If the graph is not empty
|
||||
// then we must be in a forced shutdown and some later AppendMessage will
|
||||
// detect that the manager has been emptied, and delete it.
|
||||
// mGraph is no longer needed, so delete it.
|
||||
delete mGraph;
|
||||
} else {
|
||||
// The graph is not empty. We must be in a forced shutdown, or a
|
||||
// non-realtime graph that has finished processing. Some later
|
||||
// AppendMessage will detect that the manager has been emptied, and
|
||||
// delete it.
|
||||
NS_ASSERTION(mGraph->mForceShutDown || !mGraph->mRealtime,
|
||||
"Not in forced shutdown?");
|
||||
for (uint32_t i = 0; i < mGraph->mStreams.Length(); ++i) {
|
||||
DOMMediaStream* s = mGraph->mStreams[i]->GetWrapper();
|
||||
if (s) {
|
||||
@ -1433,7 +1437,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(mGraph->mForceShutDown, "Not in forced shutdown?");
|
||||
mGraph->mLifecycleState =
|
||||
MediaStreamGraphImpl::LIFECYCLE_WAITING_FOR_STREAM_DESTRUCTION;
|
||||
}
|
||||
@ -1565,7 +1568,7 @@ MediaStreamGraphImpl::RunInStableState()
|
||||
}
|
||||
}
|
||||
|
||||
if (mForceShutDown &&
|
||||
if ((mForceShutDown || !mRealtime) &&
|
||||
mLifecycleState == LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP) {
|
||||
// Defer calls to RunDuringShutdown() to happen while mMonitor is not held.
|
||||
for (uint32_t i = 0; i < mMessageQueue.Length(); ++i) {
|
||||
@ -1640,7 +1643,8 @@ MediaStreamGraphImpl::AppendMessage(ControlMessage* aMessage)
|
||||
// happened. From now on we can't append messages to mCurrentTaskMessageQueue,
|
||||
// because that will never be processed again, so just RunDuringShutdown
|
||||
// this message.
|
||||
// This should only happen during forced shutdown.
|
||||
// This should only happen during forced shutdown, or after a non-realtime
|
||||
// graph has finished processing.
|
||||
aMessage->RunDuringShutdown();
|
||||
delete aMessage;
|
||||
if (IsEmpty() &&
|
||||
|
@ -468,12 +468,13 @@ public:
|
||||
* creation after this point will create a new graph. An async event is
|
||||
* dispatched to Shutdown() the graph's threads and then delete the graph
|
||||
* object.
|
||||
* 2) Forced shutdown at application shutdown. A flag is set, RunThread()
|
||||
* detects the flag and exits, the next RunInStableState() detects the flag,
|
||||
* and dispatches the async event to Shutdown() the graph's threads. However
|
||||
* the graph object is not deleted. New messages for the graph are processed
|
||||
* synchronously on the main thread if necessary. When the last stream is
|
||||
* destroyed, the graph object is deleted.
|
||||
* 2) Forced shutdown at application shutdown, or completion of a
|
||||
* non-realtime graph. A flag is set, RunThread() detects the flag and
|
||||
* exits, the next RunInStableState() detects the flag, and dispatches the
|
||||
* async event to Shutdown() the graph's threads. However the graph object
|
||||
* is not deleted. New messages for the graph are processed synchronously on
|
||||
* the main thread if necessary. When the last stream is destroyed, the
|
||||
* graph object is deleted.
|
||||
*/
|
||||
enum LifecycleState {
|
||||
// The graph thread hasn't started yet.
|
||||
@ -491,8 +492,9 @@ public:
|
||||
// to shut down the graph thread(s).
|
||||
LIFECYCLE_WAITING_FOR_THREAD_SHUTDOWN,
|
||||
// Graph threads have shut down but we're waiting for remaining streams
|
||||
// to be destroyed. Only happens during application shutdown since normally
|
||||
// we'd only shut down a graph when it has no streams.
|
||||
// to be destroyed. Only happens during application shutdown and on
|
||||
// completed non-realtime graphs, since normally we'd only shut down a
|
||||
// realtime graph when it has no streams.
|
||||
LIFECYCLE_WAITING_FOR_STREAM_DESTRUCTION
|
||||
};
|
||||
LifecycleState mLifecycleState;
|
||||
|
Loading…
Reference in New Issue
Block a user