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

Unified Diff: chrome/browser/chromeos/audio_mixer_alsa.cc

Issue 6591095: Mute ALSA audio completely (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/chromeos
Patch Set: cleanup Created 9 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/audio_mixer_alsa.cc
diff --git a/chrome/browser/chromeos/audio_mixer_alsa.cc b/chrome/browser/chromeos/audio_mixer_alsa.cc
index 34fb722ab0e51b9ad098568e9949764a95a530d4..ca99065d4b093635bdd59826ab884a05eb3d59e6 100644
--- a/chrome/browser/chromeos/audio_mixer_alsa.cc
+++ b/chrome/browser/chromeos/audio_mixer_alsa.cc
@@ -175,8 +175,6 @@ void AudioMixerAlsa::SetMute(bool mute) {
}
SetElementMuted_Locked(elem_master_, mute);
- if (elem_pcm_)
- SetElementMuted_Locked(elem_pcm_, mute);
davejcool 2011/03/03 20:05:02 It turns out the PCM mixer element does have a mut
prefs_->SetInteger(prefs::kAudioMute, mute ? kPrefMuteOn : kPrefMuteOff);
}
@@ -246,6 +244,21 @@ bool AudioMixerAlsa::InitializeAlsaMixer() {
snd_mixer_t* handle = NULL;
const char* card = "default";
+ // Verify PCM can be opened, which also instantiates the PCM mixer element
+ // which is needed for finer volume control and for muting by setting to zero.
+ // If it fails, we can still try to use the mixer as best we can.
+ snd_pcm_t* pcm_out_handle;
+ if ((err = snd_pcm_open(&pcm_out_handle,
+ "default",
+ SND_PCM_STREAM_PLAYBACK,
+ 0)) >= 0) {
+ snd_pcm_close(pcm_out_handle);
+ }
+ else
+ {
+ LOG(WARNING) << "ALSA PCM open: " << snd_strerror(err);
+ }
+
if ((err = snd_mixer_open(&handle, 0)) < 0) {
LOG(ERROR) << "ALSA mixer " << card << " open error: " << snd_strerror(err);
return false;
@@ -348,8 +361,6 @@ void AudioMixerAlsa::DoSetVolumeMute(double pref_volume, int pref_mute) {
}
SetElementMuted_Locked(elem_master_, mute);
- if (elem_pcm_)
- SetElementMuted_Locked(elem_pcm_, mute);
}
void AudioMixerAlsa::RestoreVolumeMuteOnUIThread() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698