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

Side by Side Diff: chromeos/audio/cras_audio_handler.h

Issue 14678004: cros: Enable new cras audio handler by default (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ 5 #ifndef CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_
6 #define CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ 6 #define CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 protected: 48 protected:
49 AudioObserver(); 49 AudioObserver();
50 virtual ~AudioObserver(); 50 virtual ~AudioObserver();
51 DISALLOW_COPY_AND_ASSIGN(AudioObserver); 51 DISALLOW_COPY_AND_ASSIGN(AudioObserver);
52 }; 52 };
53 53
54 // Sets the global instance. Must be called before any calls to Get(). 54 // Sets the global instance. Must be called before any calls to Get().
55 static void Initialize(scoped_refptr<AudioPrefHandler> audio_pref_handler); 55 static void Initialize(scoped_refptr<AudioPrefHandler> audio_pref_handler);
56 56
57 // Sets the global instance for testing.
58 static void InitializeForTesting();
59
57 // Destroys the global instance. 60 // Destroys the global instance.
58 static void Shutdown(); 61 static void Shutdown();
59 62
60 // Returns true if the global instance is initialized. 63 // Returns true if the global instance is initialized.
61 static bool IsInitialized(); 64 static bool IsInitialized();
62 65
63 // Gets the global instance. Initialize must be called first. 66 // Gets the global instance. Initialize must be called first.
64 static CrasAudioHandler* Get(); 67 static CrasAudioHandler* Get();
65 68
66 // Adds an audio observer. 69 // Adds an audio observer.
67 void AddAudioObserver(AudioObserver* observer); 70 virtual void AddAudioObserver(AudioObserver* observer);
68 71
69 // Removes an audio observer. 72 // Removes an audio observer.
70 void RemoveAudioObserver(AudioObserver* observer); 73 virtual void RemoveAudioObserver(AudioObserver* observer);
71 74
72 // Returns true if audio output is muted. 75 // Returns true if audio output is muted.
73 bool IsOutputMuted(); 76 virtual bool IsOutputMuted();
74 77
75 // Returns true if audio input is muted. 78 // Returns true if audio input is muted.
76 bool IsInputMuted(); 79 virtual bool IsInputMuted();
77 80
78 // Gets volume level in 0-100% range, 0 being pure silence. 81 // Gets volume level in 0-100% range, 0 being pure silence.
79 int GetOutputVolumePercent(); 82 virtual int GetOutputVolumePercent();
80 83
81 // Returns node_id of the active output node. 84 // Returns node_id of the active output node.
82 uint64 GetActiveOutputNode() const; 85 virtual uint64 GetActiveOutputNode() const;
83 86
84 // Returns the node_id of the active input node. 87 // Returns the node_id of the active input node.
85 uint64 GetActiveInputNode() const; 88 virtual uint64 GetActiveInputNode() const;
86 89
87 // Gets the audio devices back in |device_list|. 90 // Gets the audio devices back in |device_list|.
88 void GetAudioDevices(AudioDeviceList* device_list) const; 91 virtual void GetAudioDevices(AudioDeviceList* device_list) const;
89 92
90 bool GetActiveOutputDevice(AudioDevice* device) const; 93 virtual bool GetActiveOutputDevice(AudioDevice* device) const;
91 94
92 // Whether there is alternative input/output audio device. 95 // Whether there is alternative input/output audio device.
93 bool has_alternative_input() const { return has_alternative_input_; } 96 virtual bool has_alternative_input() const { return has_alternative_input_; }
94 bool has_alternative_output() const { return has_alternative_output_; } 97 virtual bool has_alternative_output() const {
98 return has_alternative_output_;
99 }
95 100
96 // Sets volume level from 0-100%. If less than kMuteThresholdPercent, then 101 // Sets volume level from 0-100%. If less than kMuteThresholdPercent, then
97 // mutes the sound. If it was muted, and |volume_percent| is larger than 102 // mutes the sound. If it was muted, and |volume_percent| is larger than
98 // the threshold, then the sound is unmuted. 103 // the threshold, then the sound is unmuted.
99 void SetOutputVolumePercent(int volume_percent); 104 virtual void SetOutputVolumePercent(int volume_percent);
100 105
101 // Adjusts volume up (positive percentage) or down (negative percentage). 106 // Adjusts volume up (positive percentage) or down (negative percentage).
102 void AdjustOutputVolumeByPercent(int adjust_by_percent); 107 virtual void AdjustOutputVolumeByPercent(int adjust_by_percent);
103 108
104 // Mutes or unmutes audio output device. 109 // Mutes or unmutes audio output device.
105 void SetOutputMute(bool mute_on); 110 virtual void SetOutputMute(bool mute_on);
106 111
107 // Mutes or unmutes audio input device. 112 // Mutes or unmutes audio input device.
108 void SetInputMute(bool mute_on); 113 virtual void SetInputMute(bool mute_on);
109 114
110 // Sets the active audio output node to the node with |node_id|. 115 // Sets the active audio output node to the node with |node_id|.
111 void SetActiveOutputNode(uint64 node_id); 116 virtual void SetActiveOutputNode(uint64 node_id);
112 117
113 // Sets the active audio input node to the node with |node_id|. 118 // Sets the active audio input node to the node with |node_id|.
114 void SetActiveInputNode(uint64 node_id); 119 virtual void SetActiveInputNode(uint64 node_id);
115 120
116 private: 121 protected:
117 explicit CrasAudioHandler(scoped_refptr<AudioPrefHandler> audio_pref_handler); 122 explicit CrasAudioHandler(scoped_refptr<AudioPrefHandler> audio_pref_handler);
118 virtual ~CrasAudioHandler(); 123 virtual ~CrasAudioHandler();
119 124
125 // Only used for testing.
126 CrasAudioHandler();
127
128 private:
120 // Overriden from CrasAudioHandler::Observer. 129 // Overriden from CrasAudioHandler::Observer.
121 virtual void AudioClientRestarted() OVERRIDE; 130 virtual void AudioClientRestarted() OVERRIDE;
122 virtual void OutputVolumeChanged(int volume) OVERRIDE; 131 virtual void OutputVolumeChanged(int volume) OVERRIDE;
123 virtual void OutputMuteChanged(bool mute_on) OVERRIDE; 132 virtual void OutputMuteChanged(bool mute_on) OVERRIDE;
124 virtual void InputMuteChanged(bool mute_on) OVERRIDE; 133 virtual void InputMuteChanged(bool mute_on) OVERRIDE;
125 virtual void NodesChanged() OVERRIDE; 134 virtual void NodesChanged() OVERRIDE;
126 virtual void ActiveOutputNodeChanged(uint64 node_id) OVERRIDE; 135 virtual void ActiveOutputNodeChanged(uint64 node_id) OVERRIDE;
127 virtual void ActiveInputNodeChanged(uint64 node_id) OVERRIDE; 136 virtual void ActiveInputNodeChanged(uint64 node_id) OVERRIDE;
128 137
129 // Overriden from AudioPrefObserver. 138 // Overriden from AudioPrefObserver.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 172
164 bool output_mute_locked_; 173 bool output_mute_locked_;
165 bool input_mute_locked_; 174 bool input_mute_locked_;
166 175
167 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler); 176 DISALLOW_COPY_AND_ASSIGN(CrasAudioHandler);
168 }; 177 };
169 178
170 } // namespace chromeos 179 } // namespace chromeos
171 180
172 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_ 181 #endif // CHROMEOS_AUDIO_CRAS_AUDIO_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698