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

Side by Side Diff: chrome/browser/chromeos/audio/audio_mixer_cras.h

Issue 10873085: Implement two new policies to control muting the audio I/O. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_MIXER_CRAS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_MIXER_CRAS_H_
6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_MIXER_CRAS_H_ 6 #define CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_MIXER_CRAS_H_
7 7
8 #include <cras_client.h> 8 #include <cras_client.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 11 matching lines...) Expand all
22 class AudioMixerCras : public AudioMixer { 22 class AudioMixerCras : public AudioMixer {
23 public: 23 public:
24 AudioMixerCras(); 24 AudioMixerCras();
25 virtual ~AudioMixerCras(); 25 virtual ~AudioMixerCras();
26 26
27 // AudioMixer implementation. 27 // AudioMixer implementation.
28 virtual void Init() OVERRIDE; 28 virtual void Init() OVERRIDE;
29 virtual double GetVolumePercent() OVERRIDE; 29 virtual double GetVolumePercent() OVERRIDE;
30 virtual void SetVolumePercent(double percent) OVERRIDE; 30 virtual void SetVolumePercent(double percent) OVERRIDE;
31 virtual bool IsMuted() OVERRIDE; 31 virtual bool IsMuted() OVERRIDE;
32 virtual void SetMuted(bool muted) OVERRIDE; 32 virtual void SetMuted(bool mute) OVERRIDE;
33 virtual bool IsMuteLocked() OVERRIDE;
34 virtual void SetMuteLocked(bool locked) OVERRIDE;
35 virtual bool IsCaptureMuted() OVERRIDE;
36 virtual void SetCaptureMuted(bool mute) OVERRIDE;
37 virtual bool IsCaptureMuteLocked() OVERRIDE;
38 virtual void SetCaptureMuteLocked(bool locked) OVERRIDE;
33 39
34 private: 40 private:
35 // Tries to connect to CRAS. On failure, posts a delayed Connect() task to 41 // Tries to connect to CRAS. On failure, posts a delayed Connect() task to
36 // try again. Failure could occur if the CRAS server isn't running yet. 42 // try again. Failure could occur if the CRAS server isn't running yet.
37 void Connect(); 43 void Connect();
38 44
39 // Updates |client_| for current values of |volume_percent_| and 45 // Updates |client_| for current values of |volume_percent_| and
40 // |is_muted_|. No-op if not connected. 46 // |is_muted_|. No-op if not connected.
41 void ApplyState(); 47 void ApplyState();
42 48
49 // Calls ApplyState on the proper thread only if no other call is currently
50 // pending.
51 void ApplyStateIfNeeded();
52
43 // Interfaces to the audio server. 53 // Interfaces to the audio server.
44 struct cras_client *client_; 54 struct cras_client *client_;
45 55
46 // Indicates if we have connected |client_| to the server. 56 // Indicates if we have connected |client_| to the server.
47 bool client_connected_; 57 bool client_connected_;
48 58
49 // Most recently-requested volume, in percent. This variable is updated 59 // Most recently-requested volume, in percent. This variable is updated
50 // immediately by SetVolumePercent() (post-initialization); the actual mixer 60 // immediately by SetVolumePercent() (post-initialization); the actual mixer
51 // volume is updated later on |thread_| by ApplyState(). 61 // volume is updated later on |thread_| by ApplyState().
52 double volume_percent_; 62 double volume_percent_;
53 63
54 // Most recently-requested muting state. 64 // Most recently-requested muting state.
55 bool is_muted_; 65 bool is_muted_;
66 bool is_mute_locked_;
67 bool is_capture_muted_;
68 bool is_capture_mute_locked_;
56 69
57 // Is there already a pending call to ApplyState() scheduled on |thread_|? 70 // Is there already a pending call to ApplyState() scheduled on |thread_|?
58 bool apply_is_pending_; 71 bool apply_is_pending_;
59 72
60 // Background thread used for interacting with CRAS. 73 // Background thread used for interacting with CRAS.
61 scoped_ptr<base::Thread> thread_; 74 scoped_ptr<base::Thread> thread_;
62 75
63 // Guards |volume_percent_|, |is_muted_|, and |apply_is_pending_|. 76 // Guards |volume_percent_|, |is_muted_|, |is_mute_locked_|,
77 // |is_capture_muted_|, |is_capture_mute_locked_|, and |apply_is_pending_|.
64 base::Lock lock_; 78 base::Lock lock_;
65 79
66 DISALLOW_COPY_AND_ASSIGN(AudioMixerCras); 80 DISALLOW_COPY_AND_ASSIGN(AudioMixerCras);
67 }; 81 };
68 82
69 } // namespace chromeos 83 } // namespace chromeos
70 84
71 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_MIXER_CRAS_H_ 85 #endif // CHROME_BROWSER_CHROMEOS_AUDIO_AUDIO_MIXER_CRAS_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/audio/audio_mixer_alsa.cc ('k') | chrome/browser/chromeos/audio/audio_mixer_cras.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698