bug 821299 - Make ALSA WebRTC backend expose proper IDs using device names. r=jesup
authorTed Mielczarek <ted@mielczarek.org>
Mon, 17 Dec 2012 08:28:24 -0500
changeset 125498 923df1a7c8cae86254f16edb79a1b05e32ccc1cf
parent 125497 fd40e91ec70351ba0c88685575fd3d6a2dc0ac23
child 125499 2755715976f098c256bff5efe1ab544cbb8e5c77
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs821299
milestone20.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 821299 - Make ALSA WebRTC backend expose proper IDs using device names. r=jesup
media/webrtc/trunk/src/modules/audio_device/main/source/linux/audio_device_alsa_linux.cc
media/webrtc/trunk/src/modules/audio_device/main/source/linux/audio_device_alsa_linux.h
--- a/media/webrtc/trunk/src/modules/audio_device/main/source/linux/audio_device_alsa_linux.cc
+++ b/media/webrtc/trunk/src/modules/audio_device/main/source/linux/audio_device_alsa_linux.cc
@@ -967,17 +967,18 @@ WebRtc_Word32 AudioDeviceLinuxALSA::Reco
 
     memset(name, 0, kAdmMaxDeviceNameSize);
 
     if (guid != NULL)
     {
         memset(guid, 0, kAdmMaxGuidSize);
     }
     
-    return GetDevicesInfo(1, false, index, name, kAdmMaxDeviceNameSize);
+    return GetDevicesInfo(1, false, index, name, kAdmMaxDeviceNameSize,
+                          guid, kAdmMaxGuidSize);
 }
 
 WebRtc_Word16 AudioDeviceLinuxALSA::RecordingDevices()
 {
 
     return (WebRtc_Word16)GetDevicesInfo(0, false);
 }
 
@@ -1811,17 +1812,19 @@ void AudioDeviceLinuxALSA::ClearRecordin
 //                                 Private Methods
 // ============================================================================
 
 WebRtc_Word32 AudioDeviceLinuxALSA::GetDevicesInfo(
     const WebRtc_Word32 function,
     const bool playback,
     const WebRtc_Word32 enumDeviceNo,
     char* enumDeviceName,
-    const WebRtc_Word32 ednLen) const
+    const WebRtc_Word32 ednLen,
+    char* enumDeviceId,
+    const WebRtc_Word32 ediLen) const
 {
     
     // Device enumeration based on libjingle implementation
     // by Tristan Schmelcher at Google Inc.
 
     const char *type = playback ? "Output" : "Input";
     // dmix and dsnoop are only for playback and capture, respectively, but ALSA
     // stupidly includes them in both lists.
@@ -1850,16 +1853,18 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetD
             return -1;
         }
 
         enumCount++; // default is 0
         if ((function == FUNC_GET_DEVICE_NAME ||
             function == FUNC_GET_DEVICE_NAME_FOR_AN_ENUM) && enumDeviceNo == 0)
         {
             strcpy(enumDeviceName, "default");
+            if (enumDeviceId)
+                memset(enumDeviceId, 0, ediLen);
 
             err = LATE(snd_device_name_free_hint)(hints);
             if (err != 0)
             {
                 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
                              "GetDevicesInfo - device name free hint error: %s",
                              LATE(snd_strerror)(err));
             }
@@ -1912,28 +1917,38 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetD
 
                 }
                 if ((FUNC_GET_DEVICE_NAME == function) &&
                     (enumDeviceNo == enumCount))
                 {
                     // We have found the enum device, copy the name to buffer.
                     strncpy(enumDeviceName, desc, ednLen);
                     enumDeviceName[ednLen-1] = '\0';
+                    if (enumDeviceId)
+                    {
+                        strncpy(enumDeviceId, name, ediLen);
+                        enumDeviceId[ediLen-1] = '\0';
+                    }
                     keepSearching = false;
                     // Replace '\n' with '-'.
                     char * pret = strchr(enumDeviceName, '\n'/*0xa*/); //LF
                     if (pret)
                         *pret = '-';
                 }
                 if ((FUNC_GET_DEVICE_NAME_FOR_AN_ENUM == function) &&
                     (enumDeviceNo == enumCount))
                 {
                     // We have found the enum device, copy the name to buffer.
                     strncpy(enumDeviceName, name, ednLen);
                     enumDeviceName[ednLen-1] = '\0';
+                    if (enumDeviceId)
+                    {
+                        strncpy(enumDeviceId, name, ediLen);
+                        enumDeviceId[ediLen-1] = '\0';
+                    }
                     keepSearching = false;
                 }
 
                 if (keepSearching)
                     ++enumCount;
 
                 if (desc != name)
                     free(desc);
--- a/media/webrtc/trunk/src/modules/audio_device/main/source/linux/audio_device_alsa_linux.h
+++ b/media/webrtc/trunk/src/modules/audio_device/main/source/linux/audio_device_alsa_linux.h
@@ -160,17 +160,19 @@ public:
 public:
     virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
 
 private:
     WebRtc_Word32 GetDevicesInfo(const WebRtc_Word32 function,
                                  const bool playback,
                                  const WebRtc_Word32 enumDeviceNo = 0,
                                  char* enumDeviceName = NULL,
-                                 const WebRtc_Word32 ednLen = 0) const;
+                                 const WebRtc_Word32 ednLen = 0,
+                                 char* enumDeviceID = NULL,
+                                 const WebRtc_Word32 ediLen = 0) const;
     WebRtc_Word32 ErrorRecovery(WebRtc_Word32 error, snd_pcm_t* deviceHandle);
 
 private:
     void Lock() { _critSect.Enter(); };
     void UnLock() { _critSect.Leave(); };
 private:
     inline WebRtc_Word32 InputSanityCheckAfterUnlockedPeriod() const;
     inline WebRtc_Word32 OutputSanityCheckAfterUnlockedPeriod() const;