Bug 918056 - Return errors when the mic is occupied. r=rjesup, a=koi+
authorSteven Lee <slee@mozilla.com>
Tue, 01 Oct 2013 08:06:57 -0400
changeset 160537 ee295442876872ab55045cdc049475e37ef42d85
parent 160536 e6472281dabf6ced89c4d4d3cb19fbffb2eee6e9
child 160538 6ceec89689308eba49c6b7424e34178ffd37dc60
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrjesup, koi
bugs918056
milestone26.0a2
Bug 918056 - Return errors when the mic is occupied. r=rjesup, a=koi+
content/media/webrtc/MediaEngineWebRTCAudio.cpp
--- a/content/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -98,25 +98,30 @@ MediaEngineWebRTCAudioSource::Config(boo
     }
   }
   return NS_OK;
 }
 
 nsresult
 MediaEngineWebRTCAudioSource::Allocate(const MediaEnginePrefs &aPrefs)
 {
-  if (mState == kReleased && mInitDone) {
-    webrtc::VoEHardware* ptrVoEHw = webrtc::VoEHardware::GetInterface(mVoiceEngine);
-    int res = ptrVoEHw->SetRecordingDevice(mCapIndex);
-    ptrVoEHw->Release();
-    if (res) {
+  if (mState == kReleased) {
+    if (mInitDone) {
+      webrtc::VoEHardware* ptrVoEHw = webrtc::VoEHardware::GetInterface(mVoiceEngine);
+      int res = ptrVoEHw->SetRecordingDevice(mCapIndex);
+      ptrVoEHw->Release();
+      if (res) {
+        return NS_ERROR_FAILURE;
+      }
+      mState = kAllocated;
+      LOG(("Audio device %d allocated", mCapIndex));
+    } else {
+      LOG(("Audio device is not initalized"));
       return NS_ERROR_FAILURE;
     }
-    mState = kAllocated;
-    LOG(("Audio device %d allocated", mCapIndex));
   } else if (mSources.IsEmpty()) {
     LOG(("Audio device %d reallocated", mCapIndex));
   } else {
     LOG(("Audio device %d allocated shared", mCapIndex));
   }
   return NS_OK;
 }