| 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(std::unique_ptr<AudioThread> audio_thread, |
| 21 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 21 AudioLogFactory* audio_log_factory, |
| 22 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner, | 22 pa_threaded_mainloop* pa_mainloop, |
| 23 AudioLogFactory* audio_log_factory); | 23 pa_context* pa_context); |
| 24 | 24 ~AudioManagerPulse() override; |
| 25 bool Init(); | |
| 26 | 25 |
| 27 // Implementation of AudioManager. | 26 // Implementation of AudioManager. |
| 28 bool HasAudioOutputDevices() override; | 27 bool HasAudioOutputDevices() override; |
| 29 bool HasAudioInputDevices() override; | 28 bool HasAudioInputDevices() override; |
| 30 void ShowAudioInputSettings() override; | 29 void ShowAudioInputSettings() override; |
| 31 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; | 30 void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override; |
| 32 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; | 31 void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override; |
| 33 AudioParameters GetInputStreamParameters( | 32 AudioParameters GetInputStreamParameters( |
| 34 const std::string& device_id) override; | 33 const std::string& device_id) override; |
| 35 const char* GetName() override; | 34 const char* GetName() override; |
| 36 | 35 |
| 37 // Implementation of AudioManagerBase. | 36 // Implementation of AudioManagerBase. |
| 38 AudioOutputStream* MakeLinearOutputStream( | 37 AudioOutputStream* MakeLinearOutputStream( |
| 39 const AudioParameters& params, | 38 const AudioParameters& params, |
| 40 const LogCallback& log_callback) override; | 39 const LogCallback& log_callback) override; |
| 41 AudioOutputStream* MakeLowLatencyOutputStream( | 40 AudioOutputStream* MakeLowLatencyOutputStream( |
| 42 const AudioParameters& params, | 41 const AudioParameters& params, |
| 43 const std::string& device_id, | 42 const std::string& device_id, |
| 44 const LogCallback& log_callback) override; | 43 const LogCallback& log_callback) override; |
| 45 AudioInputStream* MakeLinearInputStream( | 44 AudioInputStream* MakeLinearInputStream( |
| 46 const AudioParameters& params, | 45 const AudioParameters& params, |
| 47 const std::string& device_id, | 46 const std::string& device_id, |
| 48 const LogCallback& log_callback) override; | 47 const LogCallback& log_callback) override; |
| 49 AudioInputStream* MakeLowLatencyInputStream( | 48 AudioInputStream* MakeLowLatencyInputStream( |
| 50 const AudioParameters& params, | 49 const AudioParameters& params, |
| 51 const std::string& device_id, | 50 const std::string& device_id, |
| 52 const LogCallback& log_callback) override; | 51 const LogCallback& log_callback) override; |
| 53 | 52 |
| 54 protected: | 53 protected: |
| 55 ~AudioManagerPulse() override; | 54 void ShutdownOnAudioThread() override; |
| 56 | |
| 57 AudioParameters GetPreferredOutputStreamParameters( | 55 AudioParameters GetPreferredOutputStreamParameters( |
| 58 const std::string& output_device_id, | 56 const std::string& output_device_id, |
| 59 const AudioParameters& input_params) override; | 57 const AudioParameters& input_params) override; |
| 60 | 58 |
| 61 private: | 59 private: |
| 62 bool InitPulse(); | |
| 63 void DestroyPulse(); | |
| 64 | |
| 65 void GetAudioDeviceNames(bool input, media::AudioDeviceNames* device_names); | 60 void GetAudioDeviceNames(bool input, media::AudioDeviceNames* device_names); |
| 66 | 61 |
| 67 // Callback to get the devices' info like names, used by GetInputDevices(). | 62 // Callback to get the devices' info like names, used by GetInputDevices(). |
| 68 static void InputDevicesInfoCallback(pa_context* context, | 63 static void InputDevicesInfoCallback(pa_context* context, |
| 69 const pa_source_info* info, | 64 const pa_source_info* info, |
| 70 int error, void* user_data); | 65 int error, void* user_data); |
| 71 static void OutputDevicesInfoCallback(pa_context* context, | 66 static void OutputDevicesInfoCallback(pa_context* context, |
| 72 const pa_sink_info* info, | 67 const pa_sink_info* info, |
| 73 int error, void* user_data); | 68 int error, void* user_data); |
| 74 | 69 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 94 AudioDeviceNames* devices_; | 89 AudioDeviceNames* devices_; |
| 95 int native_input_sample_rate_; | 90 int native_input_sample_rate_; |
| 96 int native_channel_count_; | 91 int native_channel_count_; |
| 97 | 92 |
| 98 DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse); | 93 DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse); |
| 99 }; | 94 }; |
| 100 | 95 |
| 101 } // namespace media | 96 } // namespace media |
| 102 | 97 |
| 103 #endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ | 98 #endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ |
| OLD | NEW |