diff options
author | rene <rene@FreeBSD.org> | 2013-02-16 18:08:54 +0800 |
---|---|---|
committer | rene <rene@FreeBSD.org> | 2013-02-16 18:08:54 +0800 |
commit | d6b1f43de39f545c594d48c1bfa5d1049edf4f43 (patch) | |
tree | 14ddee4beac804f8dbfed7e3ef5fe22a19249125 /www/chromium/files | |
parent | e9c241ce269860445a0031e21d6eb3d540304b22 (diff) | |
download | freebsd-ports-gnome-d6b1f43de39f545c594d48c1bfa5d1049edf4f43.tar.gz freebsd-ports-gnome-d6b1f43de39f545c594d48c1bfa5d1049edf4f43.tar.zst freebsd-ports-gnome-d6b1f43de39f545c594d48c1bfa5d1049edf4f43.zip |
Unbreak audio : Let ALSA enumerate audio devices rather than iterating
over physical devices.
Bump PORTREVISION
Submitted by: George Liaskos
Obtained from: http://crrev.com/11533016
Diffstat (limited to 'www/chromium/files')
-rw-r--r-- | www/chromium/files/patch-media__audio__linux__audio_manager_linux.cc | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/www/chromium/files/patch-media__audio__linux__audio_manager_linux.cc b/www/chromium/files/patch-media__audio__linux__audio_manager_linux.cc new file mode 100644 index 000000000000..294029875f95 --- /dev/null +++ b/www/chromium/files/patch-media__audio__linux__audio_manager_linux.cc @@ -0,0 +1,110 @@ +--- media/audio/linux/audio_manager_linux.cc.orig 2013-02-04 04:01:12.000000000 +0200 ++++ media/audio/linux/audio_manager_linux.cc 2013-02-16 01:04:00.975548702 +0200 +@@ -126,22 +126,20 @@ + 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"; +- 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); +- } ++ 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); + } + } + +@@ -231,40 +229,47 @@ + } + + 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; +- } ++ // If checking for Input devices, only return true if there is an ++ // actual audio card. The bots have virtual audio input devices that do ++ // not actually generate samples, breaking some tests. ++ // See crbug.com/165401. ++ if (stream == kStreamCapture) { ++ int card = -1; ++ if (wrapper_->CardNext(&card) != 0 || card == -1) ++ return false; ++ } + +- // 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); ++ 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 a device of the |stream| type. ++ 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); + } + + return has_device; |