mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 779721. Part 6: Add a flag to track whether the main thread has called Destroy on a stream, and check that flag when sending a message to it. r=jesup
This commit is contained in:
parent
8184332b0d
commit
e24a2e411e
@ -99,11 +99,12 @@ public:
|
||||
// When we're shutting down the application, most messages are ignored but
|
||||
// some cleanup messages should still be processed (on the main thread).
|
||||
virtual void RunDuringShutdown() {}
|
||||
MediaStream* GetStream() { return mStream; }
|
||||
|
||||
protected:
|
||||
// We do not hold a reference to mStream. The main thread will be holding
|
||||
// a reference to the stream while this message is in flight. The last message
|
||||
// referencing a stream is the Destroy message for that stream.
|
||||
// We do not hold a reference to mStream. The graph will be holding
|
||||
// a reference to the stream until the Destroy message is processed. The
|
||||
// last message referencing a stream is the Destroy message for that stream.
|
||||
MediaStream* mStream;
|
||||
};
|
||||
|
||||
@ -1537,6 +1538,9 @@ void
|
||||
MediaStreamGraphImpl::AppendMessage(ControlMessage* aMessage)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "main thread only");
|
||||
NS_ASSERTION(!aMessage->GetStream() ||
|
||||
!aMessage->GetStream()->IsDestroyed(),
|
||||
"Stream already destroyed");
|
||||
|
||||
if (mDetectedNotRunning &&
|
||||
mLifecycleState > LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP) {
|
||||
@ -1599,6 +1603,7 @@ MediaStream::Destroy()
|
||||
};
|
||||
mWrapper = nullptr;
|
||||
GraphImpl()->AppendMessage(new Message(this));
|
||||
mMainThreadDestroyed = true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -238,6 +238,7 @@ public:
|
||||
, mWrapper(aWrapper)
|
||||
, mMainThreadCurrentTime(0)
|
||||
, mMainThreadFinished(false)
|
||||
, mMainThreadDestroyed(false)
|
||||
{
|
||||
for (PRUint32 i = 0; i < ArrayLength(mFirstActiveTracks); ++i) {
|
||||
mFirstActiveTracks[i] = TRACK_NONE;
|
||||
@ -275,9 +276,22 @@ public:
|
||||
void Destroy();
|
||||
// Returns the main-thread's view of how much data has been processed by
|
||||
// this stream.
|
||||
StreamTime GetCurrentTime() { return mMainThreadCurrentTime; }
|
||||
StreamTime GetCurrentTime()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Call only on main thread");
|
||||
return mMainThreadCurrentTime;
|
||||
}
|
||||
// Return the main thread's view of whether this stream has finished.
|
||||
bool IsFinished() { return mMainThreadFinished; }
|
||||
bool IsFinished()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Call only on main thread");
|
||||
return mMainThreadFinished;
|
||||
}
|
||||
bool IsDestroyed()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Call only on main thread");
|
||||
return mMainThreadDestroyed;
|
||||
}
|
||||
|
||||
friend class MediaStreamGraphImpl;
|
||||
|
||||
@ -400,6 +414,7 @@ protected:
|
||||
// Main-thread views of state
|
||||
StreamTime mMainThreadCurrentTime;
|
||||
bool mMainThreadFinished;
|
||||
bool mMainThreadDestroyed;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user