OLD | NEW |
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_DBUS_CRAS_AUDIO_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_ |
6 #define CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_ | 6 #define CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
9 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
10 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
11 #include "chromeos/dbus/audio_node.h" | 14 #include "chromeos/dbus/audio_node.h" |
12 #include "chromeos/dbus/dbus_client.h" | 15 #include "chromeos/dbus/dbus_client.h" |
13 #include "chromeos/dbus/volume_state.h" | 16 #include "chromeos/dbus/volume_state.h" |
14 | 17 |
15 namespace chromeos { | 18 namespace chromeos { |
16 | 19 |
17 // CrasAudioClient is used to communicate with the cras audio dbus interface. | 20 // CrasAudioClient is used to communicate with the cras audio dbus interface. |
18 class CHROMEOS_EXPORT CrasAudioClient : public DBusClient { | 21 class CHROMEOS_EXPORT CrasAudioClient : public DBusClient { |
19 public: | 22 public: |
20 // Interface for observing changes from the cras audio changes. | 23 // Interface for observing changes from the cras audio changes. |
21 class Observer { | 24 class Observer { |
22 public: | 25 public: |
23 // Called when cras audio client starts or re-starts, which happens when | 26 // Called when cras audio client starts or re-starts, which happens when |
24 // cros device powers up or restarted. | 27 // cros device powers up or restarted. |
25 virtual void AudioClientRestarted(); | 28 virtual void AudioClientRestarted(); |
26 | 29 |
27 // Called when audio output mute state changed to new state of |mute_on|. | 30 // Called when audio output mute state changed to new state of |mute_on|. |
28 virtual void OutputMuteChanged(bool mute_on); | 31 virtual void OutputMuteChanged(bool mute_on); |
29 | 32 |
30 // Called when audio input mute state changed to new state of |mute_on|. | 33 // Called when audio input mute state changed to new state of |mute_on|. |
31 virtual void InputMuteChanged(bool mute_on); | 34 virtual void InputMuteChanged(bool mute_on); |
32 | 35 |
33 // Called when audio nodes change. | 36 // Called when audio nodes change. |
34 virtual void NodesChanged(); | 37 virtual void NodesChanged(); |
35 | 38 |
36 // Called when active audio output node changed to new node with |node_id|. | 39 // Called when active audio output node changed to new node with |node_id|. |
37 virtual void ActiveOutputNodeChanged(uint64 node_id); | 40 virtual void ActiveOutputNodeChanged(uint64_t node_id); |
38 | 41 |
39 // Called when active audio input node changed to new node with |node_id|. | 42 // Called when active audio input node changed to new node with |node_id|. |
40 virtual void ActiveInputNodeChanged(uint64 node_id); | 43 virtual void ActiveInputNodeChanged(uint64_t node_id); |
41 | 44 |
42 protected: | 45 protected: |
43 virtual ~Observer(); | 46 virtual ~Observer(); |
44 }; | 47 }; |
45 | 48 |
46 ~CrasAudioClient() override; | 49 ~CrasAudioClient() override; |
47 | 50 |
48 // Adds and removes the observer. | 51 // Adds and removes the observer. |
49 virtual void AddObserver(Observer* observer) = 0; | 52 virtual void AddObserver(Observer* observer) = 0; |
50 virtual void RemoveObserver(Observer* observer) = 0; | 53 virtual void RemoveObserver(Observer* observer) = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
70 | 73 |
71 // Gets the volume state, asynchronously. | 74 // Gets the volume state, asynchronously. |
72 virtual void GetVolumeState(const GetVolumeStateCallback& callback) = 0; | 75 virtual void GetVolumeState(const GetVolumeStateCallback& callback) = 0; |
73 | 76 |
74 // Gets an array of audio input and output nodes. | 77 // Gets an array of audio input and output nodes. |
75 virtual void GetNodes(const GetNodesCallback& callback, | 78 virtual void GetNodes(const GetNodesCallback& callback, |
76 const ErrorCallback& error_callback) = 0; | 79 const ErrorCallback& error_callback) = 0; |
77 | 80 |
78 // Sets output volume of the given |node_id| to |volume|, in the rage of | 81 // Sets output volume of the given |node_id| to |volume|, in the rage of |
79 // [0, 100]. | 82 // [0, 100]. |
80 virtual void SetOutputNodeVolume(uint64 node_id, int32 volume) = 0; | 83 virtual void SetOutputNodeVolume(uint64_t node_id, int32_t volume) = 0; |
81 | 84 |
82 // Sets output mute from user action. | 85 // Sets output mute from user action. |
83 virtual void SetOutputUserMute(bool mute_on) = 0; | 86 virtual void SetOutputUserMute(bool mute_on) = 0; |
84 | 87 |
85 // Sets input gain of the given |node_id| to |gain|, in the range of | 88 // Sets input gain of the given |node_id| to |gain|, in the range of |
86 // [0, 100]. | 89 // [0, 100]. |
87 virtual void SetInputNodeGain(uint64 node_id, int32 gain) = 0; | 90 virtual void SetInputNodeGain(uint64_t node_id, int32_t gain) = 0; |
88 | 91 |
89 // Sets input mute state to |mute_on| value. | 92 // Sets input mute state to |mute_on| value. |
90 virtual void SetInputMute(bool mute_on) = 0; | 93 virtual void SetInputMute(bool mute_on) = 0; |
91 | 94 |
92 // Sets the active output node to |node_id|. | 95 // Sets the active output node to |node_id|. |
93 virtual void SetActiveOutputNode(uint64 node_id) = 0; | 96 virtual void SetActiveOutputNode(uint64_t node_id) = 0; |
94 | 97 |
95 // Sets the primary active input node to |node_id|. | 98 // Sets the primary active input node to |node_id|. |
96 virtual void SetActiveInputNode(uint64 node_id) = 0; | 99 virtual void SetActiveInputNode(uint64_t node_id) = 0; |
97 | 100 |
98 // Adds input node |node_id| to the active input list. This is used to add | 101 // Adds input node |node_id| to the active input list. This is used to add |
99 // an additional active input node besides the one set by SetActiveInputNode. | 102 // an additional active input node besides the one set by SetActiveInputNode. |
100 // Note that this action will not trigger an ActiveInputNodeChanged event and | 103 // Note that this action will not trigger an ActiveInputNodeChanged event and |
101 // nothing will happen if the |node_id| has already been set as active. | 104 // nothing will happen if the |node_id| has already been set as active. |
102 virtual void AddActiveInputNode(uint64 node_id) = 0; | 105 virtual void AddActiveInputNode(uint64_t node_id) = 0; |
103 | 106 |
104 // Removes input node |node_id| from the active input list. This is used for | 107 // Removes input node |node_id| from the active input list. This is used for |
105 // removing an active input node added by AddActiveInputNode. | 108 // removing an active input node added by AddActiveInputNode. |
106 virtual void RemoveActiveInputNode(uint64 node_id) = 0; | 109 virtual void RemoveActiveInputNode(uint64_t node_id) = 0; |
107 | 110 |
108 // Adds input node |node_id| to the active outputs list. This is used to add | 111 // Adds input node |node_id| to the active outputs list. This is used to add |
109 // an additional active output node besides the one set by SetActiveInputNode. | 112 // an additional active output node besides the one set by SetActiveInputNode. |
110 // Note that this action will not trigger an ActiveOutputNodeChanged event | 113 // Note that this action will not trigger an ActiveOutputNodeChanged event |
111 // and nothing will happen if the |node_id| has already been set as active. | 114 // and nothing will happen if the |node_id| has already been set as active. |
112 virtual void AddActiveOutputNode(uint64 node_id) = 0; | 115 virtual void AddActiveOutputNode(uint64_t node_id) = 0; |
113 | 116 |
114 // Removes output node |node_id| from the active output list. This is used for | 117 // Removes output node |node_id| from the active output list. This is used for |
115 // removing an active output node added by AddActiveOutputNode. | 118 // removing an active output node added by AddActiveOutputNode. |
116 virtual void RemoveActiveOutputNode(uint64 node_id) = 0; | 119 virtual void RemoveActiveOutputNode(uint64_t node_id) = 0; |
117 | 120 |
118 // Swaps the left and right channel of the primary active output device. | 121 // Swaps the left and right channel of the primary active output device. |
119 // Swap the left and right channel if |swap| is true; otherwise, swap the left | 122 // Swap the left and right channel if |swap| is true; otherwise, swap the left |
120 // and right channel back to the normal mode. | 123 // and right channel back to the normal mode. |
121 // The dbus message will be dropped if this feature is not supported on the | 124 // The dbus message will be dropped if this feature is not supported on the |
122 // |node_id|. | 125 // |node_id|. |
123 virtual void SwapLeftRight(uint64 node_id, bool swap) = 0; | 126 virtual void SwapLeftRight(uint64_t node_id, bool swap) = 0; |
124 | 127 |
125 // Creates the instance. | 128 // Creates the instance. |
126 static CrasAudioClient* Create(); | 129 static CrasAudioClient* Create(); |
127 | 130 |
128 protected: | 131 protected: |
129 // Create() should be used instead. | 132 // Create() should be used instead. |
130 CrasAudioClient(); | 133 CrasAudioClient(); |
131 | 134 |
132 private: | 135 private: |
133 DISALLOW_COPY_AND_ASSIGN(CrasAudioClient); | 136 DISALLOW_COPY_AND_ASSIGN(CrasAudioClient); |
134 }; | 137 }; |
135 | 138 |
136 } // namespace chromeos | 139 } // namespace chromeos |
137 | 140 |
138 #endif // CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_ | 141 #endif // CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_ |
OLD | NEW |