blob: 969bfb0b3d88f725702d5341448a3c5cc72d7038 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_
#define CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_
#include "base/callback.h"
#include "base/observer_list.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "chromeos/dbus/volume_state.h"
namespace dbus {
class Bus;
} // namespace
namespace chromeos {
// CrasAudioClient is used to communicate with the cras audio dbus interface.
class CHROMEOS_EXPORT CrasAudioClient {
public:
// Interface for observing changes from the cras audio changes.
class Observer {
public:
// Called when audio output device volume changed.
virtual void OutputVolumeChanged(int volume);
virtual void OutputMuteChanged(bool mute_on);
virtual void InputGainChanged(int gain);
virtual void InputMuteChanged(bool mute_on);
virtual void NodesChanged();
virtual void ActiveOutputNodeChanged(uint64 node_id);
virtual void ActiveInputNodeChanged(uint64 node_id);
protected:
virtual ~Observer();
};
virtual ~CrasAudioClient();
// Adds and removes the observer.
virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;
// Returns true if this object has the given observer.
virtual bool HasObserver(Observer* observer) = 0;
// GetVolumeStateCallback is used for GetVolumeState method. It receives
// 1 argument, |volume_state| which containing both input and output volume
// state data.
typedef base::Callback<void(const VolumeState&)> GetVolumeStateCallback;
// Gets the volume state, asynchronously.
virtual void GetVolumeState(const GetVolumeStateCallback& callback) = 0;
// Sets output volume to |volume|, in the range of [0, 100].
virtual void SetOutputVolume(int32 volume) = 0;
// Sets output mute state to |mute_on| value.
virtual void SetOutputMute(bool mute_on) = 0;
// Sets input gain to |input_gain|. |input_gain| is specified in dBFS * 100.
virtual void SetInputGain(int32 input_gain) = 0;
// Sets input mute state to |mute_on| value.
virtual void SetInputMute(bool mute_on) = 0;
// Sets the active output noe to |node_id|.
virtual void SetActiveOutputNode(uint64 node_id) = 0;
// Sets the active input noe to |node_id|.
virtual void SetActiveInputNode(uint64 node_id) = 0;
// Creates the instance.
static CrasAudioClient* Create(DBusClientImplementationType type,
dbus::Bus* bus);
protected:
// Create() should be used instead.
CrasAudioClient();
private:
DISALLOW_COPY_AND_ASSIGN(CrasAudioClient);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_CRAS_AUDIO_CLIENT_H_
|