Bug 993787: Make MediaEngine threadsafe r=ehsan

This commit is contained in:
Randell Jesup 2014-04-11 11:35:34 -04:00
parent f44247f985
commit 535042d8d1
3 changed files with 16 additions and 12 deletions

View File

@ -36,11 +36,10 @@ enum {
kAudioTrack = 2
};
class MediaEngine : public RefCounted<MediaEngine>
class MediaEngine
{
public:
MOZ_DECLARE_REFCOUNTED_TYPENAME(MediaEngine)
virtual ~MediaEngine() {}
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaEngine)
static const int DEFAULT_VIDEO_FPS = 30;
static const int DEFAULT_VIDEO_MIN_FPS = 10;
@ -55,6 +54,9 @@ public:
/* Populate an array of audio sources in the nsTArray. Also include devices
* that are currently unavailable. */
virtual void EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSource> >*) = 0;
protected:
virtual ~MediaEngine() {}
};
/**

View File

@ -131,12 +131,13 @@ public:
MediaEngineDefault()
: mMutex("mozilla::MediaEngineDefault")
{}
~MediaEngineDefault() {}
virtual void EnumerateVideoDevices(nsTArray<nsRefPtr<MediaEngineVideoSource> >*);
virtual void EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSource> >*);
private:
~MediaEngineDefault() {}
Mutex mMutex;
// protected with mMutex:

View File

@ -350,14 +350,6 @@ class MediaEngineWebRTC : public MediaEngine
{
public:
MediaEngineWebRTC(MediaEnginePrefs &aPrefs);
~MediaEngineWebRTC() {
Shutdown();
#ifdef MOZ_B2G_CAMERA
AsyncLatencyLogger::Get()->Release();
#endif
// XXX
gFarendObserver = nullptr;
}
// Clients should ensure to clean-up sources video/audio sources
// before invoking Shutdown on this class.
@ -367,6 +359,15 @@ public:
virtual void EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSource> >*);
private:
~MediaEngineWebRTC() {
Shutdown();
#ifdef MOZ_B2G_CAMERA
AsyncLatencyLogger::Get()->Release();
#endif
// XXX
gFarendObserver = nullptr;
}
Mutex mMutex;
// protected with mMutex: