• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_
6 #define MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_
7 
8 #include <string>
9 
10 #include "media/audio/audio_manager_base.h"
11 
12 namespace media {
13 
14 class AudioDeviceListenerWin;
15 
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);
22 
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;
36 
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,
43       const std::string& input_device_id) OVERRIDE;
44   virtual AudioInputStream* MakeLinearInputStream(
45       const AudioParameters& params, const std::string& device_id) OVERRIDE;
46   virtual AudioInputStream* MakeLowLatencyInputStream(
47       const AudioParameters& params, const std::string& device_id) OVERRIDE;
48   virtual std::string GetDefaultOutputDeviceID() OVERRIDE;
49 
50  protected:
51   virtual ~AudioManagerWin();
52 
53   virtual AudioParameters GetPreferredOutputStreamParameters(
54       const std::string& output_device_id,
55       const AudioParameters& input_params) OVERRIDE;
56 
57  private:
58   enum EnumerationType {
59     kUninitializedEnumeration = 0,
60     kMMDeviceEnumeration,
61     kWaveEnumeration,
62   };
63 
64   // Allow unit test to modify the utilized enumeration API.
65   friend class AudioManagerTest;
66 
67   EnumerationType enumeration_type_;
enumeration_type()68   EnumerationType enumeration_type() { return enumeration_type_; }
SetEnumerationType(EnumerationType type)69   void SetEnumerationType(EnumerationType type) {
70     enumeration_type_ = type;
71   }
72 
73   // Returns a PCMWaveInAudioInputStream instance or NULL on failure.
74   // This method converts MMDevice-style device ID to WaveIn-style device ID if
75   // necessary.
76   // (Please see device_enumeration_win.h for more info about the two kinds of
77   // device IDs.)
78   AudioInputStream* CreatePCMWaveInAudioInputStream(
79       const AudioParameters& params,
80       const std::string& device_id);
81 
82   // Helper methods for constructing AudioDeviceListenerWin on the audio thread.
83   void CreateDeviceListener();
84   void DestroyDeviceListener();
85 
86   void GetAudioDeviceNamesImpl(bool input, AudioDeviceNames* device_names);
87 
88   // Listen for output device changes.
89   scoped_ptr<AudioDeviceListenerWin> output_device_listener_;
90 
91   DISALLOW_COPY_AND_ASSIGN(AudioManagerWin);
92 };
93 
94 }  // namespace media
95 
96 #endif  // MEDIA_AUDIO_WIN_AUDIO_MANAGER_WIN_H_
97