From 1051352e8722ee2c3f4b8f9303a3962ed9110045 Mon Sep 17 00:00:00 2001 From: Munro Mengjue Chiang Date: Wed, 6 Dec 2017 19:09:40 +0800 Subject: [PATCH] Bug 1423515 - register callback while creating the real backend. r=pehrsons MozReview-Commit-ID: 2uVZ9VBAut0 --HG-- extra : rebase_source : e51862ad3f4ec74066b080eac66d69f428b86426 --- dom/media/MediaManager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index fe050b0123aa..e14880193c92 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -1721,8 +1721,6 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId, MediaManager* manager = MediaManager::GetIfExists(); MOZ_RELEASE_ASSERT(manager); // Must exist while media thread is alive realBackend = manager->GetBackend(aWindowId); - // We need to listen to this event even JS didn't listen to it. - realBackend->AddDeviceChangeCallback(manager); } auto result = MakeUnique(); @@ -2025,6 +2023,9 @@ int MediaManager::AddDeviceChangeCallback(DeviceChangeCallback* aCallback) MediaManager::PostTask(NewTaskFrom([fakeDeviceChangeEventOn]() { MediaManager* manager = MediaManager::GetIfExists(); MOZ_RELEASE_ASSERT(manager); // Must exist while media thread is alive + // this is needed in case persistent permission is given but no gUM() + // or enumeration() has created the real backend yet + manager->GetBackend(0); if (fakeDeviceChangeEventOn) manager->GetBackend(0)->SetFakeDeviceChangeEvents(); })); @@ -2916,6 +2917,7 @@ MediaManager::GetBackend(uint64_t aWindowId) #else mBackend = new MediaEngineDefault(); #endif + mBackend->AddDeviceChangeCallback(this); } return mBackend; }