Add layer tree settings flag for pinch virtual viewport.
[chromium-blink-merge.git] / chromeos / dbus / cras_audio_client.h
blob4ca0feab348542c288d12aefefe7288bfcd9d5ee
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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_
6 #define CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_
8 #include "base/callback.h"
9 #include "base/observer_list.h"
10 #include "chromeos/chromeos_export.h"
11 #include "chromeos/dbus/audio_node.h"
12 #include "chromeos/dbus/dbus_client_implementation_type.h"
13 #include "chromeos/dbus/volume_state.h"
15 namespace dbus {
16 class Bus;
17 } // namespace
19 namespace chromeos {
21 // CrasAudioClient is used to communicate with the cras audio dbus interface.
22 class CHROMEOS_EXPORT CrasAudioClient {
23 public:
24 // Interface for observing changes from the cras audio changes.
25 class Observer {
26 public:
27 // Called when cras audio client starts or re-starts, which happens when
28 // cros device powers up or restarted.
29 virtual void AudioClientRestarted();
31 // Called when audio output device volume changed to new value of |volume|.
32 virtual void OutputVolumeChanged(int volume);
34 // Called when audio output mute state changed to new state of |mute_on|.
35 virtual void OutputMuteChanged(bool mute_on);
37 // Called when audio input gain changes to new value of |gain|.
38 virtual void InputGainChanged(int gain);
40 // Called when audio input mute state changed to new state of |mute_on|.
41 virtual void InputMuteChanged(bool mute_on);
43 // Called when audio nodes change.
44 virtual void NodesChanged();
46 // Called when active audio output node changed to new node with |node_id|.
47 virtual void ActiveOutputNodeChanged(uint64 node_id);
49 // Called when active audio input node changed to new node with |node_id|.
50 virtual void ActiveInputNodeChanged(uint64 node_id);
52 protected:
53 virtual ~Observer();
56 virtual ~CrasAudioClient();
58 // Adds and removes the observer.
59 virtual void AddObserver(Observer* observer) = 0;
60 virtual void RemoveObserver(Observer* observer) = 0;
61 // Returns true if this object has the given observer.
62 virtual bool HasObserver(Observer* observer) = 0;
64 // GetVolumeStateCallback is used for GetVolumeState method. It receives
65 // 2 arguments, |volume_state| which containing both input and output volume
66 // state data, and |success| which indicates whether or not the request
67 // succeeded.
68 typedef base::Callback<void(const VolumeState&, bool)> GetVolumeStateCallback;
70 // GetNodesCallback is used for GetNodes method. It receives 2 arguments,
71 // |audio_nodes| which containing a list of audio nodes data and
72 // |success| which indicates whether or not the request succeeded.
73 typedef base::Callback<void(const AudioNodeList&, bool)> GetNodesCallback;
75 // Gets the volume state, asynchronously.
76 virtual void GetVolumeState(const GetVolumeStateCallback& callback) = 0;
78 // Gets an array of audio input and output nodes.
79 virtual void GetNodes(const GetNodesCallback& callback) = 0;
81 // Sets output volume to |volume|, in the range of [0, 100].
82 virtual void SetOutputVolume(int32 volume) = 0;
84 // Sets output mute state to |mute_on| value.
85 virtual void SetOutputMute(bool mute_on) = 0;
87 // Sets input gain to |input_gain|. |input_gain| is specified in dBFS * 100.
88 virtual void SetInputGain(int32 input_gain) = 0;
90 // Sets input mute state to |mute_on| value.
91 virtual void SetInputMute(bool mute_on) = 0;
93 // Sets the active output node to |node_id|.
94 virtual void SetActiveOutputNode(uint64 node_id) = 0;
96 // Sets the active input node to |node_id|.
97 virtual void SetActiveInputNode(uint64 node_id) = 0;
99 // Creates the instance.
100 static CrasAudioClient* Create(DBusClientImplementationType type,
101 dbus::Bus* bus);
103 protected:
104 // Create() should be used instead.
105 CrasAudioClient();
107 private:
109 DISALLOW_COPY_AND_ASSIGN(CrasAudioClient);
112 } // namespace chromeos
114 #endif // CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_