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
3 // found in the LICENSE file.
5 #ifndef MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_
6 #define MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_
10 #include "media/audio/audio_manager_base.h"
14 class AudioDeviceListenerWin
;
16 // Windows implementation of the AudioManager singleton. This class is internal
17 // to the audio output and only internal users can call methods not exposed by
18 // the AudioManager class.
19 class MEDIA_EXPORT AudioManagerWin
: public AudioManagerBase
{
21 AudioManagerWin(AudioLogFactory
* audio_log_factory
);
23 // Implementation of AudioManager.
24 virtual bool HasAudioOutputDevices() override
;
25 virtual bool HasAudioInputDevices() override
;
26 virtual base::string16
GetAudioInputDeviceModel() override
;
27 virtual void ShowAudioInputSettings() override
;
28 virtual void GetAudioInputDeviceNames(
29 AudioDeviceNames
* device_names
) override
;
30 virtual void GetAudioOutputDeviceNames(
31 AudioDeviceNames
* device_names
) override
;
32 virtual AudioParameters
GetInputStreamParameters(
33 const std::string
& device_id
) override
;
34 virtual std::string
GetAssociatedOutputDeviceID(
35 const std::string
& input_device_id
) override
;
37 // Implementation of AudioManagerBase.
38 virtual AudioOutputStream
* MakeLinearOutputStream(
39 const AudioParameters
& params
) override
;
40 virtual AudioOutputStream
* MakeLowLatencyOutputStream(
41 const AudioParameters
& params
,
42 const std::string
& device_id
) override
;
43 virtual AudioInputStream
* MakeLinearInputStream(
44 const AudioParameters
& params
, const std::string
& device_id
) override
;
45 virtual AudioInputStream
* MakeLowLatencyInputStream(
46 const AudioParameters
& params
, const std::string
& device_id
) override
;
47 virtual std::string
GetDefaultOutputDeviceID() override
;
50 virtual ~AudioManagerWin();
52 virtual AudioParameters
GetPreferredOutputStreamParameters(
53 const std::string
& output_device_id
,
54 const AudioParameters
& input_params
) override
;
57 enum EnumerationType
{
62 // Allow unit test to modify the utilized enumeration API.
63 friend class AudioManagerTest
;
65 EnumerationType enumeration_type_
;
66 EnumerationType
enumeration_type() { return enumeration_type_
; }
67 void SetEnumerationType(EnumerationType type
) {
68 enumeration_type_
= type
;
71 inline bool core_audio_supported() const {
72 return enumeration_type_
== kMMDeviceEnumeration
;
75 // Returns a PCMWaveInAudioInputStream instance or NULL on failure.
76 // This method converts MMDevice-style device ID to WaveIn-style device ID if
78 // (Please see device_enumeration_win.h for more info about the two kinds of
80 AudioInputStream
* CreatePCMWaveInAudioInputStream(
81 const AudioParameters
& params
,
82 const std::string
& device_id
);
84 // Helper methods for performing expensive initialization tasks on the audio
85 // thread instead of on the UI thread which AudioManager is constructed on.
86 void InitializeOnAudioThread();
87 void ShutdownOnAudioThread();
89 void GetAudioDeviceNamesImpl(bool input
, AudioDeviceNames
* device_names
);
91 // Listen for output device changes.
92 scoped_ptr
<AudioDeviceListenerWin
> output_device_listener_
;
94 DISALLOW_COPY_AND_ASSIGN(AudioManagerWin
);
99 #endif // MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_