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

Side by Side 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: Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/audio_mixer_alsa.h" 5 #include "chrome/browser/chromeos/audio_mixer_alsa.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include <alsa/asoundlib.h> 9 #include <alsa/asoundlib.h>
10 10
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 bool AudioMixerAlsa::InitializeAlsaMixer() { 240 bool AudioMixerAlsa::InitializeAlsaMixer() {
241 base::AutoLock lock(mixer_state_lock_); 241 base::AutoLock lock(mixer_state_lock_);
242 if (mixer_state_ != INITIALIZING) 242 if (mixer_state_ != INITIALIZING)
243 return false; 243 return false;
244 244
245 int err; 245 int err;
246 snd_mixer_t* handle = NULL; 246 snd_mixer_t* handle = NULL;
247 const char* card = "default"; 247 const char* card = "default";
248 248
249 PingPCM();
scherkus (not reviewing) 2011/03/02 19:07:11 maybe inline this code considering it's not caleld
davejcool 2011/03/03 20:05:02 It is remarkably close to the other calls in Initi
250
249 if ((err = snd_mixer_open(&handle, 0)) < 0) { 251 if ((err = snd_mixer_open(&handle, 0)) < 0) {
250 LOG(ERROR) << "ALSA mixer " << card << " open error: " << snd_strerror(err); 252 LOG(ERROR) << "ALSA mixer " << card << " open error: " << snd_strerror(err);
251 return false; 253 return false;
252 } 254 }
253 255
254 if ((err = snd_mixer_attach(handle, card)) < 0) { 256 if ((err = snd_mixer_attach(handle, card)) < 0) {
255 LOG(ERROR) << "ALSA Attach to card " << card << " failed: " 257 LOG(ERROR) << "ALSA Attach to card " << card << " failed: "
256 << snd_strerror(err); 258 << snd_strerror(err);
257 snd_mixer_close(handle); 259 snd_mixer_close(handle);
258 return false; 260 return false;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 int alsa_result = snd_mixer_selem_set_playback_switch_all(elem, enabled); 514 int alsa_result = snd_mixer_selem_set_playback_switch_all(elem, enabled);
513 if (alsa_result != 0) { 515 if (alsa_result != 0) {
514 LOG(WARNING) << "snd_mixer_selem_set_playback_switch_all() failed: " 516 LOG(WARNING) << "snd_mixer_selem_set_playback_switch_all() failed: "
515 << snd_strerror(alsa_result); 517 << snd_strerror(alsa_result);
516 } else { 518 } else {
517 VLOG(1) << "Set playback switch " << snd_mixer_selem_get_name(elem) 519 VLOG(1) << "Set playback switch " << snd_mixer_selem_get_name(elem)
518 << " to " << enabled; 520 << " to " << enabled;
519 } 521 }
520 } 522 }
521 523
524 void AudioMixerAlsa::PingPCM() {
525 snd_pcm_t* pcm_out_handle;
526 int err;
527 if ((err = snd_pcm_open(&pcm_out_handle,
528 "default",
529 SND_PCM_STREAM_PLAYBACK,
530 0)) >= 0) {
531 snd_pcm_close(pcm_out_handle);
532 return;
533 }
534 LOG(ERROR) << "ALSA PCM open error: " << snd_strerror(err);
535 }
536
522 } // namespace chromeos 537 } // namespace chromeos
OLDNEW
« chrome/browser/chromeos/audio_mixer_alsa.h ('K') | « chrome/browser/chromeos/audio_mixer_alsa.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698