Merge Chromium issue 95797 into WebRTC.
Bug = 450 Test = Manual test Review URL: https://webrtc-codereview.appspot.com/551004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2192 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
7415f371ac
commit
113f851cc3
@ -1834,10 +1834,14 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetDevicesInfo(
|
|||||||
int enumCount(0);
|
int enumCount(0);
|
||||||
bool keepSearching(true);
|
bool keepSearching(true);
|
||||||
|
|
||||||
|
// From Chromium issue 95797
|
||||||
|
// Loop through the sound cards to get Alsa device hints.
|
||||||
|
// Don't use snd_device_name_hint(-1,..) since there is a access violation
|
||||||
|
// inside this ALSA API with libasound.so.2.0.0.
|
||||||
|
int card = -1;
|
||||||
|
while (!(LATE(snd_card_next)(&card)) && (card >= 0) && keepSearching) {
|
||||||
void **hints;
|
void **hints;
|
||||||
err = LATE(snd_device_name_hint)(-1, // All cards
|
err = LATE(snd_device_name_hint)(card, "pcm", &hints);
|
||||||
"pcm", // Only PCM devices
|
|
||||||
&hints);
|
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
||||||
@ -1847,14 +1851,19 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetDevicesInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
enumCount++; // default is 0
|
enumCount++; // default is 0
|
||||||
if (function == FUNC_GET_DEVICE_NAME && enumDeviceNo == 0)
|
if ((function == FUNC_GET_DEVICE_NAME ||
|
||||||
|
function == FUNC_GET_DEVICE_NAME_FOR_AN_ENUM) && enumDeviceNo == 0)
|
||||||
{
|
{
|
||||||
strcpy(enumDeviceName, "default");
|
strcpy(enumDeviceName, "default");
|
||||||
return 0;
|
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
if (function == FUNC_GET_DEVICE_NAME_FOR_AN_ENUM && enumDeviceNo == 0)
|
|
||||||
{
|
|
||||||
strcpy(enumDeviceName, "default");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1892,7 +1901,7 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetDevicesInfo(
|
|||||||
if (!desc)
|
if (!desc)
|
||||||
{
|
{
|
||||||
// Virtual devices don't necessarily have descriptions.
|
// Virtual devices don't necessarily have descriptions.
|
||||||
// Use their names instead
|
// Use their names instead.
|
||||||
desc = name;
|
desc = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1905,12 +1914,11 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetDevicesInfo(
|
|||||||
if ((FUNC_GET_DEVICE_NAME == function) &&
|
if ((FUNC_GET_DEVICE_NAME == function) &&
|
||||||
(enumDeviceNo == enumCount))
|
(enumDeviceNo == enumCount))
|
||||||
{
|
{
|
||||||
|
// We have found the enum device, copy the name to buffer.
|
||||||
// We have found the enum device, copy the name to buffer
|
|
||||||
strncpy(enumDeviceName, desc, ednLen);
|
strncpy(enumDeviceName, desc, ednLen);
|
||||||
enumDeviceName[ednLen-1] = '\0';
|
enumDeviceName[ednLen-1] = '\0';
|
||||||
keepSearching = false;
|
keepSearching = false;
|
||||||
// replace '\n' with '-'
|
// Replace '\n' with '-'.
|
||||||
char * pret = strchr(enumDeviceName, '\n'/*0xa*/); //LF
|
char * pret = strchr(enumDeviceName, '\n'/*0xa*/); //LF
|
||||||
if (pret)
|
if (pret)
|
||||||
*pret = '-';
|
*pret = '-';
|
||||||
@ -1918,29 +1926,24 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetDevicesInfo(
|
|||||||
if ((FUNC_GET_DEVICE_NAME_FOR_AN_ENUM == function) &&
|
if ((FUNC_GET_DEVICE_NAME_FOR_AN_ENUM == function) &&
|
||||||
(enumDeviceNo == enumCount))
|
(enumDeviceNo == enumCount))
|
||||||
{
|
{
|
||||||
// We have found the enum device, copy the name to buffer
|
// We have found the enum device, copy the name to buffer.
|
||||||
strncpy(enumDeviceName, name, ednLen);
|
strncpy(enumDeviceName, name, ednLen);
|
||||||
enumDeviceName[ednLen-1] = '\0';
|
enumDeviceName[ednLen-1] = '\0';
|
||||||
keepSearching = false;
|
keepSearching = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keepSearching)
|
if (keepSearching)
|
||||||
{
|
|
||||||
++enumCount;
|
++enumCount;
|
||||||
}
|
|
||||||
|
|
||||||
if (desc != name)
|
if (desc != name)
|
||||||
{
|
|
||||||
free(desc);
|
free(desc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
if (!keepSearching)
|
if (!keepSearching)
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
err = LATE(snd_device_name_free_hint)(hints);
|
err = LATE(snd_device_name_free_hint)(hints);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
@ -1948,7 +1951,8 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetDevicesInfo(
|
|||||||
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
||||||
"GetDevicesInfo - device name free hint error: %s",
|
"GetDevicesInfo - device name free hint error: %s",
|
||||||
LATE(snd_strerror)(err));
|
LATE(snd_strerror)(err));
|
||||||
// Continue and return true anyways, since we did get the whole list.
|
// Continue and return true anyway, since we did get the whole list.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FUNC_GET_NUM_OF_DEVICE == function)
|
if (FUNC_GET_NUM_OF_DEVICE == function)
|
||||||
@ -1961,7 +1965,7 @@ WebRtc_Word32 AudioDeviceLinuxALSA::GetDevicesInfo(
|
|||||||
if (keepSearching)
|
if (keepSearching)
|
||||||
{
|
{
|
||||||
// If we get here for function 1 and 2, we didn't find the specified
|
// If we get here for function 1 and 2, we didn't find the specified
|
||||||
// enum device
|
// enum device.
|
||||||
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
||||||
"GetDevicesInfo - Could not find device name or numbers");
|
"GetDevicesInfo - Could not find device name or numbers");
|
||||||
return -1;
|
return -1;
|
||||||
@ -2151,7 +2155,7 @@ bool AudioDeviceLinuxALSA::PlayThreadProcess()
|
|||||||
if (frames < 0)
|
if (frames < 0)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id,
|
WEBRTC_TRACE(kTraceStream, kTraceAudioDevice, _id,
|
||||||
"playout snd_pcm_avail_update error: %s",
|
"playout snd_pcm_writei error: %s",
|
||||||
LATE(snd_strerror)(frames));
|
LATE(snd_strerror)(frames));
|
||||||
_playoutFramesLeft = 0;
|
_playoutFramesLeft = 0;
|
||||||
ErrorRecovery(frames, _handlePlayout);
|
ErrorRecovery(frames, _handlePlayout);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user