Chromium Code Reviews| Index: media/audio/linux/audio_manager_linux.cc |
| diff --git a/media/audio/linux/audio_manager_linux.cc b/media/audio/linux/audio_manager_linux.cc |
| index da24f1228d30a3afda012d08f1a1ca33f0e161b8..8c1241405dc8419b0fd5a8d15a2f62e066745acb 100644 |
| --- a/media/audio/linux/audio_manager_linux.cc |
| +++ b/media/audio/linux/audio_manager_linux.cc |
| @@ -11,8 +11,6 @@ |
| #include "base/process_util.h" |
| #include "base/stl_util.h" |
| #include "media/audio/audio_output_dispatcher.h" |
| -#include "media/audio/fake_audio_input_stream.h" |
| -#include "media/audio/fake_audio_output_stream.h" |
| #include "media/audio/linux/alsa_input.h" |
| #include "media/audio/linux/alsa_output.h" |
| #include "media/audio/linux/alsa_wrapper.h" |
| @@ -23,7 +21,7 @@ |
| #include "media/base/media_switches.h" |
| // Maximum number of output streams that can be open simultaneously. |
| -static const size_t kMaxOutputStreams = 50; |
| +static const int kMaxOutputStreams = 50; |
| static const int kMaxInputChannels = 2; |
| @@ -47,67 +45,10 @@ bool AudioManagerLinux::HasAudioInputDevices() { |
| return HasAnyAlsaAudioDevice(kStreamCapture); |
| } |
| -AudioOutputStream* AudioManagerLinux::MakeAudioOutputStream( |
| - const AudioParameters& params) { |
| - // Early return for testing hook. |
| - if (params.format == AudioParameters::AUDIO_MOCK) |
| - return FakeAudioOutputStream::MakeFakeStream(params); |
| - |
| - // Don't allow opening more than |kMaxOutputStreams| streams. |
| - if (active_output_stream_count_ >= kMaxOutputStreams) |
| - return NULL; |
| - |
| - AudioOutputStream* stream = NULL; |
| -#if defined(USE_PULSEAUDIO) |
| - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) { |
| - stream = new PulseAudioOutputStream(params, this); |
| - } else { |
| -#endif |
| - std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; |
| - if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kAlsaOutputDevice)) { |
| - device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| - switches::kAlsaOutputDevice); |
| - } |
| - stream = new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this); |
| -#if defined(USE_PULSEAUDIO) |
| - } |
| -#endif |
| - ++active_output_stream_count_; |
| - DCHECK(stream); |
| - return stream; |
| -} |
| - |
| -AudioInputStream* AudioManagerLinux::MakeAudioInputStream( |
| - const AudioParameters& params, const std::string& device_id) { |
| - if (!params.IsValid() || params.channels > kMaxInputChannels || |
| - device_id.empty()) { |
| - return NULL; |
| - } |
| - |
| - if (params.format == AudioParameters::AUDIO_MOCK) { |
| - return FakeAudioInputStream::MakeFakeStream(params); |
| - } |
| - |
| - std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ? |
| - AlsaPcmInputStream::kAutoSelectDevice : device_id; |
| - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) { |
| - device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| - switches::kAlsaInputDevice); |
| - } |
| - |
| - AlsaPcmInputStream* stream = new AlsaPcmInputStream(this, |
| - device_name, params, wrapper_.get()); |
| - |
| - return stream; |
| -} |
| - |
| -AudioManagerLinux::AudioManagerLinux() : active_output_stream_count_(0U) {} |
| +AudioManagerLinux::AudioManagerLinux() {} |
| AudioManagerLinux::~AudioManagerLinux() { |
| Shutdown(); |
| - // All the streams should have been deleted on the audio thread via Shutdown. |
| - CHECK_EQ(active_output_stream_count_, 0U); |
| } |
| void AudioManagerLinux::Init() { |
| @@ -123,14 +64,6 @@ void AudioManagerLinux::UnMuteAll() { |
| NOTIMPLEMENTED(); |
| } |
| -void AudioManagerLinux::ReleaseOutputStream(AudioOutputStream* stream) { |
| - if (stream) { |
| - delete stream; |
| - --active_output_stream_count_; |
| - DCHECK_GE(active_output_stream_count_, 0U); |
| - } |
| -} |
| - |
| bool AudioManagerLinux::CanShowAudioInputSettings() { |
| scoped_ptr<base::Environment> env(base::Environment::Create()); |
| base::nix::DesktopEnvironment desktop = base::nix::GetDesktopEnvironment( |
| @@ -303,6 +236,71 @@ bool AudioManagerLinux::HasAnyAlsaAudioDevice(StreamType stream) { |
| return has_device; |
| } |
| +int AudioManagerLinux::GetMaxAudioOutputStreamsAllowed() { |
| + return kMaxOutputStreams; |
| +} |
| + |
| +AudioOutputStream* AudioManagerLinux::MakeAudioLinearOutputStream( |
| + const AudioParameters& params) { |
| + DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); |
| + return MakeOutputStream(params); |
| +} |
| + |
| +AudioOutputStream* AudioManagerLinux::MakeAudioLowLatencyOutputStream( |
| + const AudioParameters& params) { |
| + DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); |
| + return MakeOutputStream(params); |
| +} |
| + |
| +AudioInputStream* AudioManagerLinux::MakeAudioLinearInputStream( |
| + const AudioParameters& params, const std::string& device_id) { |
| + DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); |
| + return MakeInputStream(params, device_id); |
| +} |
| + |
| +AudioInputStream* AudioManagerLinux::MakeAudioLowLatencyInputStream( |
| + const AudioParameters& params, const std::string& device_id) { |
| + DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); |
| + return MakeInputStream(params, device_id); |
| +} |
| + |
| +AudioOutputStream* AudioManagerLinux::MakeOutputStream( |
| + const AudioParameters& params) { |
| + AudioOutputStream* stream = NULL; |
| +#if defined(USE_PULSEAUDIO) |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) { |
| + stream = new PulseAudioOutputStream(params, this); |
| + } else { |
| +#endif |
| + std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; |
| + if (CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kAlsaOutputDevice)) { |
|
tommi (sloooow) - chröme
2012/03/05 14:28:28
indent feels off to me
Foo(arg1,
arg2)
compared
no longer working on chromium
2012/03/06 15:27:07
Done.
|
| + device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + switches::kAlsaOutputDevice); |
| + } |
| + stream = new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this); |
| +#if defined(USE_PULSEAUDIO) |
| + } |
| +#endif |
| + DCHECK(stream); |
| + return stream; |
| +} |
| + |
| +AudioInputStream* AudioManagerLinux::MakeInputStream( |
| + const AudioParameters& params, const std::string& device_id) { |
| + if (params.channels > kMaxInputChannels) |
| + return NULL; |
| + |
| + std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ? |
| + AlsaPcmInputStream::kAutoSelectDevice : device_id; |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) { |
| + device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| + switches::kAlsaInputDevice); |
| + } |
| + |
| + return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); |
| +} |
| + |
| AudioManager* CreateAudioManager() { |
| return new AudioManagerLinux(); |
| } |