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

Side by Side Diff: content/renderer/media/render_audiosourceprovider.cc

Issue 10636036: Enable renderer side mixing behind a flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renderer Side Mixing! Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/render_audiosourceprovider.h" 5 #include "content/renderer/media/render_audiosourceprovider.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "content/renderer/media/audio_device_factory.h" 10 #include "content/renderer/media/audio_device_factory.h"
11 #include "content/renderer/media/audio_renderer_mixer_manager.h"
12 #include "content/renderer/render_thread_impl.h"
13 #include "media/base/audio_renderer_mixer_input.h"
14 #include "media/base/media_switches.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide rClient.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide rClient.h"
11 16
12 using content::AudioDeviceFactory; 17 using content::AudioDeviceFactory;
13 using std::vector; 18 using std::vector;
14 using WebKit::WebVector; 19 using WebKit::WebVector;
15 20
16 RenderAudioSourceProvider::RenderAudioSourceProvider() 21 RenderAudioSourceProvider::RenderAudioSourceProvider()
17 : is_initialized_(false), 22 : is_initialized_(false),
18 channels_(0), 23 channels_(0),
19 sample_rate_(0), 24 sample_rate_(0),
20 is_running_(false), 25 is_running_(false),
21 volume_(1.0), 26 volume_(1.0),
22 renderer_(NULL), 27 renderer_(NULL),
23 client_(NULL) { 28 client_(NULL) {
24 // We create the AudioDevice here using the factory. But we don't yet know 29 // Only process the command line switch once.
25 // the audio format (sample-rate, etc.) at this point. Later, when 30 static int enable_render_side_mixing = -1;
scherkus (not reviewing) 2012/07/13 18:40:16 don't worry about optimizing the switch lookup on
DaleCurtis 2012/07/13 21:28:33 Done.
26 // Initialize() is called, we have the audio format information and call 31 if (enable_render_side_mixing < 0) {
27 // the AudioDevice::Initialize() method to fully initialize it. 32 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
28 default_sink_ = AudioDeviceFactory::Create(); 33 enable_render_side_mixing = static_cast<int>(cmd_line->HasSwitch(
34 switches::kEnableRendererSideMixing));
35 }
36
37 // We create an AudioRendererSink here, but we don't yet know the audio format
38 // (sample-rate, etc.) at this point. Later, when Initialize() is called, we
39 // have the audio format information and call AudioRendererSink::Initialize()
40 // to fully initialize it.
41 if (!enable_render_side_mixing) {
42 default_sink_ = AudioDeviceFactory::Create();
43 } else {
44 default_sink_ = RenderThreadImpl::current()->
45 audio_renderer_mixer_manager()->CreateInput();
46 }
29 } 47 }
30 48
31 void RenderAudioSourceProvider::setClient( 49 void RenderAudioSourceProvider::setClient(
32 WebKit::WebAudioSourceProviderClient* client) { 50 WebKit::WebAudioSourceProviderClient* client) {
33 // Synchronize with other uses of client_ and default_sink_. 51 // Synchronize with other uses of client_ and default_sink_.
34 base::AutoLock auto_lock(sink_lock_); 52 base::AutoLock auto_lock(sink_lock_);
35 53
36 if (client && client != client_) { 54 if (client && client != client_) {
37 // Detach the audio renderer from normal playback. 55 // Detach the audio renderer from normal playback.
38 default_sink_->Stop(); 56 default_sink_->Stop();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 158
141 if (client_) { 159 if (client_) {
142 // Inform WebKit about the audio stream format. 160 // Inform WebKit about the audio stream format.
143 client_->setFormat(channels_, sample_rate_); 161 client_->setFormat(channels_, sample_rate_);
144 } 162 }
145 163
146 is_initialized_ = true; 164 is_initialized_ = true;
147 } 165 }
148 166
149 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} 167 RenderAudioSourceProvider::~RenderAudioSourceProvider() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698