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 #include "chromeos/dbus/cras_audio_client_stub_impl.h" | 5 #include "chromeos/dbus/cras_audio_client_stub_impl.h" |
6 | 6 |
7 namespace chromeos { | 7 namespace chromeos { |
8 | 8 |
9 CrasAudioClientStubImpl::CrasAudioClientStubImpl() | 9 CrasAudioClientStubImpl::CrasAudioClientStubImpl() |
10 : active_input_node_id_(0), | 10 : active_input_node_id_(0), |
11 active_output_node_id_(0) { | 11 active_output_node_id_(0) { |
12 } | 12 } |
13 | 13 |
| 14 CrasAudioClientStubImpl::~CrasAudioClientStubImpl() { |
| 15 } |
| 16 |
14 void CrasAudioClientStubImpl::Init(dbus::Bus* bus) { | 17 void CrasAudioClientStubImpl::Init(dbus::Bus* bus) { |
15 VLOG(1) << "CrasAudioClientStubImpl is created"; | 18 VLOG(1) << "CrasAudioClientStubImpl is created"; |
16 | 19 |
17 // Fake audio output nodes. | 20 // Fake audio output nodes. |
18 AudioNode node_1; | 21 AudioNode node_1; |
19 node_1.is_input = false; | 22 node_1.is_input = false; |
20 node_1.id = 10001; | 23 node_1.id = 10001; |
21 node_1.device_name = "Fake Speaker"; | 24 node_1.device_name = "Fake Speaker"; |
22 node_1.type = "INTERNAL_SPEAKER"; | 25 node_1.type = "INTERNAL_SPEAKER"; |
23 node_1.name = "Speaker"; | 26 node_1.name = "Speaker"; |
(...skipping 26 matching lines...) Expand all Loading... |
50 | 53 |
51 AudioNode node_5; | 54 AudioNode node_5; |
52 node_5.is_input = true; | 55 node_5.is_input = true; |
53 node_5.id = 10005; | 56 node_5.id = 10005; |
54 node_5.device_name = "Fake USB Mic"; | 57 node_5.device_name = "Fake USB Mic"; |
55 node_5.type = "USB"; | 58 node_5.type = "USB"; |
56 node_5.name = "Mic"; | 59 node_5.name = "Mic"; |
57 node_list_.push_back(node_5); | 60 node_list_.push_back(node_5); |
58 } | 61 } |
59 | 62 |
60 CrasAudioClientStubImpl::~CrasAudioClientStubImpl() { | |
61 } | |
62 | |
63 void CrasAudioClientStubImpl::AddObserver(Observer* observer) { | 63 void CrasAudioClientStubImpl::AddObserver(Observer* observer) { |
64 observers_.AddObserver(observer); | 64 observers_.AddObserver(observer); |
65 } | 65 } |
66 | 66 |
67 void CrasAudioClientStubImpl::RemoveObserver(Observer* observer) { | 67 void CrasAudioClientStubImpl::RemoveObserver(Observer* observer) { |
68 observers_.RemoveObserver(observer); | 68 observers_.RemoveObserver(observer); |
69 } | 69 } |
70 | 70 |
71 bool CrasAudioClientStubImpl::HasObserver(Observer* observer) { | 71 bool CrasAudioClientStubImpl::HasObserver(Observer* observer) { |
72 return observers_.HasObserver(observer); | 72 return observers_.HasObserver(observer); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 157 } |
158 } | 158 } |
159 | 159 |
160 void CrasAudioClientStubImpl::RemoveActiveOutputNode(uint64 node_id) { | 160 void CrasAudioClientStubImpl::RemoveActiveOutputNode(uint64 node_id) { |
161 for (size_t i = 0; i < node_list_.size(); ++i) { | 161 for (size_t i = 0; i < node_list_.size(); ++i) { |
162 if (node_list_[i].id == node_id) | 162 if (node_list_[i].id == node_id) |
163 node_list_[i].active = false; | 163 node_list_[i].active = false; |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void CrasAudioClientStubImpl::SetAudioDevices( | 167 void CrasAudioClientStubImpl::SetAudioNodesForTesting( |
168 const AudioNodeList& audio_nodes) { | 168 const AudioNodeList& audio_nodes) { |
169 node_list_.clear(); | 169 node_list_ = audio_nodes; |
170 for (size_t i = 0; i < audio_nodes.size(); ++i) | |
171 node_list_.push_back(audio_nodes[i]); | |
172 } | 170 } |
173 | 171 |
174 void CrasAudioClientStubImpl::ChangeAudioNodes(const AudioNodeList& new_nodes) { | 172 void CrasAudioClientStubImpl::SetAudioNodesAndNotifyObserversForTesting( |
175 SetAudioDevices(new_nodes); | 173 const AudioNodeList& new_nodes) { |
| 174 SetAudioNodesForTesting(new_nodes); |
176 FOR_EACH_OBSERVER(Observer, observers_, NodesChanged()); | 175 FOR_EACH_OBSERVER(Observer, observers_, NodesChanged()); |
177 } | 176 } |
178 | 177 |
179 } // namespace chromeos | 178 } // namespace chromeos |
OLD | NEW |