diff options
author | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 15:25:51 +0000 |
---|---|---|
committer | xians@chromium.org <xians@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 15:25:51 +0000 |
commit | f34a9058aa124789ebc5b1e38d9d890c29f49ce5 (patch) | |
tree | 4002bf52e0861deb1c75b7f09cd6f601487a54d7 /media/audio/openbsd | |
parent | eaabba206ae14905ef3a922e7b839cab285dd940 (diff) | |
download | chromium_src-f34a9058aa124789ebc5b1e38d9d890c29f49ce5.zip chromium_src-f34a9058aa124789ebc5b1e38d9d890c29f49ce5.tar.gz chromium_src-f34a9058aa124789ebc5b1e38d9d890c29f49ce5.tar.bz2 |
Moved the implementations of ReleaseOutputStream() and ReleaseInputStream() to AudioManagerBase and let all the AudioManagerPlatforms inherit the same implementations.
Also moved the MakeAudioOutputStream() and MakeAudioInputStream() to AudioManagerBase, separate the AUDIO_PCM_LINEAR mode and AUDIO_PCM_LOW_LATENCY mode into two different functions inside the AudioManagerPlatforms. So that the structure is clearer and also easier to deprecate the AUDIO_PCM_LINEAR for the future.
Made the destructor of the AudioManagerPlatforms protected so it can be called by only the AudioManagerBase.
BUG=116064
TEST=media_unittests
Review URL: http://codereview.chromium.org/9570014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/openbsd')
-rw-r--r-- | media/audio/openbsd/audio_manager_openbsd.cc | 90 | ||||
-rw-r--r-- | media/audio/openbsd/audio_manager_openbsd.h | 20 |
2 files changed, 54 insertions, 56 deletions
diff --git a/media/audio/openbsd/audio_manager_openbsd.cc b/media/audio/openbsd/audio_manager_openbsd.cc index 7222748..1ef9398 100644 --- a/media/audio/openbsd/audio_manager_openbsd.cc +++ b/media/audio/openbsd/audio_manager_openbsd.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -7,8 +7,6 @@ #include "base/command_line.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" #if defined(USE_PULSEAUDIO) #include "media/audio/pulse/pulse_output.h" #endif @@ -18,7 +16,7 @@ #include <fcntl.h> // Maximum number of output streams that can be open simultaneously. -static const size_t kMaxOutputStreams = 50; +static const int kMaxOutputStreams = 50; // Implementation of AudioManager. static bool HasAudioHardware() { @@ -43,43 +41,8 @@ bool AudioManagerOpenBSD::HasAudioInputDevices() { return HasAudioHardware(); } -AudioOutputStream* AudioManagerOpenBSD::MakeAudioOutputStream( - const AudioParameters& params) { - // Early return for testing hook. Do this before checking for - // |initialized_|. - if (params.format == AudioParameters::AUDIO_MOCK) { - return FakeAudioOutputStream::MakeFakeStream(params); - } - - if (!initialized()) { - return NULL; - } - - // Don't allow opening more than |kMaxOutputStreams| streams. - if (active_streams_.size() >= kMaxOutputStreams) { - return NULL; - } - - AudioOutputStream* stream; -#if defined(USE_PULSEAUDIO) - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) { - stream = new PulseAudioOutputStream(params, this); - active_streams_.insert(stream); - return stream; - } -#endif - - NOTIMPLEMENTED(); - return NULL; -} - -AudioInputStream* AudioManagerOpenBSD::MakeAudioInputStream( - const AudioParameters& params, const std::string& device_id) { - NOTIMPLEMENTED(); - return NULL; -} - AudioManagerOpenBSD::AudioManagerOpenBSD() { + SetMaxOutputStreamsAllowed(kMaxOutputStreams); } AudioManagerOpenBSD::~AudioManagerOpenBSD() { @@ -92,10 +55,6 @@ AudioManagerOpenBSD::~AudioManagerOpenBSD() { // Free output dispatchers, closing all remaining open streams. output_dispatchers_.clear(); - - // Delete all the streams. Have to do it manually, we don't have ScopedSet<>, - // and we are not using ScopedVector<> because search there is slow. - STLDeleteElements(&active_streams_); } void AudioManagerOpenBSD::Init() { @@ -110,11 +69,46 @@ void AudioManagerOpenBSD::UnMuteAll() { NOTIMPLEMENTED(); } -void AudioManagerOpenBSD::ReleaseOutputStream(AudioOutputStream* stream) { - if (stream) { - active_streams_.erase(stream); - delete stream; +AudioOutputStream* AudioManagerOpenBSD::MakeLinearOutputStream( + const AudioParameters& params) { + DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); + return MakeOutputStream(params); +} + +AudioOutputStream* AudioManagerOpenBSD::MakeLowLatencyOutputStream( + const AudioParameters& params) { + DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); + return MakeOutputStream(params); +} + +AudioInputStream* AudioManagerOpenBSD::MakeLinearInputStream( + const AudioParameters& params, const std::string& device_id) { + DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format); + NOTIMPLEMENTED(); + return NULL; +} + +AudioInputStream* AudioManagerOpenBSD::MakeLowLatencyInputStream( + const AudioParameters& params, const std::string& device_id) { + DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format); + NOTIMPLEMENTED(); + return NULL; +} + +AudioOutputStream* AudioManagerOpenBSD::MakeOutputStream( + const AudioParameters& params) { + if (!initialized()) { + return NULL; } + +#if defined(USE_PULSEAUDIO) + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) { + return new PulseAudioOutputStream(params, this); + } +#endif + + NOTIMPLEMENTED(); + return NULL; } // static diff --git a/media/audio/openbsd/audio_manager_openbsd.h b/media/audio/openbsd/audio_manager_openbsd.h index fa49203..86b56c0 100644 --- a/media/audio/openbsd/audio_manager_openbsd.h +++ b/media/audio/openbsd/audio_manager_openbsd.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -20,21 +20,25 @@ class MEDIA_EXPORT AudioManagerOpenBSD : public AudioManagerBase { // Implementation of AudioManager. virtual bool HasAudioOutputDevices() OVERRIDE; virtual bool HasAudioInputDevices() OVERRIDE; - virtual AudioOutputStream* MakeAudioOutputStream( - const AudioParameters& params) OVERRIDE; - virtual AudioInputStream* MakeAudioInputStream( - const AudioParameters& params, const std::string& device_id) OVERRIDE; - virtual void MuteAll() OVERRIDE; virtual void UnMuteAll() OVERRIDE; - virtual void ReleaseOutputStream(AudioOutputStream* stream); + // Implementation of AudioManagerBase. + virtual AudioOutputStream* MakeLinearOutputStream( + const AudioParameters& params) OVERRIDE; + virtual AudioOutputStream* MakeLowLatencyOutputStream( + const AudioParameters& params) OVERRIDE; + virtual AudioInputStream* MakeLinearInputStream( + const AudioParameters& params, const std::string& device_id) OVERRIDE; + virtual AudioInputStream* MakeLowLatencyInputStream( + const AudioParameters& params, const std::string& device_id) OVERRIDE; protected: virtual ~AudioManagerOpenBSD(); private: - std::set<AudioOutputStream*> active_streams_; + // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream. + AudioOutputStream* MakeOutputStream(const AudioParameters& params); DISALLOW_COPY_AND_ASSIGN(AudioManagerOpenBSD); }; |