Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / audio / pulse / audio_manager_pulse.h
blob3639663992947522b7fe3d87a07a436d0b05dfd3
1 // Copyright 2013 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_PULSE_AUDIO_MANAGER_PULSE_H_
6 #define MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_
8 #include <pulse/pulseaudio.h>
9 #include <string>
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "media/audio/audio_manager_base.h"
15 namespace media {
17 class MEDIA_EXPORT AudioManagerPulse : public AudioManagerBase {
18 public:
19 AudioManagerPulse();
20 virtual ~AudioManagerPulse();
22 static AudioManager* Create();
24 // Implementation of AudioManager.
25 virtual bool HasAudioOutputDevices() OVERRIDE;
26 virtual bool HasAudioInputDevices() 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;
35 // Implementation of AudioManagerBase.
36 virtual AudioOutputStream* MakeLinearOutputStream(
37 const AudioParameters& params) OVERRIDE;
38 virtual AudioOutputStream* MakeLowLatencyOutputStream(
39 const AudioParameters& params,
40 const std::string& device_id,
41 const std::string& input_device_id) OVERRIDE;
42 virtual AudioInputStream* MakeLinearInputStream(
43 const AudioParameters& params, const std::string& device_id) OVERRIDE;
44 virtual AudioInputStream* MakeLowLatencyInputStream(
45 const AudioParameters& params, const std::string& device_id) OVERRIDE;
47 protected:
48 virtual AudioParameters GetPreferredOutputStreamParameters(
49 const std::string& output_device_id,
50 const AudioParameters& input_params) OVERRIDE;
52 private:
53 bool Init();
54 void DestroyPulse();
56 void GetAudioDeviceNames(bool input, media::AudioDeviceNames* device_names);
58 // Callback to get the devices' info like names, used by GetInputDevices().
59 static void InputDevicesInfoCallback(pa_context* context,
60 const pa_source_info* info,
61 int error, void* user_data);
62 static void OutputDevicesInfoCallback(pa_context* context,
63 const pa_sink_info* info,
64 int error, void* user_data);
66 // Callback to get the native sample rate of PulseAudio, used by
67 // GetNativeSampleRate().
68 static void SampleRateInfoCallback(pa_context* context,
69 const pa_server_info* info,
70 void* user_data);
72 // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream.
73 AudioOutputStream* MakeOutputStream(const AudioParameters& params,
74 const std::string& input_device_id);
76 // Called by MakeLinearInputStream and MakeLowLatencyInputStream.
77 AudioInputStream* MakeInputStream(const AudioParameters& params,
78 const std::string& device_id);
80 // Gets the native sample rate of Pulse.
81 int GetNativeSampleRate();
83 pa_threaded_mainloop* input_mainloop_;
84 pa_context* input_context_;
85 AudioDeviceNames* devices_;
86 int native_input_sample_rate_;
88 DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse);
91 } // namespace media
93 #endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_