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