diff options
author | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-11 20:57:03 +0000 |
---|---|---|
committer | dbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-11 20:57:03 +0000 |
commit | 345c13e75c87b5693c0238d48b6c22e70ad5d25d (patch) | |
tree | 7dba225583e132ee048dc6f418a4433c997df9dc /media | |
parent | 07fb7cc3ec0005f4480c0bf9d203c1612d1d732c (diff) | |
download | chromium_src-345c13e75c87b5693c0238d48b6c22e70ad5d25d.zip chromium_src-345c13e75c87b5693c0238d48b6c22e70ad5d25d.tar.gz chromium_src-345c13e75c87b5693c0238d48b6c22e70ad5d25d.tar.bz2 |
Revert 172385
Broke content_unittests on Linux (aura) and Linux (clang)
> Let ALSA enumerate audio devices rather than iterating over physical devices.
>
> Some configurations (e.g. Chromoting virtual desktops) have no audio hardware,
> but still provide valid ALSA output devices that Chrome can use.
>
> BUG=162953,165401
>
>
> Review URL: https://chromiumcodereview.appspot.com/11299222
TBR=wez@chromium.org
Review URL: https://codereview.chromium.org/11528021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172396 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/audio_input_unittest.cc | 8 | ||||
-rw-r--r-- | media/audio/linux/audio_manager_linux.cc | 77 |
2 files changed, 42 insertions, 43 deletions
diff --git a/media/audio/audio_input_unittest.cc b/media/audio/audio_input_unittest.cc index 380312f..5a02323b 100644 --- a/media/audio/audio_input_unittest.cc +++ b/media/audio/audio_input_unittest.cc @@ -137,13 +137,7 @@ TEST(AudioInputTest, OpenStopAndClose) { } // Test a normal recording sequence using an AudioInputStream. -// This test currently fails on the Linux bots (crbug.com/165401). -#if defined(OS_LINUX) -#define MAYBE_Record DISABLED_Record -#else -#define MAYBE_Record Record -#endif // defined(OS_LINUX) -TEST(AudioInputTest, MAYBE_Record) { +TEST(AudioInputTest, Record) { scoped_ptr<AudioManager> audio_man(AudioManager::Create()); if (!CanRunAudioTests(audio_man.get())) return; diff --git a/media/audio/linux/audio_manager_linux.cc b/media/audio/linux/audio_manager_linux.cc index e8f84fdd..48be0b7 100644 --- a/media/audio/linux/audio_manager_linux.cc +++ b/media/audio/linux/audio_manager_linux.cc @@ -127,20 +127,22 @@ void AudioManagerLinux::GetCrasAudioInputDevices( void AudioManagerLinux::GetAlsaAudioInputDevices( media::AudioDeviceNames* device_names) { // Constants specified by the ALSA API for device hints. - static const int kGetAllDevices = -1; static const char kPcmInterfaceName[] = "pcm"; - - void** hints = NULL; - int error = - wrapper_->DeviceNameHint(kGetAllDevices, kPcmInterfaceName, &hints); - if (!error) { - GetAlsaDevicesInfo(hints, device_names); - - // Destroy the hints now that we're done with it. - wrapper_->DeviceNameFreeHint(hints); - } else { - DLOG(WARNING) << "GetAudioInputDevices: unable to get device hints: " - << wrapper_->StrError(error); + int card = -1; + + // Loop through the sound cards to get ALSA device hints. + while (!wrapper_->CardNext(&card) && card >= 0) { + void** hints = NULL; + int error = wrapper_->DeviceNameHint(card, kPcmInterfaceName, &hints); + if (!error) { + GetAlsaDevicesInfo(hints, device_names); + + // Destroy the hints now that we're done with it. + wrapper_->DeviceNameFreeHint(hints); + } else { + DLOG(WARNING) << "GetAudioInputDevices: unable to get device hints: " + << wrapper_->StrError(error); + } } } @@ -216,37 +218,40 @@ bool AudioManagerLinux::IsAlsaDeviceAvailable(const char* device_name) { } bool AudioManagerLinux::HasAnyAlsaAudioDevice(StreamType stream) { - // Constants specified by the ALSA API for device hints. - static const int kGetAllDevices = -1; static const char kPcmInterfaceName[] = "pcm"; static const char kIoHintName[] = "IOID"; const char* kNotWantedDevice = (stream == kStreamPlayback ? "Input" : "Output"); void** hints = NULL; bool has_device = false; + int card = -1; + + // Loop through the sound cards. + // Don't use snd_device_name_hint(-1,..) since there is a access violation + // inside this ALSA API with libasound.so.2.0.0. + while (!wrapper_->CardNext(&card) && (card >= 0) && !has_device) { + int error = wrapper_->DeviceNameHint(card, kPcmInterfaceName, &hints); + if (!error) { + for (void** hint_iter = hints; *hint_iter != NULL; hint_iter++) { + // Only examine devices that are |stream| capable. Valid values are + // "Input", "Output", and NULL which means both input and output. + scoped_ptr_malloc<char> io(wrapper_->DeviceNameGetHint(*hint_iter, + kIoHintName)); + if (io != NULL && strcmp(kNotWantedDevice, io.get()) == 0) + continue; // Wrong type, skip the device. + + // Found an input device. + has_device = true; + break; + } - int error = - wrapper_->DeviceNameHint(kGetAllDevices, kPcmInterfaceName, &hints); - if (!error) { - for (void** hint_iter = hints; *hint_iter != NULL; hint_iter++) { - // Only examine devices that are |stream| capable. Valid values are - // "Input", "Output", and NULL which means both input and output. - scoped_ptr_malloc<char> io(wrapper_->DeviceNameGetHint(*hint_iter, - kIoHintName)); - if (io != NULL && strcmp(kNotWantedDevice, io.get()) == 0) - continue; // Wrong type, skip the device. - - // Found an input device. - has_device = true; - break; + // Destroy the hints now that we're done with it. + wrapper_->DeviceNameFreeHint(hints); + hints = NULL; + } else { + DLOG(WARNING) << "HasAnyAudioDevice: unable to get device hints: " + << wrapper_->StrError(error); } - - // Destroy the hints now that we're done with it. - wrapper_->DeviceNameFreeHint(hints); - hints = NULL; - } else { - DLOG(WARNING) << "HasAnyAudioDevice: unable to get device hints: " - << wrapper_->StrError(error); } return has_device; |