| 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/audio/cras_audio_handler.h" | 5 #include "chromeos/audio/cras_audio_handler.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 void OnActiveInputNodeChanged() override { | 252 void OnActiveInputNodeChanged() override { |
| 253 ++active_input_node_changed_count_; | 253 ++active_input_node_changed_count_; |
| 254 } | 254 } |
| 255 | 255 |
| 256 void OnAudioNodesChanged() override { ++audio_nodes_changed_count_; } | 256 void OnAudioNodesChanged() override { ++audio_nodes_changed_count_; } |
| 257 | 257 |
| 258 void OnOutputMuteChanged() override { ++output_mute_changed_count_; } | 258 void OnOutputMuteChanged() override { ++output_mute_changed_count_; } |
| 259 | 259 |
| 260 void OnInputMuteChanged() override { ++input_mute_changed_count_; } | 260 void OnInputMuteChanged() override { ++input_mute_changed_count_; } |
| 261 | 261 |
| 262 void OnOutputVolumeChanged() override { ++output_volume_changed_count_; } | 262 void OnOutputNodeVolumeChanged(uint64 node_id, double volume) override { |
| 263 ++output_volume_changed_count_; |
| 264 } |
| 263 | 265 |
| 264 void OnInputGainChanged() override { ++input_gain_changed_count_; } | 266 void OnInputGainChanged() override { ++input_gain_changed_count_; } |
| 265 | 267 |
| 266 private: | 268 private: |
| 267 int active_output_node_changed_count_; | 269 int active_output_node_changed_count_; |
| 268 int active_input_node_changed_count_; | 270 int active_input_node_changed_count_; |
| 269 int audio_nodes_changed_count_; | 271 int audio_nodes_changed_count_; |
| 270 int output_mute_changed_count_; | 272 int output_mute_changed_count_; |
| 271 int input_mute_changed_count_; | 273 int input_mute_changed_count_; |
| 272 int output_volume_changed_count_; | 274 int output_volume_changed_count_; |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 | 1806 |
| 1805 TEST_F(CrasAudioHandlerTest, SetOutputVolumePercent) { | 1807 TEST_F(CrasAudioHandlerTest, SetOutputVolumePercent) { |
| 1806 AudioNodeList audio_nodes; | 1808 AudioNodeList audio_nodes; |
| 1807 audio_nodes.push_back(kInternalSpeaker); | 1809 audio_nodes.push_back(kInternalSpeaker); |
| 1808 SetUpCrasAudioHandler(audio_nodes); | 1810 SetUpCrasAudioHandler(audio_nodes); |
| 1809 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); | 1811 EXPECT_EQ(0, test_observer_->output_volume_changed_count()); |
| 1810 | 1812 |
| 1811 cras_audio_handler_->SetOutputVolumePercent(60); | 1813 cras_audio_handler_->SetOutputVolumePercent(60); |
| 1812 | 1814 |
| 1813 // Verify the output volume is changed to the designated value, | 1815 // Verify the output volume is changed to the designated value, |
| 1814 // OnOutputVolumeChanged event is fired, and the device volume value | 1816 // OnOutputNodeVolumeChanged event is fired, and the device volume value |
| 1815 // is saved the preferences. | 1817 // is saved the preferences. |
| 1816 const int kVolume = 60; | 1818 const int kVolume = 60; |
| 1817 EXPECT_EQ(kVolume, cras_audio_handler_->GetOutputVolumePercent()); | 1819 EXPECT_EQ(kVolume, cras_audio_handler_->GetOutputVolumePercent()); |
| 1818 EXPECT_EQ(1, test_observer_->output_volume_changed_count()); | 1820 EXPECT_EQ(1, test_observer_->output_volume_changed_count()); |
| 1819 AudioDevice device; | 1821 AudioDevice device; |
| 1820 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); | 1822 EXPECT_TRUE(cras_audio_handler_->GetPrimaryActiveOutputDevice(&device)); |
| 1821 EXPECT_EQ(device.id, kInternalSpeaker.id); | 1823 EXPECT_EQ(device.id, kInternalSpeaker.id); |
| 1822 EXPECT_EQ(kVolume, audio_pref_handler_->GetOutputVolumeValue(&device)); | 1824 EXPECT_EQ(kVolume, audio_pref_handler_->GetOutputVolumeValue(&device)); |
| 1823 } | 1825 } |
| 1824 | 1826 |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 hdmi.plugged_time = 90000000; | 2424 hdmi.plugged_time = 90000000; |
| 2423 audio_nodes.push_back(hdmi); | 2425 audio_nodes.push_back(hdmi); |
| 2424 ChangeAudioNodes(audio_nodes); | 2426 ChangeAudioNodes(audio_nodes); |
| 2425 | 2427 |
| 2426 // The active output should not change. | 2428 // The active output should not change. |
| 2427 EXPECT_EQ(kInternalSpeaker.id, | 2429 EXPECT_EQ(kInternalSpeaker.id, |
| 2428 cras_audio_handler_->GetPrimaryActiveOutputNode()); | 2430 cras_audio_handler_->GetPrimaryActiveOutputNode()); |
| 2429 } | 2431 } |
| 2430 | 2432 |
| 2431 } // namespace chromeos | 2433 } // namespace chromeos |
| OLD | NEW |