Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 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_LINUX_AUDIO_MANAGER_LINUX_H_ | 5 #ifndef MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ |
| 6 #define MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_ | 6 #define MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ |
| 7 | 7 |
| 8 #include <pulse/pulseaudio.h> | |
| 8 #include <string> | 9 #include <string> |
| 10 | |
| 9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/threading/thread.h" | |
| 12 #include "media/audio/audio_manager_base.h" | 13 #include "media/audio/audio_manager_base.h" |
| 13 | 14 |
| 14 namespace media { | 15 namespace media { |
| 15 | 16 |
| 16 class AlsaWrapper; | 17 class MEDIA_EXPORT AudioManagerPulse : public AudioManagerBase { |
| 18 public: | |
| 19 AudioManagerPulse(); | |
| 20 virtual ~AudioManagerPulse(); | |
| 17 | 21 |
| 18 class MEDIA_EXPORT AudioManagerLinux : public AudioManagerBase { | 22 static AudioManager* Create(); |
| 19 public: | |
| 20 AudioManagerLinux(); | |
| 21 | 23 |
| 22 // Implementation of AudioManager. | 24 // Implementation of AudioManager. |
| 23 virtual bool HasAudioOutputDevices() OVERRIDE; | 25 virtual bool HasAudioOutputDevices() OVERRIDE; |
| 24 virtual bool HasAudioInputDevices() OVERRIDE; | 26 virtual bool HasAudioInputDevices() OVERRIDE; |
| 27 virtual bool CanShowAudioInputSettings() OVERRIDE; | |
|
DaleCurtis
2013/02/20 00:17:38
You'll need to rebase, this was deleted a few revi
no longer working on chromium
2013/02/20 14:43:38
Yes, I realized when Dylan pointed it out in anoth
| |
| 25 virtual void ShowAudioInputSettings() OVERRIDE; | 28 virtual void ShowAudioInputSettings() OVERRIDE; |
| 26 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) | 29 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) |
| 27 OVERRIDE; | 30 OVERRIDE; |
| 28 | 31 |
| 29 // Implementation of AudioManagerBase. | 32 // Implementation of AudioManagerBase. |
| 30 virtual AudioOutputStream* MakeLinearOutputStream( | 33 virtual AudioOutputStream* MakeLinearOutputStream( |
| 31 const AudioParameters& params) OVERRIDE; | 34 const AudioParameters& params) OVERRIDE; |
| 32 virtual AudioOutputStream* MakeLowLatencyOutputStream( | 35 virtual AudioOutputStream* MakeLowLatencyOutputStream( |
| 33 const AudioParameters& params) OVERRIDE; | 36 const AudioParameters& params) OVERRIDE; |
| 34 virtual AudioInputStream* MakeLinearInputStream( | 37 virtual AudioInputStream* MakeLinearInputStream( |
| 35 const AudioParameters& params, const std::string& device_id) OVERRIDE; | 38 const AudioParameters& params, const std::string& device_id) OVERRIDE; |
| 36 virtual AudioInputStream* MakeLowLatencyInputStream( | 39 virtual AudioInputStream* MakeLowLatencyInputStream( |
| 37 const AudioParameters& params, const std::string& device_id) OVERRIDE; | 40 const AudioParameters& params, const std::string& device_id) OVERRIDE; |
| 38 virtual AudioParameters GetPreferredLowLatencyOutputStreamParameters( | 41 virtual AudioParameters GetPreferredLowLatencyOutputStreamParameters( |
| 39 const AudioParameters& input_params) OVERRIDE; | 42 const AudioParameters& input_params) OVERRIDE; |
| 40 | 43 |
| 41 protected: | 44 int GetNativeSampleRate(); |
| 42 virtual ~AudioManagerLinux(); | |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 enum StreamType { | 47 bool Init(); |
| 46 kStreamPlayback = 0, | 48 void Terminate(); |
| 47 kStreamCapture, | |
| 48 }; | |
| 49 | 49 |
| 50 // Returns true if cras should be used for input/output. | 50 // Callback to get the devices' info like names, used by GetInputDevices(). |
| 51 bool UseCras(); | 51 static void DevicesInfoCallback(pa_context* context, |
| 52 const pa_source_info* info, | |
| 53 int error, void* user_data); | |
| 52 | 54 |
| 53 // Gets a list of available cras input devices. | 55 // Callback to get the native sample rate of PulseAudio, used by |
| 54 void GetCrasAudioInputDevices(media::AudioDeviceNames* device_names); | 56 // GetNativeSampleRate(). |
| 55 | 57 static void SamplerateInfoCallback(pa_context* context, |
|
DaleCurtis
2013/02/20 00:17:38
s/Samplerate/SampleRate/
Is there a reason you di
no longer working on chromium
2013/02/20 14:43:38
Done.
| |
| 56 // Gets a list of available ALSA input devices. | 58 const pa_server_info* info, |
| 57 void GetAlsaAudioInputDevices(media::AudioDeviceNames* device_names); | 59 void* user_data); |
| 58 | |
| 59 // Gets the ALSA devices' names and ids. | |
| 60 void GetAlsaDevicesInfo(void** hint, media::AudioDeviceNames* device_names); | |
| 61 | |
| 62 // Checks if the specific ALSA device is available. | |
| 63 bool IsAlsaDeviceAvailable(const char* device_name); | |
| 64 | |
| 65 // Returns true if a device is present for the given stream type. | |
| 66 bool HasAnyAlsaAudioDevice(StreamType stream); | |
| 67 | 60 |
| 68 // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream. | 61 // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream. |
| 69 AudioOutputStream* MakeOutputStream(const AudioParameters& params); | 62 AudioOutputStream* MakeOutputStream(const AudioParameters& params); |
| 70 | 63 |
| 71 // Called by MakeLinearInputStream and MakeLowLatencyInputStream. | 64 // Called by MakeLinearInputStream and MakeLowLatencyInputStream. |
| 72 AudioInputStream* MakeInputStream(const AudioParameters& params, | 65 AudioInputStream* MakeInputStream(const AudioParameters& params, |
| 73 const std::string& device_id); | 66 const std::string& device_id); |
| 74 | 67 |
| 75 scoped_ptr<AlsaWrapper> wrapper_; | 68 pa_threaded_mainloop* input_mainloop_; |
| 69 pa_context* input_context_; | |
| 70 AudioDeviceNames* devices_; | |
| 71 int native_input_sample_rate_; | |
| 76 | 72 |
| 77 DISALLOW_COPY_AND_ASSIGN(AudioManagerLinux); | 73 DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse); |
| 78 }; | 74 }; |
| 79 | 75 |
| 80 } // namespace media | 76 } // namespace media |
| 81 | 77 |
| 82 #endif // MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_ | 78 #endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_ |
| OLD | NEW |