Loading dom/media/MediaManager.h +17 −16 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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(); } Loading Loading @@ -135,6 +143,7 @@ public: nsRefPtr<GetUserMediaNotificationEvent> event = new GetUserMediaNotificationEvent(GetUserMediaNotificationEvent::STARTING); NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL); } break; Loading @@ -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 Loading
dom/media/MediaManager.h +17 −16 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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(); } Loading Loading @@ -135,6 +143,7 @@ public: nsRefPtr<GetUserMediaNotificationEvent> event = new GetUserMediaNotificationEvent(GetUserMediaNotificationEvent::STARTING); NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL); } break; Loading @@ -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