зеркало из https://github.com/mozilla/gecko-dev.git
Bug 803093: Lock access to MediaEngineWebRTC singleton r=anant
This commit is contained in:
Родитель
7af2a0ac17
Коммит
bef0a4c1e2
|
@ -29,6 +29,8 @@ MediaEngineWebRTC::EnumerateVideoDevices(nsTArray<nsRefPtr<MediaEngineVideoSourc
|
|||
{
|
||||
webrtc::ViEBase* ptrViEBase;
|
||||
webrtc::ViECapture* ptrViECapture;
|
||||
// We spawn threads to handle gUM runnables, so we must protect the member vars
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (!mVideoEngine) {
|
||||
if (!(mVideoEngine = webrtc::VideoEngine::Create())) {
|
||||
|
@ -123,6 +125,8 @@ MediaEngineWebRTC::EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSourc
|
|||
{
|
||||
webrtc::VoEBase* ptrVoEBase = NULL;
|
||||
webrtc::VoEHardware* ptrVoEHw = NULL;
|
||||
// We spawn threads to handle gUM runnables, so we must protect the member vars
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (!mVoiceEngine) {
|
||||
mVoiceEngine = webrtc::VoiceEngine::Create();
|
||||
|
@ -181,6 +185,9 @@ MediaEngineWebRTC::EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSourc
|
|||
void
|
||||
MediaEngineWebRTC::Shutdown()
|
||||
{
|
||||
// This is likely paranoia
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (mVideoEngine) {
|
||||
mVideoSources.Clear();
|
||||
webrtc::VideoEngine::Delete(mVideoEngine);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "nsIThread.h"
|
||||
#include "nsIRunnable.h"
|
||||
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
@ -218,10 +219,12 @@ class MediaEngineWebRTC : public MediaEngine
|
|||
{
|
||||
public:
|
||||
MediaEngineWebRTC()
|
||||
: mVideoEngine(NULL)
|
||||
: mMutex("mozilla::MediaEngineWebRTC")
|
||||
, mVideoEngine(NULL)
|
||||
, mVoiceEngine(NULL)
|
||||
, mVideoEngineInit(false)
|
||||
, mAudioEngineInit(false) {
|
||||
, mAudioEngineInit(false)
|
||||
{
|
||||
mVideoSources.Init();
|
||||
mAudioSources.Init();
|
||||
}
|
||||
|
@ -235,6 +238,9 @@ public:
|
|||
virtual void EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSource> >*);
|
||||
|
||||
private:
|
||||
Mutex mMutex;
|
||||
// protected with mMutex:
|
||||
|
||||
webrtc::VideoEngine* mVideoEngine;
|
||||
webrtc::VoiceEngine* mVoiceEngine;
|
||||
|
||||
|
|
|
@ -812,6 +812,7 @@ MediaManager::GetUserMedia(bool aPrivileged, nsPIDOMWindow* aWindow,
|
|||
if (!mMediaThread) {
|
||||
nsresult rv = NS_NewThread(getter_AddRefs(mMediaThread));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
LOG(("New Media thread for gum"));
|
||||
}
|
||||
mMediaThread->Dispatch(gUMRunnable, NS_DISPATCH_NORMAL);
|
||||
} else {
|
||||
|
@ -952,8 +953,11 @@ MediaManager::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
|
||||
// Reuse the same thread to save memory.
|
||||
if (!mMediaThread) {
|
||||
LOG(("New Media thread for gum on allow"));
|
||||
nsresult rv = NS_NewThread(getter_AddRefs(mMediaThread));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else {
|
||||
LOG(("Reused Media thread for gum on allow"));
|
||||
}
|
||||
|
||||
if (aSubject) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче