Bug 1582637 - Remove unnecessary MediaEngineWebRTC::mMutex. r=jib

Differential Revision: https://phabricator.services.mozilla.com/D48515

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Pehrson 2019-10-29 13:01:36 +00:00
Родитель 5e2a4e0c27
Коммит 94356644ac
2 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -35,10 +35,11 @@ CubebDeviceEnumerator* GetEnumerator() {
} }
MediaEngineWebRTC::MediaEngineWebRTC(MediaEnginePrefs& aPrefs) MediaEngineWebRTC::MediaEngineWebRTC(MediaEnginePrefs& aPrefs)
: mMutex("mozilla::MediaEngineWebRTC"), : mDelayAgnostic(aPrefs.mDelayAgnostic),
mDelayAgnostic(aPrefs.mDelayAgnostic),
mExtendedFilter(aPrefs.mExtendedFilter), mExtendedFilter(aPrefs.mExtendedFilter),
mHasTabVideoSource(false) { mHasTabVideoSource(false) {
AssertIsOnOwningThread();
nsCOMPtr<nsIComponentRegistrar> compMgr; nsCOMPtr<nsIComponentRegistrar> compMgr;
NS_GetComponentRegistrar(getter_AddRefs(compMgr)); NS_GetComponentRegistrar(getter_AddRefs(compMgr));
if (compMgr) { if (compMgr) {
@ -51,13 +52,15 @@ MediaEngineWebRTC::MediaEngineWebRTC(MediaEnginePrefs& aPrefs)
} }
void MediaEngineWebRTC::SetFakeDeviceChangeEvents() { void MediaEngineWebRTC::SetFakeDeviceChangeEvents() {
AssertIsOnOwningThread();
GetChildAndCall(&CamerasChild::SetFakeDeviceChangeEvents); GetChildAndCall(&CamerasChild::SetFakeDeviceChangeEvents);
} }
void MediaEngineWebRTC::EnumerateVideoDevices( void MediaEngineWebRTC::EnumerateVideoDevices(
uint64_t aWindowId, camera::CaptureEngine aCapEngine, uint64_t aWindowId, camera::CaptureEngine aCapEngine,
nsTArray<RefPtr<MediaDevice>>* aDevices) { nsTArray<RefPtr<MediaDevice>>* aDevices) {
mMutex.AssertCurrentThreadOwns(); AssertIsOnOwningThread();
// flag sources with cross-origin exploit potential // flag sources with cross-origin exploit potential
bool scaryKind = (aCapEngine == camera::ScreenEngine || bool scaryKind = (aCapEngine == camera::ScreenEngine ||
aCapEngine == camera::BrowserEngine); aCapEngine == camera::BrowserEngine);
@ -151,7 +154,7 @@ void MediaEngineWebRTC::EnumerateVideoDevices(
void MediaEngineWebRTC::EnumerateMicrophoneDevices( void MediaEngineWebRTC::EnumerateMicrophoneDevices(
uint64_t aWindowId, nsTArray<RefPtr<MediaDevice>>* aDevices) { uint64_t aWindowId, nsTArray<RefPtr<MediaDevice>>* aDevices) {
mMutex.AssertCurrentThreadOwns(); AssertIsOnOwningThread();
nsTArray<RefPtr<AudioDeviceInfo>> devices; nsTArray<RefPtr<AudioDeviceInfo>> devices;
GetEnumerator()->EnumerateAudioInputDevices(devices); GetEnumerator()->EnumerateAudioInputDevices(devices);
@ -202,6 +205,8 @@ void MediaEngineWebRTC::EnumerateMicrophoneDevices(
void MediaEngineWebRTC::EnumerateSpeakerDevices( void MediaEngineWebRTC::EnumerateSpeakerDevices(
uint64_t aWindowId, nsTArray<RefPtr<MediaDevice>>* aDevices) { uint64_t aWindowId, nsTArray<RefPtr<MediaDevice>>* aDevices) {
AssertIsOnOwningThread();
nsTArray<RefPtr<AudioDeviceInfo>> devices; nsTArray<RefPtr<AudioDeviceInfo>> devices;
GetEnumerator()->EnumerateAudioOutputDevices(devices); GetEnumerator()->EnumerateAudioOutputDevices(devices);
@ -235,9 +240,9 @@ void MediaEngineWebRTC::EnumerateSpeakerDevices(
void MediaEngineWebRTC::EnumerateDevices( void MediaEngineWebRTC::EnumerateDevices(
uint64_t aWindowId, dom::MediaSourceEnum aMediaSource, uint64_t aWindowId, dom::MediaSourceEnum aMediaSource,
MediaSinkEnum aMediaSink, nsTArray<RefPtr<MediaDevice>>* aDevices) { MediaSinkEnum aMediaSink, nsTArray<RefPtr<MediaDevice>>* aDevices) {
AssertIsOnOwningThread();
MOZ_ASSERT(aMediaSource != dom::MediaSourceEnum::Other || MOZ_ASSERT(aMediaSource != dom::MediaSourceEnum::Other ||
aMediaSink != MediaSinkEnum::Other); aMediaSink != MediaSinkEnum::Other);
MutexAutoLock lock(mMutex);
if (MediaEngineSource::IsVideo(aMediaSource)) { if (MediaEngineSource::IsVideo(aMediaSource)) {
switch (aMediaSource) { switch (aMediaSource) {
case dom::MediaSourceEnum::Window: case dom::MediaSourceEnum::Window:
@ -278,9 +283,7 @@ void MediaEngineWebRTC::EnumerateDevices(
} }
void MediaEngineWebRTC::Shutdown() { void MediaEngineWebRTC::Shutdown() {
// This is likely paranoia AssertIsOnOwningThread();
MutexAutoLock lock(mMutex);
if (camera::GetCamerasChildIfExists()) { if (camera::GetCamerasChildIfExists()) {
GetChildAndCall(&CamerasChild::RemoveDeviceChangeCallback, this); GetChildAndCall(&CamerasChild::RemoveDeviceChangeCallback, this);
} }

Просмотреть файл

@ -74,8 +74,6 @@ class MediaEngineWebRTC : public MediaEngine {
void EnumerateSpeakerDevices(uint64_t aWindowId, void EnumerateSpeakerDevices(uint64_t aWindowId,
nsTArray<RefPtr<MediaDevice>>*); nsTArray<RefPtr<MediaDevice>>*);
// gUM runnables can e.g. Enumerate from multiple threads
Mutex mMutex;
const bool mDelayAgnostic; const bool mDelayAgnostic;
const bool mExtendedFilter; const bool mExtendedFilter;
// This also is set in the ctor and then never changed, but we can't make it // This also is set in the ctor and then never changed, but we can't make it