Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(558)

Unified Diff: media/audio/audio_manager_base.cc

Issue 10918098: Introduce AudioOutputResampler for browser side resampling. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | media/audio/audio_output_proxy_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_manager_base.cc
diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc
index 7e5cc43afc7d9b1f152d9ac54d8fdcdde82c86ec..1d8a4540f988c41a38f8b5f09b7e27cb05f42cdb 100644
--- a/media/audio/audio_manager_base.cc
+++ b/media/audio/audio_manager_base.cc
@@ -10,6 +10,8 @@
#include "base/threading/thread.h"
#include "media/audio/audio_output_dispatcher_impl.h"
#include "media/audio/audio_output_proxy.h"
+#include "media/audio/audio_output_resampler.h"
+#include "media/audio/audio_util.h"
#include "media/audio/fake_audio_input_stream.h"
#include "media/audio/fake_audio_output_stream.h"
#include "media/base/media_switches.h"
@@ -147,22 +149,39 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
#else
DCHECK(GetMessageLoop()->BelongsToCurrentThread());
- scoped_refptr<AudioOutputDispatcher>& dispatcher =
- output_dispatchers_[params];
- if (!dispatcher) {
- base::TimeDelta close_delay =
- base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds);
- // 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
+ AudioOutputDispatchersMap::iterator it = output_dispatchers_.find(params);
+ if (it != output_dispatchers_.end())
+ return new AudioOutputProxy(it->second);
+
+ base::TimeDelta close_delay =
+ base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds);
+
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+ if (cmd_line->HasSwitch(switches::kEnableAudioOutputResampler) &&
+ params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) {
+ scoped_refptr<AudioOutputDispatcher> dispatcher = new AudioOutputResampler(
+ this, params,
+ GetPreferredLowLatencyOutputStreamParameters(params.channel_layout()),
+ close_delay);
+ output_dispatchers_[params] = dispatcher;
+ return new AudioOutputProxy(dispatcher);
+ }
+
#if defined(ENABLE_AUDIO_MIXER)
- const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
- if (cmd_line->HasSwitch(switches::kEnableAudioMixer))
- dispatcher = new AudioOutputMixer(this, params, close_delay);
- else
-#endif
- dispatcher = new AudioOutputDispatcherImpl(this, params, close_delay);
+ // 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_[params] = dispatcher;
+ return new AudioOutputProxy(dispatcher);
}
+#endif
+
+ scoped_refptr<AudioOutputDispatcher> dispatcher =
+ new AudioOutputDispatcherImpl(this, params, close_delay);
+ output_dispatchers_[params] = dispatcher;
return new AudioOutputProxy(dispatcher);
#endif // defined(OS_IOS)
}
@@ -259,4 +278,13 @@ void AudioManagerBase::ShutdownOnAudioThread() {
#endif // defined(OS_IOS)
}
+AudioParameters AudioManagerBase::GetPreferredLowLatencyOutputStreamParameters(
+ ChannelLayout channel_layout) {
+ // TODO(dalecurtis): This should include bits per channel and channel layout
+ // eventually.
+ return AudioParameters(
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
+ GetAudioHardwareSampleRate(), 16, GetAudioHardwareBufferSize());
+}
+
} // namespace media
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | media/audio/audio_output_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698