summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 04:52:47 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 04:52:47 +0000
commit71ec3203561e97c3cde5acb59a5229efcfe3e881 (patch)
tree38160062fede6bbd3a6574f7988796948986ea1c
parent3a85b1f23e82eff120d6f7d28e94fbd85a3c7dc2 (diff)
downloadchromium_src-71ec3203561e97c3cde5acb59a5229efcfe3e881.zip
chromium_src-71ec3203561e97c3cde5acb59a5229efcfe3e881.tar.gz
chromium_src-71ec3203561e97c3cde5acb59a5229efcfe3e881.tar.bz2
Delete AudioOutputMixer.
Not used. If we do enable browser side mixing in the future it'll be based on AudioConverter. With renderer side mixing and AudioOutputProxy, there's not a pressing need for this function. BUG=none TEST=compile Review URL: https://chromiumcodereview.appspot.com/12082111 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180072 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/audio/audio_manager_base.cc18
-rw-r--r--media/audio/audio_output_mixer.cc248
-rw-r--r--media/audio/audio_output_mixer.h94
-rw-r--r--media/audio/audio_output_proxy_unittest.cc195
-rw-r--r--media/audio/audio_util.cc80
-rw-r--r--media/audio/audio_util.h9
-rw-r--r--media/audio/audio_util_unittest.cc82
-rw-r--r--media/media.gyp4
8 files changed, 0 insertions, 730 deletions
diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc
index a12b243..67e03c0 100644
--- a/media/audio/audio_manager_base.cc
+++ b/media/audio/audio_manager_base.cc
@@ -19,12 +19,6 @@
#include "media/audio/virtual_audio_output_stream.h"
#include "media/base/media_switches.h"
-// TODO(dalecurtis): Temporarily disabled while switching pipeline to use float,
-// http://crbug.com/114700
-#if defined(ENABLE_AUDIO_MIXER)
-#include "media/audio/audio_output_mixer.h"
-#endif
-
namespace media {
static const int kStreamCloseDelaySeconds = 5;
@@ -272,18 +266,6 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
return new AudioOutputProxy(dispatcher);
}
-#if defined(ENABLE_AUDIO_MIXER)
- // TODO(dalecurtis): Browser side mixing has a couple issues that must be
- // fixed before it can be turned on by default: http://crbug.com/138098 and
- // http://crbug.com/140247
- if (cmd_line->HasSwitch(switches::kEnableAudioMixer)) {
- scoped_refptr<AudioOutputDispatcher> dispatcher =
- new AudioOutputMixer(this, params, close_delay);
- output_dispatchers_[dispatcher_key] = dispatcher;
- return new AudioOutputProxy(dispatcher);
- }
-#endif
-
scoped_refptr<AudioOutputDispatcher> dispatcher =
new AudioOutputDispatcherImpl(this, output_params, close_delay);
output_dispatchers_[dispatcher_key] = dispatcher;
diff --git a/media/audio/audio_output_mixer.cc b/media/audio/audio_output_mixer.cc
deleted file mode 100644
index edce4ea..0000000
--- a/media/audio/audio_output_mixer.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-// 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.
-
-#include "media/audio/audio_output_mixer.h"
-
-#include <algorithm>
-
-#include "base/bind.h"
-#include "base/compiler_specific.h"
-#include "base/message_loop.h"
-#include "base/time.h"
-#include "media/audio/audio_io.h"
-#include "media/audio/audio_output_proxy.h"
-#include "media/audio/audio_util.h"
-
-namespace media {
-
-AudioOutputMixer::AudioOutputMixer(AudioManager* audio_manager,
- const AudioParameters& params,
- const base::TimeDelta& close_delay)
- : AudioOutputDispatcher(audio_manager, params),
- ALLOW_THIS_IN_INITIALIZER_LIST(weak_this_(this)),
- close_timer_(FROM_HERE,
- close_delay,
- weak_this_.GetWeakPtr(),
- &AudioOutputMixer::ClosePhysicalStream),
- pending_bytes_(0) {
- // TODO(enal): align data.
- mixer_data_.reset(new uint8[params_.GetBytesPerBuffer()]);
-}
-
-AudioOutputMixer::~AudioOutputMixer() {
-}
-
-bool AudioOutputMixer::OpenStream() {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-
- if (physical_stream_.get())
- return true;
- AudioOutputStream* stream = audio_manager_->MakeAudioOutputStream(params_);
- if (!stream)
- return false;
- if (!stream->Open()) {
- stream->Close();
- return false;
- }
- pending_bytes_ = 0; // Just in case.
- physical_stream_.reset(stream);
- close_timer_.Reset();
- return true;
-}
-
-bool AudioOutputMixer::StartStream(
- AudioOutputStream::AudioSourceCallback* callback,
- AudioOutputProxy* stream_proxy) {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-
- // May need to re-open the physical stream if no active proxies and
- // enough time had pass.
- OpenStream();
- if (!physical_stream_.get())
- return false;
-
- double volume = 0.0;
- stream_proxy->GetVolume(&volume);
- bool should_start = proxies_.empty();
- {
- base::AutoLock lock(lock_);
- ProxyData* proxy_data = &proxies_[stream_proxy];
- proxy_data->audio_source_callback = callback;
- proxy_data->volume = volume;
- proxy_data->pending_bytes = 0;
- }
- // We cannot start physical stream under the lock,
- // OnMoreData() would try acquiring it...
- if (should_start) {
- physical_stream_->SetVolume(1.0);
- physical_stream_->Start(this);
- }
- return true;
-}
-
-void AudioOutputMixer::StopStream(AudioOutputProxy* stream_proxy) {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-
- // Because of possible deadlock we cannot stop physical stream under the lock
- // (physical_stream_->Stop() can call OnError(), and it acquires the lock to
- // iterate through proxies), so acquire the lock, update proxy list, release
- // the lock, and only then stop physical stream if necessary.
- bool stop_physical_stream = false;
- {
- base::AutoLock lock(lock_);
- ProxyMap::iterator it = proxies_.find(stream_proxy);
- if (it != proxies_.end()) {
- proxies_.erase(it);
- stop_physical_stream = proxies_.empty();
- }
- }
- if (physical_stream_.get()) {
- if (stop_physical_stream) {
- physical_stream_->Stop();
- pending_bytes_ = 0; // Just in case.
- }
- close_timer_.Reset();
- }
-}
-
-void AudioOutputMixer::StreamVolumeSet(AudioOutputProxy* stream_proxy,
- double volume) {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-
- ProxyMap::iterator it = proxies_.find(stream_proxy);
-
- // Do nothing if stream is not currently playing.
- if (it != proxies_.end()) {
- base::AutoLock lock(lock_);
- it->second.volume = volume;
- }
-}
-
-void AudioOutputMixer::CloseStream(AudioOutputProxy* stream_proxy) {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-
- StopStream(stream_proxy);
-}
-
-void AudioOutputMixer::Shutdown() {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-
- // Cancel any pending tasks to close physical stream.
- weak_this_.InvalidateWeakPtrs();
-
- while (!proxies_.empty()) {
- CloseStream(proxies_.begin()->first);
- }
- ClosePhysicalStream();
-
- // No AudioOutputProxy objects should hold a reference to us when we get
- // to this stage.
- DCHECK(HasOneRef()) << "Only the AudioManager should hold a reference";
-}
-
-void AudioOutputMixer::ClosePhysicalStream() {
- DCHECK_EQ(MessageLoop::current(), message_loop_);
-
- if (proxies_.empty() && physical_stream_.get() != NULL)
- physical_stream_.release()->Close();
-}
-
-// AudioSourceCallback implementation.
-uint32 AudioOutputMixer::OnMoreData(uint8* dest,
- uint32 max_size,
- AudioBuffersState buffers_state) {
- max_size = std::min(max_size,
- static_cast<uint32>(params_.GetBytesPerBuffer()));
- // TODO(enal): consider getting rid of lock as it is in time-critical code.
- // E.g. swap |proxies_| with local variable, and merge 2 lists
- // at the end. That would speed things up but complicate stopping
- // the stream.
- base::AutoLock lock(lock_);
-
- DCHECK_GE(pending_bytes_, buffers_state.pending_bytes);
- if (proxies_.empty()) {
- pending_bytes_ = buffers_state.pending_bytes;
- return 0;
- }
- uint32 actual_total_size = 0;
- uint32 bytes_per_sample = params_.bits_per_sample() >> 3;
-
- // Go through all the streams, getting data for every one of them
- // and mixing it into destination.
- // Minor optimization: for the first stream we are writing data directly into
- // destination. This way we don't have to mix the data when there is only one
- // active stream, and net win in other cases, too.
- bool first_stream = true;
- uint8* actual_dest = dest;
- for (ProxyMap::iterator it = proxies_.begin(); it != proxies_.end(); ++it) {
- ProxyData* proxy_data = &it->second;
-
- // If proxy's pending bytes are the same as pending bytes for combined
- // stream, both are either pre-buffering or in the steady state. In either
- // case new pending bytes for proxy is the same as new pending bytes for
- // combined stream.
- // Note: use >= instead of ==, that way is safer.
- if (proxy_data->pending_bytes >= pending_bytes_)
- proxy_data->pending_bytes = buffers_state.pending_bytes;
-
- // Note: there is no way we can deduce hardware_delay_bytes for the
- // particular proxy stream. Use zero instead.
- uint32 actual_size = proxy_data->audio_source_callback->OnMoreData(
- actual_dest,
- max_size,
- AudioBuffersState(proxy_data->pending_bytes, 0));
- if (actual_size == 0)
- continue;
- double volume = proxy_data->volume;
-
- // Different handling for first and all subsequent streams.
- if (first_stream) {
- if (volume != 1.0) {
- media::AdjustVolume(actual_dest,
- actual_size,
- params_.channels(),
- bytes_per_sample,
- volume);
- }
- if (actual_size < max_size)
- memset(dest + actual_size, 0, max_size - actual_size);
- first_stream = false;
- actual_dest = mixer_data_.get();
- actual_total_size = actual_size;
- } else {
- media::MixStreams(dest,
- actual_dest,
- actual_size,
- bytes_per_sample,
- volume);
- actual_total_size = std::max(actual_size, actual_total_size);
- }
- }
-
- // Now go through all proxies once again and increase pending_bytes
- // for each proxy. Could not do it earlier because we did not know
- // actual_total_size.
- for (ProxyMap::iterator it = proxies_.begin(); it != proxies_.end(); ++it) {
- it->second.pending_bytes += actual_total_size;
- }
- pending_bytes_ = buffers_state.pending_bytes + actual_total_size;
-
- return actual_total_size;
-}
-
-void AudioOutputMixer::OnError(AudioOutputStream* stream, int code) {
- base::AutoLock lock(lock_);
- for (ProxyMap::iterator it = proxies_.begin(); it != proxies_.end(); ++it) {
- it->second.audio_source_callback->OnError(it->first, code);
- }
-}
-
-void AudioOutputMixer::WaitTillDataReady() {
- base::AutoLock lock(lock_);
- for (ProxyMap::iterator it = proxies_.begin(); it != proxies_.end(); ++it) {
- it->second.audio_source_callback->WaitTillDataReady();
- }
-}
-
-} // namespace media
diff --git a/media/audio/audio_output_mixer.h b/media/audio/audio_output_mixer.h
deleted file mode 100644
index 4ddeeef..0000000
--- a/media/audio/audio_output_mixer.h
+++ /dev/null
@@ -1,94 +0,0 @@
-// 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.
-
-// AudioOutputMixer is a class that implements browser-side audio mixer.
-// AudioOutputMixer implements both AudioOutputDispatcher and
-// AudioSourceCallback interfaces.
-
-#ifndef MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
-#define MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
-
-#include <map>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "base/synchronization/lock.h"
-#include "base/timer.h"
-#include "media/audio/audio_io.h"
-#include "media/audio/audio_manager.h"
-#include "media/audio/audio_output_dispatcher.h"
-#include "media/audio/audio_parameters.h"
-
-namespace media {
-
-class MEDIA_EXPORT AudioOutputMixer
- : public AudioOutputDispatcher,
- public AudioOutputStream::AudioSourceCallback {
- public:
- AudioOutputMixer(AudioManager* audio_manager,
- const AudioParameters& params,
- const base::TimeDelta& close_delay);
-
- // AudioOutputDispatcher interface.
- virtual bool OpenStream() OVERRIDE;
- virtual bool StartStream(AudioOutputStream::AudioSourceCallback* callback,
- AudioOutputProxy* stream_proxy) OVERRIDE;
- virtual void StopStream(AudioOutputProxy* stream_proxy) OVERRIDE;
- virtual void StreamVolumeSet(AudioOutputProxy* stream_proxy,
- double volume) OVERRIDE;
- virtual void CloseStream(AudioOutputProxy* stream_proxy) OVERRIDE;
- virtual void Shutdown() OVERRIDE;
-
- // AudioSourceCallback interface.
- virtual uint32 OnMoreData(uint8* dest,
- uint32 max_size,
- AudioBuffersState buffers_state) OVERRIDE;
- virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE;
- virtual void WaitTillDataReady() OVERRIDE;
-
- private:
- friend class base::RefCountedThreadSafe<AudioOutputMixer>;
- virtual ~AudioOutputMixer();
-
- // Called by |close_timer_|. Closes physical stream.
- void ClosePhysicalStream();
-
- // The |lock_| must be acquired whenever we modify |proxies_| in the audio
- // manager thread or accessing it in the hardware audio thread. Read in the
- // audio manager thread is safe.
- base::Lock lock_;
-
- // List of audio output proxies currently being played.
- // For every proxy we store aux structure containing data necessary for
- // mixing.
- struct ProxyData {
- AudioOutputStream::AudioSourceCallback* audio_source_callback;
- double volume;
- int pending_bytes;
- };
- typedef std::map<AudioOutputProxy*, ProxyData> ProxyMap;
- ProxyMap proxies_;
-
- // Physical stream for this mixer.
- scoped_ptr<AudioOutputStream> physical_stream_;
-
- // Temporary buffer used when mixing. Allocated in the constructor
- // to avoid constant allocation/deallocation in the callback.
- scoped_array<uint8> mixer_data_;
-
- // Used to post delayed tasks to ourselves that we cancel inside Shutdown().
- base::WeakPtrFactory<AudioOutputMixer> weak_this_;
- base::DelayTimer<AudioOutputMixer> close_timer_;
-
- // Size of data in all in-flight buffers.
- int pending_bytes_;
-
- DISALLOW_COPY_AND_ASSIGN(AudioOutputMixer);
-};
-
-} // namespace media
-
-#endif // MEDIA_AUDIO_AUDIO_OUTPUT_MIXER_H_
diff --git a/media/audio/audio_output_proxy_unittest.cc b/media/audio/audio_output_proxy_unittest.cc
index 6c13856..fdebdab 100644
--- a/media/audio/audio_output_proxy_unittest.cc
+++ b/media/audio/audio_output_proxy_unittest.cc
@@ -17,12 +17,6 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-// TODO(dalecurtis): Temporarily disabled while switching pipeline to use float,
-// http://crbug.com/114700
-#if defined(ENABLE_AUDIO_MIXER)
-#include "media/audio/audio_output_mixer.h"
-#endif
-
using ::testing::_;
using ::testing::AllOf;
using ::testing::DoAll;
@@ -169,9 +163,6 @@ class AudioOutputProxyTest : public testing::Test {
dispatcher_impl_ = new AudioOutputDispatcherImpl(&manager(),
params_,
close_delay);
-#if defined(ENABLE_AUDIO_MIXER)
- mixer_ = new AudioOutputMixer(&manager(), params_, close_delay);
-#endif
// Necessary to know how long the dispatcher will wait before posting
// StopStreamTask.
@@ -450,9 +441,6 @@ class AudioOutputProxyTest : public testing::Test {
MessageLoop message_loop_;
scoped_refptr<AudioOutputDispatcherImpl> dispatcher_impl_;
-#if defined(ENABLE_AUDIO_MIXER)
- scoped_refptr<AudioOutputMixer> mixer_;
-#endif
base::TimeDelta pause_delay_;
MockAudioManager manager_;
MockAudioSourceCallback callback_;
@@ -494,13 +482,6 @@ TEST_F(AudioOutputProxyTest, CreateAndClose) {
proxy->Close();
}
-#if defined(ENABLE_AUDIO_MIXER)
-TEST_F(AudioOutputProxyTest, CreateAndClose_Mixer) {
- AudioOutputProxy* proxy = new AudioOutputProxy(mixer_);
- proxy->Close();
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, CreateAndClose) {
AudioOutputProxy* proxy = new AudioOutputProxy(resampler_);
proxy->Close();
@@ -510,12 +491,6 @@ TEST_F(AudioOutputProxyTest, OpenAndClose) {
OpenAndClose(dispatcher_impl_);
}
-#if defined(ENABLE_AUDIO_MIXER)
-TEST_F(AudioOutputProxyTest, OpenAndClose_Mixer) {
- OpenAndClose(mixer_);
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, OpenAndClose) {
OpenAndClose(resampler_);
}
@@ -536,12 +511,6 @@ TEST_F(AudioOutputProxyTest, StartAndStop) {
StartAndStop(dispatcher_impl_);
}
-#if defined(ENABLE_AUDIO_MIXER)
-TEST_F(AudioOutputProxyTest, StartAndStop_Mixer) {
- StartAndStop(mixer_);
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, StartAndStop) {
StartAndStop(resampler_);
}
@@ -550,12 +519,6 @@ TEST_F(AudioOutputProxyTest, CloseAfterStop) {
CloseAfterStop(dispatcher_impl_);
}
-#if defined(ENABLE_AUDIO_MIXER)
-TEST_F(AudioOutputProxyTest, CloseAfterStop_Mixer) {
- CloseAfterStop(mixer_);
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, CloseAfterStop) {
CloseAfterStop(resampler_);
}
@@ -564,12 +527,6 @@ TEST_F(AudioOutputProxyTest, TwoStreams) {
TwoStreams(dispatcher_impl_);
}
-#if defined(ENABLE_AUDIO_MIXER)
-TEST_F(AudioOutputProxyTest, TwoStreams_Mixer) {
- TwoStreams(mixer_);
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, TwoStreams) {
TwoStreams(resampler_);
}
@@ -581,41 +538,6 @@ TEST_F(AudioOutputProxyTest, TwoStreams_OnePlaying) {
TwoStreams_OnePlaying(dispatcher_impl_);
}
-#if defined(ENABLE_AUDIO_MIXER)
-// Two streams: verify that only one device will be created.
-TEST_F(AudioOutputProxyTest, TwoStreams_OnePlaying_Mixer) {
- MockAudioOutputStream stream(&manager_, params_);
-
- InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs));
-
- EXPECT_CALL(manager(), MakeAudioOutputStream(_))
- .WillOnce(Return(&stream));
-
- EXPECT_CALL(stream, Open())
- .WillOnce(Return(true));
- EXPECT_CALL(stream, Start(_))
- .Times(1);
- EXPECT_CALL(stream, SetVolume(_))
- .Times(1);
- EXPECT_CALL(stream, Stop())
- .Times(1);
- EXPECT_CALL(stream, Close())
- .Times(1);
-
- AudioOutputProxy* proxy1 = new AudioOutputProxy(mixer_);
- AudioOutputProxy* proxy2 = new AudioOutputProxy(mixer_);
- EXPECT_TRUE(proxy1->Open());
- EXPECT_TRUE(proxy2->Open());
-
- proxy1->Start(&callback_);
- proxy1->Stop();
-
- proxy1->Close();
- proxy2->Close();
- WaitForCloseTimer(kTestCloseDelayMs);
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, TwoStreams_OnePlaying) {
InitDispatcher(base::TimeDelta::FromSeconds(kTestBigCloseDelaySeconds));
TwoStreams_OnePlaying(resampler_);
@@ -627,71 +549,6 @@ TEST_F(AudioOutputProxyTest, TwoStreams_BothPlaying) {
TwoStreams_BothPlaying(dispatcher_impl_);
}
-#if defined(ENABLE_AUDIO_MIXER)
-// Two streams, both are playing. Still have to use single device.
-// Also verifies that every proxy stream gets its own pending_bytes.
-TEST_F(AudioOutputProxyTest, TwoStreams_BothPlaying_Mixer) {
- MockAudioOutputStream stream(&manager_, params_);
-
- InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs));
-
- EXPECT_CALL(manager(), MakeAudioOutputStream(_))
- .WillOnce(Return(&stream));
-
- EXPECT_CALL(stream, Open())
- .WillOnce(Return(true));
- EXPECT_CALL(stream, Start(_))
- .Times(1);
- EXPECT_CALL(stream, SetVolume(_))
- .Times(1);
- EXPECT_CALL(stream, Stop())
- .Times(1);
- EXPECT_CALL(stream, Close())
- .Times(1);
-
- AudioOutputProxy* proxy1 = new AudioOutputProxy(mixer_);
- AudioOutputProxy* proxy2 = new AudioOutputProxy(mixer_);
- EXPECT_TRUE(proxy1->Open());
- EXPECT_TRUE(proxy2->Open());
-
- proxy1->Start(&callback_);
-
- // Mute the proxy. Resulting stream should still have correct length.
- proxy1->SetVolume(0.0);
-
- uint8 zeroes[4] = {0, 0, 0, 0};
- uint8 buf1[4] = {0};
- EXPECT_CALL(callback_,
- OnMoreData(NotNull(), 4,
- AllOf(Field(&AudioBuffersState::pending_bytes, 0),
- Field(&AudioBuffersState::hardware_delay_bytes, 0))))
- .WillOnce(DoAll(SetArrayArgument<0>(zeroes, zeroes + sizeof(zeroes)),
- Return(4)));
- mixer_->OnMoreData(buf1, sizeof(buf1), AudioBuffersState(0, 0));
- proxy2->Start(&callback_);
- uint8 buf2[4] = {0};
- EXPECT_CALL(callback_,
- OnMoreData(NotNull(), 4,
- AllOf(Field(&AudioBuffersState::pending_bytes, 4),
- Field(&AudioBuffersState::hardware_delay_bytes, 0))))
- .WillOnce(DoAll(SetArrayArgument<0>(zeroes, zeroes + sizeof(zeroes)),
- Return(4)));
- EXPECT_CALL(callback_,
- OnMoreData(NotNull(), 4,
- AllOf(Field(&AudioBuffersState::pending_bytes, 0),
- Field(&AudioBuffersState::hardware_delay_bytes, 0))))
- .WillOnce(DoAll(SetArrayArgument<0>(zeroes, zeroes + sizeof(zeroes)),
- Return(4)));
- mixer_->OnMoreData(buf2, sizeof(buf2), AudioBuffersState(4, 0));
- proxy1->Stop();
- proxy2->Stop();
-
- proxy1->Close();
- proxy2->Close();
- WaitForCloseTimer(kTestCloseDelayMs);
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, TwoStreams_BothPlaying) {
InitDispatcher(base::TimeDelta::FromSeconds(kTestBigCloseDelaySeconds));
TwoStreams_BothPlaying(resampler_);
@@ -701,12 +558,6 @@ TEST_F(AudioOutputProxyTest, OpenFailed) {
OpenFailed(dispatcher_impl_);
}
-#if defined(ENABLE_AUDIO_MIXER)
-TEST_F(AudioOutputProxyTest, OpenFailed_Mixer) {
- OpenFailed(mixer_);
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, OpenFailed) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableAudioFallback);
@@ -718,52 +569,6 @@ TEST_F(AudioOutputProxyTest, StartFailed) {
StartFailed(dispatcher_impl_);
}
-#if defined(ENABLE_AUDIO_MIXER)
-// Start() method failed.
-TEST_F(AudioOutputProxyTest, StartFailed_Mixer) {
- MockAudioOutputStream stream(&manager_, params_);
-
- EXPECT_CALL(manager(), MakeAudioOutputStream(_))
- .WillOnce(Return(&stream));
- EXPECT_CALL(stream, Open())
- .WillOnce(Return(true));
- EXPECT_CALL(stream, Close())
- .Times(1);
- EXPECT_CALL(stream, Start(_))
- .Times(1);
- EXPECT_CALL(stream, SetVolume(_))
- .Times(1);
- EXPECT_CALL(stream, Stop())
- .Times(1);
-
- AudioOutputProxy* proxy1 = new AudioOutputProxy(mixer_);
- AudioOutputProxy* proxy2 = new AudioOutputProxy(mixer_);
- EXPECT_TRUE(proxy1->Open());
- EXPECT_TRUE(proxy2->Open());
- proxy1->Start(&callback_);
- proxy1->Stop();
- proxy1->Close();
- WaitForCloseTimer(kTestCloseDelayMs);
-
- // Verify expectation before continueing.
- Mock::VerifyAndClear(&stream);
-
- // |stream| is closed at this point. Start() should reopen it again.
- EXPECT_CALL(manager(), MakeAudioOutputStream(_))
- .WillOnce(Return(reinterpret_cast<AudioOutputStream*>(NULL)));
-
- EXPECT_CALL(callback_, OnError(_, _))
- .Times(1);
-
- proxy2->Start(&callback_);
-
- Mock::VerifyAndClear(&callback_);
-
- proxy2->Close();
- WaitForCloseTimer(kTestCloseDelayMs);
-}
-#endif
-
TEST_F(AudioOutputResamplerTest, StartFailed) {
StartFailed(resampler_);
}
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc
index 4c446dd..7342801f 100644
--- a/media/audio/audio_util.cc
+++ b/media/audio/audio_util.cc
@@ -70,20 +70,6 @@ static void AdjustVolume(Format* buf_out,
}
}
-static const int kChannel_L = 0;
-static const int kChannel_R = 1;
-static const int kChannel_C = 2;
-
-template<class Fixed, int min_value, int max_value>
-static int AddSaturated(int val, int adder) {
- Fixed sum = static_cast<Fixed>(val) + static_cast<Fixed>(adder);
- if (sum > max_value)
- return max_value;
- if (sum < min_value)
- return min_value;
- return static_cast<int>(sum);
-}
-
// AdjustVolume() does an in place audio sample change.
bool AdjustVolume(void* buf,
size_t buflen,
@@ -122,72 +108,6 @@ bool AdjustVolume(void* buf,
return false;
}
-// TODO(enal): use template specialization and size-specific intrinsics.
-// Call is on the time-critical path, and by using SSE/AVX
-// instructions we can speed things up by ~4-8x, more for the case
-// when we have to adjust volume as well.
-template<class Format, class Fixed, int min_value, int max_value, int bias>
-static void MixStreams(Format* dst, Format* src, int count, float volume) {
- if (volume == 0.0f)
- return;
- if (volume == 1.0f) {
- // Most common case -- no need to adjust volume.
- for (int i = 0; i < count; ++i) {
- Fixed value = AddSaturated<Fixed, min_value, max_value>(dst[i] - bias,
- src[i] - bias);
- dst[i] = static_cast<Format>(value + bias);
- }
- } else {
- // General case -- have to adjust volume before mixing.
- const int fixed_volume = static_cast<int>(volume * 65536);
- for (int i = 0; i < count; ++i) {
- Fixed adjusted_src = ScaleChannel<Fixed>(src[i] - bias, fixed_volume);
- Fixed value = AddSaturated<Fixed, min_value, max_value>(dst[i] - bias,
- adjusted_src);
- dst[i] = static_cast<Format>(value + bias);
- }
- }
-}
-
-void MixStreams(void* dst,
- void* src,
- size_t buflen,
- int bytes_per_sample,
- float volume) {
- DCHECK(dst);
- DCHECK(src);
- DCHECK_GE(volume, 0.0f);
- DCHECK_LE(volume, 1.0f);
- switch (bytes_per_sample) {
- case 1:
- MixStreams<uint8, int32, kint8min, kint8max, 128>(
- static_cast<uint8*>(dst),
- static_cast<uint8*>(src),
- buflen,
- volume);
- break;
- case 2:
- DCHECK_EQ(0u, buflen % 2);
- MixStreams<int16, int32, kint16min, kint16max, 0>(
- static_cast<int16*>(dst),
- static_cast<int16*>(src),
- buflen / 2,
- volume);
- break;
- case 4:
- DCHECK_EQ(0u, buflen % 4);
- MixStreams<int32, int64, kint32min, kint32max, 0>(
- static_cast<int32*>(dst),
- static_cast<int32*>(src),
- buflen / 4,
- volume);
- break;
- default:
- NOTREACHED() << "Illegal bytes per sample";
- break;
- }
-}
-
int GetAudioHardwareSampleRate() {
#if defined(OS_MACOSX)
// Hardware sample-rate on the Mac can be configured, so we must query.
diff --git a/media/audio/audio_util.h b/media/audio/audio_util.h
index 18cda41..6067b21 100644
--- a/media/audio/audio_util.h
+++ b/media/audio/audio_util.h
@@ -39,15 +39,6 @@ MEDIA_EXPORT bool AdjustVolume(void* buf,
int bytes_per_sample,
float volume);
-// MixStreams() mixes 2 audio streams with same sample rate and number of
-// samples, adjusting volume on one of them.
-// Dst += Src * volume.
-MEDIA_EXPORT void MixStreams(void* dst,
- void* src,
- size_t buflen,
- int bytes_per_sample,
- float volume);
-
// Returns the default audio output hardware sample-rate.
MEDIA_EXPORT int GetAudioHardwareSampleRate();
diff --git a/media/audio/audio_util_unittest.cc b/media/audio/audio_util_unittest.cc
index 2643b99..679243c 100644
--- a/media/audio/audio_util_unittest.cc
+++ b/media/audio/audio_util_unittest.cc
@@ -79,86 +79,4 @@ TEST(AudioUtilTest, AdjustVolume_s32) {
EXPECT_EQ(0, expected_test);
}
-TEST(AudioUtilTest, MixStreams_u8_QuarterVolume) {
- // Test MixStreams() on 8 bit samples.
- uint8 dst_u8[kNumberOfSamples] = { 14, 0x44, 0x80, 0xff };
- uint8 src_u8[kNumberOfSamples] = { 4, 0x40, 0x80, 0xff };
- uint8 expected_u8[kNumberOfSamples] = { 0, /* saturation */
- (0x44 - 128) + (0x40 - 128) / 4 + 128,
- (0x80 - 128) + (0x80 - 128) / 4 + 128,
- 0xff /* saturation */ };
- media::MixStreams(dst_u8, src_u8, sizeof(dst_u8), sizeof(src_u8[0]), 0.25f);
- int expected_test = memcmp(dst_u8, expected_u8, sizeof(expected_u8));
- EXPECT_EQ(0, expected_test);
-}
-
-TEST(AudioUtilTest, MixStreams_u8_FullVolume) {
- // Test MixStreams() on 8 bit samples.
- uint8 dst_u8[kNumberOfSamples] = { 44, 0x44, 0x80, 0xff };
- uint8 src_u8[kNumberOfSamples] = { 4, 0x40, 0x80, 0xff };
- uint8 expected_u8[kNumberOfSamples] = { 0, /* saturation */
- (0x44 - 128) + (0x40 - 128) + 128,
- (0x80 - 128) + (0x80 - 128) + 128,
- 0xff /* saturation */ };
- media::MixStreams(dst_u8, src_u8, sizeof(dst_u8), sizeof(src_u8[0]), 1.0f);
- int expected_test = memcmp(dst_u8, expected_u8, sizeof(expected_u8));
- EXPECT_EQ(0, expected_test);
-}
-
-TEST(AudioUtilTest, MixStreams_s16_QuarterVolume) {
- // Test MixStreams() on 16 bit samples.
- int16 dst_s16[kNumberOfSamples] = { -4, 0x40, -32760, 32760 };
- int16 src_s16[kNumberOfSamples] = { -4, 0x40, -123, 123 };
- int16 expected_s16[kNumberOfSamples] = { -5, 0x50, -32768, 32767 };
- media::MixStreams(dst_s16,
- src_s16,
- sizeof(dst_s16),
- sizeof(src_s16[0]),
- 0.25f);
- int expected_test = memcmp(dst_s16, expected_s16, sizeof(expected_s16));
- EXPECT_EQ(0, expected_test);
-}
-
-TEST(AudioUtilTest, MixStreams_s16_FullVolume) {
- // Test MixStreams() on 16 bit samples.
- int16 dst_s16[kNumberOfSamples] = { -4, 0x40, -32760, 32760 };
- int16 src_s16[kNumberOfSamples] = { -4, 0x40, -123, 123 };
- int16 expected_s16[kNumberOfSamples] = { -8, 0x80, -32768, 32767 };
- media::MixStreams(dst_s16,
- src_s16,
- sizeof(dst_s16),
- sizeof(src_s16[0]),
- 1.0f);
- int expected_test = memcmp(dst_s16, expected_s16, sizeof(expected_s16));
- EXPECT_EQ(0, expected_test);
-}
-
-TEST(AudioUtilTest, MixStreams_s32_QuarterVolume) {
- // Test MixStreams() on 32 bit samples.
- int32 dst_s32[kNumberOfSamples] = { -4, 0x40, -32768, 2147483640 };
- int32 src_s32[kNumberOfSamples] = { -4, 0x40, -32768, 123 };
- int32 expected_s32[kNumberOfSamples] = { -5, 0x50, -40960, 2147483647 };
- media::MixStreams(dst_s32,
- src_s32,
- sizeof(dst_s32),
- sizeof(src_s32[0]),
- 0.25f);
- int expected_test = memcmp(dst_s32, expected_s32, sizeof(expected_s32));
- EXPECT_EQ(0, expected_test);
-}
-
-TEST(AudioUtilTest, MixStreams_s32_FullVolume) {
- // Test MixStreams() on 32 bit samples.
- int32 dst_s32[kNumberOfSamples] = { -4, 0x40, -32768, 2147483640 };
- int32 src_s32[kNumberOfSamples] = { -4, 0x40, -32768, 123 };
- int32 expected_s32[kNumberOfSamples] = { -8, 0x80, -65536, 2147483647 };
- media::MixStreams(dst_s32,
- src_s32,
- sizeof(dst_s32),
- sizeof(src_s32[0]),
- 1.0);
- int expected_test = memcmp(dst_s32, expected_s32, sizeof(expected_s32));
- EXPECT_EQ(0, expected_test);
-}
-
} // namespace media
diff --git a/media/media.gyp b/media/media.gyp
index cc8be41..e27e956 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -67,10 +67,6 @@
'audio/audio_input_device.h',
'audio/audio_input_ipc.cc',
'audio/audio_input_ipc.h',
- # TODO(dalecurtis): Temporarily disabled while switching pipeline to use
- # float, http://crbug.com/114700
- # 'audio/audio_output_mixer.cc',
- # 'audio/audio_output_mixer.h',
'audio/audio_input_stream_impl.cc',
'audio/audio_input_stream_impl.h',
'audio/audio_io.h',