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 "extensions/browser/api/audio/audio_service.h" | 5 #include "extensions/browser/api/audio/audio_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chromeos/audio/audio_device.h" | 10 #include "chromeos/audio/audio_device.h" |
11 #include "chromeos/audio/cras_audio_handler.h" | 11 #include "chromeos/audio/cras_audio_handler.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 | 13 |
14 using content::BrowserThread; | 14 using content::BrowserThread; |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 using core_api::audio::OutputDeviceInfo; | 18 using core_api::audio::OutputDeviceInfo; |
19 using core_api::audio::InputDeviceInfo; | 19 using core_api::audio::InputDeviceInfo; |
20 | 20 |
21 class AudioServiceImpl : public AudioService, | 21 class AudioServiceImpl : public AudioService, |
22 public chromeos::CrasAudioHandler::AudioObserver { | 22 public chromeos::CrasAudioHandler::AudioObserver { |
23 public: | 23 public: |
24 AudioServiceImpl(); | 24 AudioServiceImpl(); |
25 virtual ~AudioServiceImpl(); | 25 ~AudioServiceImpl() override; |
26 | 26 |
27 // Called by listeners to this service to add/remove themselves as observers. | 27 // Called by listeners to this service to add/remove themselves as observers. |
28 virtual void AddObserver(AudioService::Observer* observer) override; | 28 void AddObserver(AudioService::Observer* observer) override; |
29 virtual void RemoveObserver(AudioService::Observer* observer) override; | 29 void RemoveObserver(AudioService::Observer* observer) override; |
30 | 30 |
31 // Start to query audio device information. | 31 // Start to query audio device information. |
32 virtual void StartGetInfo(const GetInfoCallback& callback) override; | 32 void StartGetInfo(const GetInfoCallback& callback) override; |
33 virtual void SetActiveDevices(const DeviceIdList& device_list) override; | 33 void SetActiveDevices(const DeviceIdList& device_list) override; |
34 virtual bool SetDeviceProperties(const std::string& device_id, | 34 bool SetDeviceProperties(const std::string& device_id, |
35 bool muted, | 35 bool muted, |
36 int volume, | 36 int volume, |
37 int gain) override; | 37 int gain) override; |
38 | 38 |
39 protected: | 39 protected: |
40 // chromeos::CrasAudioHandler::AudioObserver overrides. | 40 // chromeos::CrasAudioHandler::AudioObserver overrides. |
41 virtual void OnOutputVolumeChanged() override; | 41 void OnOutputVolumeChanged() override; |
42 virtual void OnInputGainChanged() override; | 42 void OnInputGainChanged() override; |
43 virtual void OnOutputMuteChanged() override; | 43 void OnOutputMuteChanged() override; |
44 virtual void OnInputMuteChanged() override; | 44 void OnInputMuteChanged() override; |
45 virtual void OnAudioNodesChanged() override; | 45 void OnAudioNodesChanged() override; |
46 virtual void OnActiveOutputNodeChanged() override; | 46 void OnActiveOutputNodeChanged() override; |
47 virtual void OnActiveInputNodeChanged() override; | 47 void OnActiveInputNodeChanged() override; |
48 | 48 |
49 private: | 49 private: |
50 void NotifyDeviceChanged(); | 50 void NotifyDeviceChanged(); |
51 | 51 |
52 bool FindDevice(uint64 id, chromeos::AudioDevice* device); | 52 bool FindDevice(uint64 id, chromeos::AudioDevice* device); |
53 uint64 GetIdFromStr(const std::string& id_str); | 53 uint64 GetIdFromStr(const std::string& id_str); |
54 | 54 |
55 // List of observers. | 55 // List of observers. |
56 ObserverList<AudioService::Observer> observer_list_; | 56 ObserverList<AudioService::Observer> observer_list_; |
57 | 57 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 void AudioServiceImpl::NotifyDeviceChanged() { | 222 void AudioServiceImpl::NotifyDeviceChanged() { |
223 FOR_EACH_OBSERVER(AudioService::Observer, observer_list_, OnDeviceChanged()); | 223 FOR_EACH_OBSERVER(AudioService::Observer, observer_list_, OnDeviceChanged()); |
224 } | 224 } |
225 | 225 |
226 AudioService* AudioService::CreateInstance() { | 226 AudioService* AudioService::CreateInstance() { |
227 return new AudioServiceImpl; | 227 return new AudioServiceImpl; |
228 } | 228 } |
229 | 229 |
230 } // namespace extensions | 230 } // namespace extensions |
OLD | NEW |