Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / audio / mac / audio_manager_mac.h
blob3ff16818af62b44f26482e45db6757b8fbb8f0db
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_MAC_AUDIO_MANAGER_MAC_H_
6 #define MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_
8 #include <CoreAudio/AudioHardware.h>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/message_loop/message_loop_proxy.h"
14 #include "media/audio/audio_manager_base.h"
15 #include "media/audio/mac/aggregate_device_manager.h"
16 #include "media/audio/mac/audio_device_listener_mac.h"
18 namespace media {
20 // Mac OS X implementation of the AudioManager singleton. This class is internal
21 // to the audio output and only internal users can call methods not exposed by
22 // the AudioManager class.
23 class MEDIA_EXPORT AudioManagerMac : public AudioManagerBase {
24 public:
25 AudioManagerMac();
27 // Implementation of AudioManager.
28 virtual bool HasAudioOutputDevices() OVERRIDE;
29 virtual bool HasAudioInputDevices() OVERRIDE;
30 virtual void GetAudioInputDeviceNames(
31 AudioDeviceNames* device_names) OVERRIDE;
32 virtual void GetAudioOutputDeviceNames(
33 AudioDeviceNames* device_names) OVERRIDE;
34 virtual AudioParameters GetInputStreamParameters(
35 const std::string& device_id) OVERRIDE;
36 virtual std::string GetAssociatedOutputDeviceID(
37 const std::string& input_device_id) OVERRIDE;
39 // Implementation of AudioManagerBase.
40 virtual AudioOutputStream* MakeLinearOutputStream(
41 const AudioParameters& params) OVERRIDE;
42 virtual AudioOutputStream* MakeLowLatencyOutputStream(
43 const AudioParameters& params,
44 const std::string& device_id,
45 const std::string& input_device_id) OVERRIDE;
46 virtual AudioInputStream* MakeLinearInputStream(
47 const AudioParameters& params, const std::string& device_id) OVERRIDE;
48 virtual AudioInputStream* MakeLowLatencyInputStream(
49 const AudioParameters& params, const std::string& device_id) OVERRIDE;
50 virtual std::string GetDefaultOutputDeviceID() OVERRIDE;
52 static bool GetDefaultInputDevice(AudioDeviceID* device);
53 static bool GetDefaultOutputDevice(AudioDeviceID* device);
54 static bool GetDefaultDevice(AudioDeviceID* device, bool input);
56 static bool GetDefaultOutputChannels(int* channels);
58 static bool GetDeviceChannels(AudioDeviceID device,
59 AudioObjectPropertyScope scope,
60 int* channels);
62 static int HardwareSampleRateForDevice(AudioDeviceID device_id);
63 static int HardwareSampleRate();
65 // Notify streams of a device change if the default output device or its
66 // sample rate has changed, otherwise does nothing.
67 void HandleDeviceChanges();
69 protected:
70 virtual ~AudioManagerMac();
72 virtual AudioParameters GetPreferredOutputStreamParameters(
73 const std::string& output_device_id,
74 const AudioParameters& input_params) OVERRIDE;
76 private:
77 bool HasUnifiedDefaultIO();
79 // Helper methods for constructing AudioDeviceListenerMac on the audio thread.
80 void CreateDeviceListener();
81 void DestroyDeviceListener();
83 int ChooseBufferSize(int output_sample_rate);
85 scoped_ptr<AudioDeviceListenerMac> output_device_listener_;
87 // Track the output sample-rate and the default output device
88 // so we can intelligently handle device notifications only when necessary.
89 int current_sample_rate_;
90 AudioDeviceID current_output_device_;
92 AggregateDeviceManager aggregate_device_manager_;
94 DISALLOW_COPY_AND_ASSIGN(AudioManagerMac);
97 } // namespace media
99 #endif // MEDIA_AUDIO_MAC_AUDIO_MANAGER_MAC_H_