Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3654)

Unified Diff: media/audio/linux/audio_manager_linux.cc

Issue 7888011: There is a complain from Valgrind about invalid memory access in snd_device_name_hint(-1, ..) // ... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/linux/alsa_wrapper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/linux/audio_manager_linux.cc
===================================================================
--- media/audio/linux/audio_manager_linux.cc (revision 100401)
+++ media/audio/linux/audio_manager_linux.cc (working copy)
@@ -63,25 +63,29 @@
}
// Constants specified by the ALSA API for device hints.
- static const int kGetAllDevices = -1;
static const char kPcmInterfaceName[] = "pcm";
bool has_device = false;
void** hints = NULL;
+ int card = -1;
- // Use the same approach to find the devices as in
- // AlsaPcmOutputStream::FindDeviceForChannels
- // Get Alsa device hints.
- int error = wrapper_->DeviceNameHint(kGetAllDevices,
- kPcmInterfaceName,
- &hints);
- if (error == 0) {
- has_device = HasAnyValidAudioInputDevice(hints);
- } else {
- LOG(ERROR) << "Unable to get device hints: " << wrapper_->StrError(error);
+ // Loop through the sound cards to get Alsa device hints.
+ // Don't use snd_device_name_hint(-1,..) since there is a memory leak inside
Alexander Potapenko 2011/09/13 17:03:04 There is not a memory leak, but an access violatio
xians 2011/09/14 08:12:01 Done.
+ // 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 == 0) {
+ has_device = HasAnyValidAudioInputDevice(hints);
+
+ // Destroy the hints now that we're done with it.
+ wrapper_->DeviceNameFreeHint(hints);
+ hints = NULL;
+ } else {
+ LOG(ERROR) << "Unable to get device hints: " << wrapper_->StrError(error);
+ }
}
- // Destroy the hint now that we're done with it.
- wrapper_->DeviceNameFreeHint(hints);
Raymond Toy (Google) 2011/09/13 17:07:40 Won't there be a real leak now since you don't fre
xians 2011/09/14 08:12:01 In case DeviceNameHint fails, hints should be alwa
return has_device;
}
« no previous file with comments | « media/audio/linux/alsa_wrapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698