OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ | 5 #ifndef MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ |
6 #define MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ | 6 #define MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ |
7 | 7 |
8 #include <pulse/pulseaudio.h> | 8 #include <pulse/pulseaudio.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "media/audio/audio_manager_base.h" | 14 #include "media/audio/audio_manager_base.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 class MEDIA_EXPORT AudioManagerPulse : public AudioManagerBase { | 18 class MEDIA_EXPORT AudioManagerPulse : public AudioManagerBase { |
19 public: | 19 public: |
20 AudioManagerPulse( | 20 AudioManagerPulse(AudioLogFactory* audio_log_factory); |
21 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 21 ~AudioManagerPulse() override; |
22 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | |
23 AudioLogFactory* audio_log_factory); | |
24 | 22 |
25 bool Init(); | 23 static AudioManager* Create(AudioLogFactory* audio_log_factory); |
26 | 24 |
27 // Implementation of AudioManager. | 25 // Implementation of AudioManager. |
28 bool HasAudioOutputDevices() override; | 26 bool HasAudioOutputDevices() override; |
29 bool HasAudioInputDevices() override; | 27 bool HasAudioInputDevices() override; |
30 void ShowAudioInputSettings() override; | 28 void ShowAudioInputSettings() override; |
31 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; | 29 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; |
32 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; | 30 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; |
33 AudioParameters GetInputStreamParameters( | 31 AudioParameters GetInputStreamParameters( |
34 const std::string& device_id) override; | 32 const std::string& device_id) override; |
35 | 33 |
36 // Implementation of AudioManagerBase. | 34 // Implementation of AudioManagerBase. |
37 AudioOutputStream* MakeLinearOutputStream( | 35 AudioOutputStream* MakeLinearOutputStream( |
38 const AudioParameters& params) override; | 36 const AudioParameters& params) override; |
39 AudioOutputStream* MakeLowLatencyOutputStream( | 37 AudioOutputStream* MakeLowLatencyOutputStream( |
40 const AudioParameters& params, | 38 const AudioParameters& params, |
41 const std::string& device_id) override; | 39 const std::string& device_id) override; |
42 AudioInputStream* MakeLinearInputStream( | 40 AudioInputStream* MakeLinearInputStream( |
43 const AudioParameters& params, | 41 const AudioParameters& params, |
44 const std::string& device_id) override; | 42 const std::string& device_id) override; |
45 AudioInputStream* MakeLowLatencyInputStream( | 43 AudioInputStream* MakeLowLatencyInputStream( |
46 const AudioParameters& params, | 44 const AudioParameters& params, |
47 const std::string& device_id) override; | 45 const std::string& device_id) override; |
48 | 46 |
49 protected: | 47 protected: |
50 ~AudioManagerPulse() override; | |
51 | |
52 AudioParameters GetPreferredOutputStreamParameters( | 48 AudioParameters GetPreferredOutputStreamParameters( |
53 const std::string& output_device_id, | 49 const std::string& output_device_id, |
54 const AudioParameters& input_params) override; | 50 const AudioParameters& input_params) override; |
55 | 51 |
56 private: | 52 private: |
57 bool InitPulse(); | 53 bool Init(); |
58 void DestroyPulse(); | 54 void DestroyPulse(); |
59 | 55 |
60 void GetAudioDeviceNames(bool input, media::AudioDeviceNames* device_names); | 56 void GetAudioDeviceNames(bool input, media::AudioDeviceNames* device_names); |
61 | 57 |
62 // Callback to get the devices' info like names, used by GetInputDevices(). | 58 // Callback to get the devices' info like names, used by GetInputDevices(). |
63 static void InputDevicesInfoCallback(pa_context* context, | 59 static void InputDevicesInfoCallback(pa_context* context, |
64 const pa_source_info* info, | 60 const pa_source_info* info, |
65 int error, void* user_data); | 61 int error, void* user_data); |
66 static void OutputDevicesInfoCallback(pa_context* context, | 62 static void OutputDevicesInfoCallback(pa_context* context, |
67 const pa_sink_info* info, | 63 const pa_sink_info* info, |
(...skipping 20 matching lines...) Expand all Loading... |
88 pa_context* input_context_; | 84 pa_context* input_context_; |
89 AudioDeviceNames* devices_; | 85 AudioDeviceNames* devices_; |
90 int native_input_sample_rate_; | 86 int native_input_sample_rate_; |
91 | 87 |
92 DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse); | 88 DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse); |
93 }; | 89 }; |
94 | 90 |
95 } // namespace media | 91 } // namespace media |
96 | 92 |
97 #endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ | 93 #endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ |
OLD | NEW |