| Index: media/audio/pulse/audio_manager_pulse.h
|
| diff --git a/media/audio/linux/audio_manager_linux.h b/media/audio/pulse/audio_manager_pulse.h
|
| similarity index 54%
|
| copy from media/audio/linux/audio_manager_linux.h
|
| copy to media/audio/pulse/audio_manager_pulse.h
|
| index 7aab32abf99c9770df271863f9cc535f6e8f0baa..095c1f74d0733877773afd01fb0f80342287b955 100644
|
| --- a/media/audio/linux/audio_manager_linux.h
|
| +++ b/media/audio/pulse/audio_manager_pulse.h
|
| @@ -1,23 +1,27 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_
|
| -#define MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_
|
| +#ifndef MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_
|
| +#define MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_
|
|
|
| +#include <pulse/pulseaudio.h>
|
| #include <string>
|
| +
|
| #include "base/compiler_specific.h"
|
| #include "base/memory/ref_counted.h"
|
| -#include "base/threading/thread.h"
|
| #include "media/audio/audio_manager_base.h"
|
|
|
| namespace media {
|
|
|
| -class AlsaWrapper;
|
| +class PulseWrapper;
|
|
|
| -class MEDIA_EXPORT AudioManagerLinux : public AudioManagerBase {
|
| +class MEDIA_EXPORT AudioManagerPulse : public AudioManagerBase {
|
| public:
|
| - AudioManagerLinux();
|
| + AudioManagerPulse();
|
| + virtual ~AudioManagerPulse();
|
| +
|
| + static AudioManager* Create();
|
|
|
| // Implementation of AudioManager.
|
| virtual bool HasAudioOutputDevices() OVERRIDE;
|
| @@ -39,32 +43,25 @@ class MEDIA_EXPORT AudioManagerLinux : public AudioManagerBase {
|
| virtual AudioParameters GetPreferredLowLatencyOutputStreamParameters(
|
| const AudioParameters& input_params) OVERRIDE;
|
|
|
| - protected:
|
| - virtual ~AudioManagerLinux();
|
| + int GetNativeSampleRate();
|
|
|
| private:
|
| - enum StreamType {
|
| - kStreamPlayback = 0,
|
| - kStreamCapture,
|
| - };
|
| -
|
| - // Returns true if cras should be used for input/output.
|
| - bool UseCras();
|
| -
|
| - // Gets a list of available cras input devices.
|
| - void GetCrasAudioInputDevices(media::AudioDeviceNames* device_names);
|
| -
|
| - // Gets a list of available ALSA input devices.
|
| - void GetAlsaAudioInputDevices(media::AudioDeviceNames* device_names);
|
| + bool Init();
|
| + void Terminate();
|
|
|
| - // Gets the ALSA devices' names and ids.
|
| - void GetAlsaDevicesInfo(void** hint, media::AudioDeviceNames* device_names);
|
| + // Triggers pa_threaded_mainloop_signal() to avoid deadlocks.
|
| + static void ContextStateCallback(pa_context* context, void* user_data);
|
|
|
| - // Checks if the specific ALSA device is available.
|
| - bool IsAlsaDeviceAvailable(const char* device_name);
|
| + // Callback to get the devices' info like names, used by GetInputDevices().
|
| + static void DevicesInfoCallback(pa_context* context,
|
| + const pa_source_info* info,
|
| + int error, void* user_data);
|
|
|
| - // Returns true if a device is present for the given stream type.
|
| - bool HasAnyAlsaAudioDevice(StreamType stream);
|
| + // Callback to get the native sample rate of PulseAudio, used by
|
| + // GetNativeSampleRate().
|
| + static void SamplerateInfoCallback(pa_context* context,
|
| + const pa_server_info* info,
|
| + void* user_data);
|
|
|
| // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream.
|
| AudioOutputStream* MakeOutputStream(const AudioParameters& params);
|
| @@ -73,11 +70,15 @@ class MEDIA_EXPORT AudioManagerLinux : public AudioManagerBase {
|
| AudioInputStream* MakeInputStream(const AudioParameters& params,
|
| const std::string& device_id);
|
|
|
| - scoped_ptr<AlsaWrapper> wrapper_;
|
| + scoped_ptr<PulseWrapper> wrapper_;
|
| + pa_threaded_mainloop* input_mainloop_;
|
| + pa_context* input_context_;
|
| + AudioDeviceNames* devices_;
|
| + int native_input_sample_rate_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(AudioManagerLinux);
|
| + DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse);
|
| };
|
|
|
| } // namespace media
|
|
|
| -#endif // MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_
|
| +#endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_
|
|
|