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>
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "media/audio/audio_manager_base.h"
17 class MEDIA_EXPORT AudioManagerPulse
: public AudioManagerBase
{
19 AudioManagerPulse(AudioLogFactory
* audio_log_factory
);
20 ~AudioManagerPulse() override
;
22 static AudioManager
* Create(AudioLogFactory
* audio_log_factory
);
24 // Implementation of AudioManager.
25 bool HasAudioOutputDevices() override
;
26 bool HasAudioInputDevices() 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
;
33 // Implementation of AudioManagerBase.
34 AudioOutputStream
* MakeLinearOutputStream(
35 const AudioParameters
& params
) override
;
36 AudioOutputStream
* MakeLowLatencyOutputStream(
37 const AudioParameters
& params
,
38 const std::string
& device_id
) override
;
39 AudioInputStream
* MakeLinearInputStream(
40 const AudioParameters
& params
,
41 const std::string
& device_id
) override
;
42 AudioInputStream
* MakeLowLatencyInputStream(
43 const AudioParameters
& params
,
44 const std::string
& device_id
) override
;
47 AudioParameters
GetPreferredOutputStreamParameters(
48 const std::string
& output_device_id
,
49 const AudioParameters
& input_params
) override
;
55 void GetAudioDeviceNames(bool input
, media::AudioDeviceNames
* device_names
);
57 // Callback to get the devices' info like names, used by GetInputDevices().
58 static void InputDevicesInfoCallback(pa_context
* context
,
59 const pa_source_info
* info
,
60 int error
, void* user_data
);
61 static void OutputDevicesInfoCallback(pa_context
* context
,
62 const pa_sink_info
* info
,
63 int error
, void* user_data
);
65 // Callback to get the native sample rate of PulseAudio, used by
66 // GetNativeSampleRate().
67 static void SampleRateInfoCallback(pa_context
* context
,
68 const pa_server_info
* info
,
71 // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream.
72 AudioOutputStream
* MakeOutputStream(const AudioParameters
& params
,
73 const std::string
& device_id
);
75 // Called by MakeLinearInputStream and MakeLowLatencyInputStream.
76 AudioInputStream
* MakeInputStream(const AudioParameters
& params
,
77 const std::string
& device_id
);
79 // Gets the native sample rate of Pulse.
80 int GetNativeSampleRate();
82 pa_threaded_mainloop
* input_mainloop_
;
83 pa_context
* input_context_
;
84 AudioDeviceNames
* devices_
;
85 int native_input_sample_rate_
;
87 DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse
);
92 #endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_