Bug 802399: set capture index for audio input when device is Allocate()ed, plug VoEHw leak r=derf
authorRandell Jesup <rjesup@jesup.org>
Thu, 15 Nov 2012 18:23:39 -0500
changeset 113426 5444aff38dfb15f91b2c343208418cdb7849fdb0
parent 113425 244493403e8922b6fcf4e6abe7e0248d804939d2
child 113427 a3ea6aa33de6c18651aca7633221dcf7373eb18b
push id18150
push userrjesup@wgate.com
push dateThu, 15 Nov 2012 23:24:02 +0000
treeherdermozilla-inbound@5444aff38dfb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersderf
bugs802399
milestone19.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 802399: set capture index for audio input when device is Allocate()ed, plug VoEHw leak r=derf
content/media/webrtc/MediaEngineWebRTCAudio.cpp
--- a/content/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/content/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -48,16 +48,24 @@ MediaEngineWebRTCAudioSource::GetUUID(ns
 
 nsresult
 MediaEngineWebRTCAudioSource::Allocate()
 {
   if (mState != kReleased) {
     return NS_ERROR_FAILURE;
   }
 
+  webrtc::VoEHardware* ptrVoEHw = webrtc::VoEHardware::GetInterface(mVoiceEngine);
+  int res = ptrVoEHw->SetRecordingDevice(mCapIndex);
+  ptrVoEHw->Release();
+  if (res) {
+    return NS_ERROR_FAILURE;
+  }
+
+  LOG(("Audio device %d allocated", mCapIndex));
   mState = kAllocated;
   return NS_OK;
 }
 
 nsresult
 MediaEngineWebRTCAudioSource::Deallocate()
 {
   if (mState != kStopped && mState != kAllocated) {
@@ -172,21 +180,23 @@ MediaEngineWebRTCAudioSource::Init()
   mNullTransport = new NullTransport();
   if (mVoENetwork->RegisterExternalTransport(mChannel, *mNullTransport)) {
     return;
   }
 
   // Check for availability.
   webrtc::VoEHardware* ptrVoEHw = webrtc::VoEHardware::GetInterface(mVoiceEngine);
   if (ptrVoEHw->SetRecordingDevice(mCapIndex)) {
+    ptrVoEHw->Release();
     return;
   }
 
   bool avail = false;
   ptrVoEHw->GetRecordingDeviceStatus(avail);
+  ptrVoEHw->Release();
   if (!avail) {
     return;
   }
 
   // Set "codec" to PCM, 32kHz on 1 channel
   webrtc::VoECodec* ptrVoECodec;
   webrtc::CodecInst codec;
   ptrVoECodec = webrtc::VoECodec::GetInterface(mVoiceEngine);