Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / audio / win / audio_manager_win.h
blob98265664176e08d493da5265611e510e96453eff
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_
8 #include <string>
10 #include "media/audio/audio_manager_base.h"
12 namespace media {
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 {
20 public:
21 AudioManagerWin(AudioLogFactory* audio_log_factory);
23 // Implementation of AudioManager.
24 bool HasAudioOutputDevices() override;
25 bool HasAudioInputDevices() override;
26 base::string16 GetAudioInputDeviceModel() override;
27 void ShowAudioInputSettings() override;
28 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override;
29 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override;
30 AudioParameters GetInputStreamParameters(
31 const std::string& device_id) override;
32 std::string GetAssociatedOutputDeviceID(
33 const std::string& input_device_id) override;
35 // Implementation of AudioManagerBase.
36 AudioOutputStream* MakeLinearOutputStream(
37 const AudioParameters& params) override;
38 AudioOutputStream* MakeLowLatencyOutputStream(
39 const AudioParameters& params,
40 const std::string& device_id) override;
41 AudioInputStream* MakeLinearInputStream(
42 const AudioParameters& params,
43 const std::string& device_id) override;
44 AudioInputStream* MakeLowLatencyInputStream(
45 const AudioParameters& params,
46 const std::string& device_id) override;
47 std::string GetDefaultOutputDeviceID() override;
49 protected:
50 ~AudioManagerWin() override;
52 AudioParameters GetPreferredOutputStreamParameters(
53 const std::string& output_device_id,
54 const AudioParameters& input_params) override;
56 private:
57 enum EnumerationType {
58 kMMDeviceEnumeration,
59 kWaveEnumeration,
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
77 // necessary.
78 // (Please see device_enumeration_win.h for more info about the two kinds of
79 // device IDs.)
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);
97 } // namespace media
99 #endif // MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_