OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ | 5 #ifndef MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ |
6 #define MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ | 6 #define MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ |
7 | 7 |
8 #include <windows.h> | |
9 #include <string> | 8 #include <string> |
10 | 9 |
11 #include "base/basictypes.h" | |
12 #include "base/compiler_specific.h" | |
13 #include "base/gtest_prod_util.h" | |
14 #include "media/audio/audio_manager_base.h" | 10 #include "media/audio/audio_manager_base.h" |
15 | 11 |
16 namespace media { | 12 namespace media { |
17 | 13 |
| 14 class AudioDeviceListenerWin; |
| 15 |
18 // Windows implementation of the AudioManager singleton. This class is internal | 16 // Windows implementation of the AudioManager singleton. This class is internal |
19 // to the audio output and only internal users can call methods not exposed by | 17 // to the audio output and only internal users can call methods not exposed by |
20 // the AudioManager class. | 18 // the AudioManager class. |
21 class MEDIA_EXPORT AudioManagerWin : public AudioManagerBase { | 19 class MEDIA_EXPORT AudioManagerWin : public AudioManagerBase { |
22 public: | 20 public: |
23 AudioManagerWin(); | 21 AudioManagerWin(); |
| 22 |
24 // Implementation of AudioManager. | 23 // Implementation of AudioManager. |
25 virtual bool HasAudioOutputDevices() OVERRIDE; | 24 virtual bool HasAudioOutputDevices() OVERRIDE; |
26 virtual bool HasAudioInputDevices() OVERRIDE; | 25 virtual bool HasAudioInputDevices() OVERRIDE; |
27 virtual string16 GetAudioInputDeviceModel() OVERRIDE; | 26 virtual string16 GetAudioInputDeviceModel() OVERRIDE; |
28 virtual bool CanShowAudioInputSettings() OVERRIDE; | 27 virtual bool CanShowAudioInputSettings() OVERRIDE; |
29 virtual void ShowAudioInputSettings() OVERRIDE; | 28 virtual void ShowAudioInputSettings() OVERRIDE; |
30 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) | 29 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) |
31 OVERRIDE; | 30 OVERRIDE; |
32 | 31 |
33 // Implementation of AudioManagerBase. | 32 // Implementation of AudioManagerBase. |
34 virtual AudioOutputStream* MakeLinearOutputStream( | 33 virtual AudioOutputStream* MakeLinearOutputStream( |
35 const AudioParameters& params) OVERRIDE; | 34 const AudioParameters& params) OVERRIDE; |
36 virtual AudioOutputStream* MakeLowLatencyOutputStream( | 35 virtual AudioOutputStream* MakeLowLatencyOutputStream( |
37 const AudioParameters& params) OVERRIDE; | 36 const AudioParameters& params) OVERRIDE; |
38 virtual AudioInputStream* MakeLinearInputStream( | 37 virtual AudioInputStream* MakeLinearInputStream( |
39 const AudioParameters& params, const std::string& device_id) OVERRIDE; | 38 const AudioParameters& params, const std::string& device_id) OVERRIDE; |
40 virtual AudioInputStream* MakeLowLatencyInputStream( | 39 virtual AudioInputStream* MakeLowLatencyInputStream( |
41 const AudioParameters& params, const std::string& device_id) OVERRIDE; | 40 const AudioParameters& params, const std::string& device_id) OVERRIDE; |
42 virtual AudioParameters GetPreferredLowLatencyOutputStreamParameters( | 41 virtual AudioParameters GetPreferredLowLatencyOutputStreamParameters( |
43 const AudioParameters& input_params) OVERRIDE; | 42 const AudioParameters& input_params) OVERRIDE; |
44 | 43 |
45 protected: | 44 protected: |
46 virtual ~AudioManagerWin(); | 45 virtual ~AudioManagerWin(); |
47 | 46 |
| 47 // Implementation of AudioManager. |
| 48 virtual void InitializeOnAudioThread() OVERRIDE; |
| 49 |
48 private: | 50 private: |
49 enum EnumerationType { | 51 enum EnumerationType { |
50 kUninitializedEnumeration = 0, | 52 kUninitializedEnumeration = 0, |
51 kMMDeviceEnumeration, | 53 kMMDeviceEnumeration, |
52 kWaveEnumeration, | 54 kWaveEnumeration, |
53 }; | 55 }; |
54 | 56 |
55 // Allow unit test to modify the utilized enumeration API. | 57 // Allow unit test to modify the utilized enumeration API. |
56 friend class AudioInputDeviceTest; | 58 friend class AudioInputDeviceTest; |
57 | 59 |
58 EnumerationType enumeration_type_; | 60 EnumerationType enumeration_type_; |
59 EnumerationType enumeration_type() { return enumeration_type_; } | 61 EnumerationType enumeration_type() { return enumeration_type_; } |
60 void SetEnumerationType(EnumerationType type) { | 62 void SetEnumerationType(EnumerationType type) { |
61 enumeration_type_ = type; | 63 enumeration_type_ = type; |
62 } | 64 } |
63 | 65 |
64 // Returns a PCMWaveInAudioInputStream instance or NULL on failure. | 66 // Returns a PCMWaveInAudioInputStream instance or NULL on failure. |
65 // This method converts MMDevice-style device ID to WaveIn-style device ID if | 67 // This method converts MMDevice-style device ID to WaveIn-style device ID if |
66 // necessary. | 68 // necessary. |
67 // (Please see device_enumeration_win.h for more info about the two kinds of | 69 // (Please see device_enumeration_win.h for more info about the two kinds of |
68 // device IDs.) | 70 // device IDs.) |
69 AudioInputStream* CreatePCMWaveInAudioInputStream( | 71 AudioInputStream* CreatePCMWaveInAudioInputStream( |
70 const AudioParameters& params, | 72 const AudioParameters& params, |
71 const std::string& device_id); | 73 const std::string& device_id); |
72 | 74 |
| 75 // |output_device_listener_| must be destructed on the same COM thread it was |
| 76 // initialized on. |
| 77 void DestructOnAudioThread(); |
| 78 |
| 79 // Listen for output device changes. |
| 80 scoped_ptr<AudioDeviceListenerWin> output_device_listener_; |
| 81 |
73 DISALLOW_COPY_AND_ASSIGN(AudioManagerWin); | 82 DISALLOW_COPY_AND_ASSIGN(AudioManagerWin); |
74 }; | 83 }; |
75 | 84 |
76 } // namespace media | 85 } // namespace media |
77 | 86 |
78 #endif // MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ | 87 #endif // MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_ |
OLD | NEW |