mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 817841: Proxy deletion of nsDOMMediaStreams with NS_ProxyRelease() r=roc
This commit is contained in:
parent
87eed6808b
commit
a244dd198f
@ -67,8 +67,7 @@ class GetUserMediaNotificationEvent: public nsRunnable
|
||||
|
||||
typedef enum {
|
||||
MEDIA_START,
|
||||
MEDIA_STOP,
|
||||
MEDIA_RELEASE
|
||||
MEDIA_STOP
|
||||
} MediaOperation;
|
||||
|
||||
// Generic class for running long media operations off the main thread, and
|
||||
@ -101,12 +100,21 @@ public:
|
||||
, mSourceStream(aStream)
|
||||
{}
|
||||
|
||||
~MediaOperationRunnable()
|
||||
{
|
||||
// nsDOMMediaStreams are cycle-collected and thus main-thread-only for
|
||||
// refcounting and releasing
|
||||
if (mStream) {
|
||||
nsCOMPtr<nsIThread> mainThread = do_GetMainThread();
|
||||
NS_ProxyRelease(mainThread,mStream,false);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Run()
|
||||
{
|
||||
// No locking between these is required as all the callbacks (other
|
||||
// than MEDIA_RELEASE) for the same MediaStream will occur on the same
|
||||
// thread.
|
||||
// No locking between these is required as all the callbacks for the
|
||||
// same MediaStream will occur on the same thread.
|
||||
if (mStream) {
|
||||
mSourceStream = mStream->GetStream()->AsSourceStream();
|
||||
}
|
||||
@ -135,6 +143,7 @@ public:
|
||||
nsRefPtr<GetUserMediaNotificationEvent> event =
|
||||
new GetUserMediaNotificationEvent(GetUserMediaNotificationEvent::STARTING);
|
||||
|
||||
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
break;
|
||||
@ -159,23 +168,15 @@ public:
|
||||
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||
}
|
||||
break;
|
||||
case MEDIA_RELEASE:
|
||||
// We go to MainThread to die
|
||||
break;
|
||||
}
|
||||
if (mType != MEDIA_RELEASE) {
|
||||
// nsDOMMediaStreams aren't thread-safe... sigh.
|
||||
mType = MEDIA_RELEASE;
|
||||
NS_DispatchToMainThread(this);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
MediaOperation mType;
|
||||
nsRefPtr<MediaEngineSource> mAudioSource;
|
||||
nsRefPtr<MediaEngineSource> mVideoSource;
|
||||
nsRefPtr<nsDOMMediaStream> mStream;
|
||||
nsRefPtr<MediaEngineSource> mAudioSource; // threadsafe
|
||||
nsRefPtr<MediaEngineSource> mVideoSource; // threadsafe
|
||||
nsRefPtr<nsDOMMediaStream> mStream; // not threadsafe
|
||||
SourceMediaStream *mSourceStream;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user