Bug 1434439 - Avoid stray capability requirement in StartCapture failure case. r=pehrsons
authorJan-Ivar Bruaroey <jib@mozilla.com>
Tue, 27 Feb 2018 14:04:57 -0500
changeset 461774 3c3ae4a1a7ede1ed97de25bd6206fcd0fb38a3b6
parent 461773 9ea189de40f3e1d0a026da68915166c17ab91044
child 461775 b03fd1004cacad2e79713f85ab055099ae4b0da2
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1434439
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1434439 - Avoid stray capability requirement in StartCapture failure case. r=pehrsons MozReview-Commit-ID: BEgnoOizMjt
dom/media/systemservices/CamerasParent.cpp
--- a/dom/media/systemservices/CamerasParent.cpp
+++ b/dom/media/systemservices/CamerasParent.cpp
@@ -880,21 +880,22 @@ CamerasParent::RecvStartCapture(const Ca
           capability.width = ipcCaps.width();
           capability.height = ipcCaps.height();
           capability.maxFPS = ipcCaps.maxFPS();
           capability.expectedCaptureDelay = ipcCaps.expectedCaptureDelay();
           capability.rawType = static_cast<webrtc::RawVideoType>(ipcCaps.rawType());
           capability.codecType = static_cast<webrtc::VideoCodecType>(ipcCaps.codecType());
           capability.interlaced = ipcCaps.interlaced();
 
-#ifdef DEBUG
-          auto deviceUniqueID = sDeviceUniqueIDs.find(capnum);
-          MOZ_ASSERT(deviceUniqueID == sDeviceUniqueIDs.end());
-#endif
+          MOZ_DIAGNOSTIC_ASSERT(sDeviceUniqueIDs.find(capnum) ==
+                                sDeviceUniqueIDs.end());
           sDeviceUniqueIDs.emplace(capnum, cap.VideoCapture()->CurrentDeviceName());
+
+          MOZ_DIAGNOSTIC_ASSERT(sAllRequestedCapabilities.find(capnum) ==
+                                sAllRequestedCapabilities.end());
           sAllRequestedCapabilities.emplace(capnum, capability);
 
           if (aCapEngine == CameraEngine) {
             for (const auto &it : sDeviceUniqueIDs) {
               if (strcmp(it.second, cap.VideoCapture()->CurrentDeviceName()) == 0) {
                 capability.width = std::max(
                   capability.width, sAllRequestedCapabilities[it.first].width);
                 capability.height = std::max(
@@ -944,16 +945,19 @@ CamerasParent::RecvStartCapture(const Ca
             }
           }
 
           error = cap.VideoCapture()->StartCapture(capability);
 
           if (!error) {
             cap.VideoCapture()->RegisterCaptureDataCallback(
               static_cast<rtc::VideoSinkInterface<webrtc::VideoFrame>*>(*cbh));
+          } else {
+            sDeviceUniqueIDs.erase(capnum);
+            sAllRequestedCapabilities.erase(capnum);
           }
         });
       }
       RefPtr<nsIRunnable> ipc_runnable =
         media::NewRunnableFrom([self, error]() -> nsresult {
           if (!self->mChildIsAlive) {
             return NS_ERROR_FAILURE;
           }