summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/cras_audio_client.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromeos/dbus/cras_audio_client.cc')
-rw-r--r--chromeos/dbus/cras_audio_client.cc145
1 files changed, 1 insertions, 144 deletions
diff --git a/chromeos/dbus/cras_audio_client.cc b/chromeos/dbus/cras_audio_client.cc
index 8919e52..411314e 100644
--- a/chromeos/dbus/cras_audio_client.cc
+++ b/chromeos/dbus/cras_audio_client.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/format_macros.h"
#include "base/strings/stringprintf.h"
+#include "chromeos/dbus/cras_audio_client_stub_impl.h"
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_path.h"
@@ -350,150 +351,6 @@ class CrasAudioClientImpl : public CrasAudioClient {
DISALLOW_COPY_AND_ASSIGN(CrasAudioClientImpl);
};
-// The CrasAudioClient implementation used on Linux desktop,
-// which does nothing.
-class CrasAudioClientStubImpl : public CrasAudioClient {
- public:
- CrasAudioClientStubImpl() {
- VLOG(1) << "CrasAudioClientStubImpl is created";
-
- // Fake audio output nodes.
- AudioNode node_1;
- node_1.is_input = false;
- node_1.id = 10001;
- node_1.device_name = "Fake Speaker";
- node_1.type = "INTERNAL_SPEAKER";
- node_1.name = "Speaker";
- node_1.active = false;
- node_list_.push_back(node_1);
-
- AudioNode node_2;
- node_2.is_input = false;
- node_2.id = 10002;
- node_2.device_name = "Fake Headphone";
- node_2.type = "HEADPHONE";
- node_2.name = "Headphone";
- node_2.active = true;
- node_list_.push_back(node_2);
- active_output_node_id_ = node_2.id;
-
- AudioNode node_3;
- node_3.is_input = false;
- node_3.id = 10003;
- node_3.device_name = "Fake Audio Output";
- node_3.type = "BLUETOOTH";
- node_3.name = "Bluetooth Headphone";
- node_3.active = false;
- node_list_.push_back(node_3);
-
- // Fake audio input ndoes
- AudioNode node_4;
- node_4.is_input = true;
- node_4.id = 10004;
- node_4.device_name = "Fake Internal Mic";
- node_4.type = "INTERNAL_MIC";
- node_4.name = "Internal Mic";
- node_4.active = false;
- node_list_.push_back(node_4);
-
- AudioNode node_5;
- node_5.is_input = true;
- node_5.id = 10005;
- node_5.device_name = "Fake Internal Mic";
- node_5.type = "USB";
- node_5.name = "USB Mic";
- node_5.active = true;
- node_list_.push_back(node_5);
- active_input_node_id_ = node_5.id;
- }
- virtual ~CrasAudioClientStubImpl() {
- }
-
- // CrasAudioClient overrides:
- // TODO(jennyz): Implement the observers and callbacks in the stub for UI
- // testing.
- virtual void AddObserver(Observer* observer) OVERRIDE {
- observers_.AddObserver(observer);
- }
-
- virtual void RemoveObserver(Observer* observer) OVERRIDE {
- observers_.RemoveObserver(observer);
- }
-
- virtual bool HasObserver(Observer* observer) OVERRIDE {
- return observers_.HasObserver(observer);
- }
-
- virtual void GetVolumeState(const GetVolumeStateCallback& callback) OVERRIDE {
- callback.Run(volume_state_, true);
- }
-
- virtual void GetNodes(const GetNodesCallback& callback)OVERRIDE {
- callback.Run(node_list_, true);
- }
-
- virtual void SetOutputNodeVolume(uint64 node_id, int32 volume) OVERRIDE {
- }
-
- virtual void SetOutputUserMute(bool mute_on) OVERRIDE {
- volume_state_.output_user_mute = mute_on;
- FOR_EACH_OBSERVER(Observer,
- observers_,
- OutputMuteChanged(volume_state_.output_user_mute));
- }
-
- virtual void SetInputNodeGain(uint64 node_id, int32 input_gain) OVERRIDE {
- }
-
- virtual void SetInputMute(bool mute_on) OVERRIDE {
- volume_state_.input_mute = mute_on;
- FOR_EACH_OBSERVER(Observer,
- observers_,
- InputMuteChanged(volume_state_.input_mute));
- }
-
- virtual void SetActiveOutputNode(uint64 node_id) OVERRIDE {
- if (active_output_node_id_ == node_id)
- return;
-
- for (size_t i = 0; i < node_list_.size(); ++i) {
- if (node_list_[i].id == active_output_node_id_)
- node_list_[i].active = false;
- else if (node_list_[i].id == node_id)
- node_list_[i].active = true;
- }
- active_output_node_id_ = node_id;
- FOR_EACH_OBSERVER(Observer,
- observers_,
- ActiveOutputNodeChanged(node_id));
- }
-
- virtual void SetActiveInputNode(uint64 node_id) OVERRIDE {
- if (active_input_node_id_ == node_id)
- return;
-
- for (size_t i = 0; i < node_list_.size(); ++i) {
- if (node_list_[i].id == active_input_node_id_)
- node_list_[i].active = false;
- else if (node_list_[i].id == node_id)
- node_list_[i].active = true;
- }
- active_input_node_id_ = node_id;
- FOR_EACH_OBSERVER(Observer,
- observers_,
- ActiveInputNodeChanged(node_id));
- }
-
- private:
- VolumeState volume_state_;
- AudioNodeList node_list_;
- uint64 active_input_node_id_;
- uint64 active_output_node_id_;
- ObserverList<Observer> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(CrasAudioClientStubImpl);
-};
-
CrasAudioClient::Observer::~Observer() {
}