| OLD | NEW |
| 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" |
| 10 #include "content/public/common/content_switches.h" |
| 9 #include "content/renderer/media/audio_device_factory.h" | 11 #include "content/renderer/media/audio_device_factory.h" |
| 12 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
| 13 #include "content/renderer/render_thread_impl.h" |
| 14 #include "media/base/audio_renderer_mixer_input.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; |
| 18 using content::AudioRendererMixerManager; |
| 13 using std::vector; | 19 using std::vector; |
| 14 using WebKit::WebVector; | 20 using WebKit::WebVector; |
| 15 | 21 |
| 16 RenderAudioSourceProvider::RenderAudioSourceProvider() | 22 RenderAudioSourceProvider::RenderAudioSourceProvider() |
| 17 : is_initialized_(false), | 23 : is_initialized_(false), |
| 18 channels_(0), | 24 channels_(0), |
| 19 sample_rate_(0), | 25 sample_rate_(0), |
| 20 is_running_(false), | 26 is_running_(false), |
| 21 volume_(1.0), | 27 volume_(1.0), |
| 22 renderer_(NULL), | 28 renderer_(NULL), |
| 23 client_(NULL) { | 29 client_(NULL) { |
| 24 // We create the AudioDevice here using the factory. But we don't yet know | 30 // We create an AudioRendererSink here, but we don't yet know the audio format |
| 25 // the audio format (sample-rate, etc.) at this point. Later, when | 31 // (sample-rate, etc.) at this point. Later, when Initialize() is called, we |
| 26 // Initialize() is called, we have the audio format information and call | 32 // have the audio format information and call AudioRendererSink::Initialize() |
| 27 // the AudioDevice::Initialize() method to fully initialize it. | 33 // to fully initialize it. |
| 28 default_sink_ = AudioDeviceFactory::Create(); | 34 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 35 if (cmd_line->HasSwitch(switches::kEnableRendererSideMixing)) { |
| 36 default_sink_ = RenderThreadImpl::current()-> |
| 37 audio_renderer_mixer_manager()->CreateInput(); |
| 38 } else { |
| 39 default_sink_ = AudioDeviceFactory::Create(); |
| 40 } |
| 29 } | 41 } |
| 30 | 42 |
| 31 void RenderAudioSourceProvider::setClient( | 43 void RenderAudioSourceProvider::setClient( |
| 32 WebKit::WebAudioSourceProviderClient* client) { | 44 WebKit::WebAudioSourceProviderClient* client) { |
| 33 // Synchronize with other uses of client_ and default_sink_. | 45 // Synchronize with other uses of client_ and default_sink_. |
| 34 base::AutoLock auto_lock(sink_lock_); | 46 base::AutoLock auto_lock(sink_lock_); |
| 35 | 47 |
| 36 if (client && client != client_) { | 48 if (client && client != client_) { |
| 37 // Detach the audio renderer from normal playback. | 49 // Detach the audio renderer from normal playback. |
| 38 default_sink_->Stop(); | 50 default_sink_->Stop(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 152 |
| 141 if (client_) { | 153 if (client_) { |
| 142 // Inform WebKit about the audio stream format. | 154 // Inform WebKit about the audio stream format. |
| 143 client_->setFormat(channels_, sample_rate_); | 155 client_->setFormat(channels_, sample_rate_); |
| 144 } | 156 } |
| 145 | 157 |
| 146 is_initialized_ = true; | 158 is_initialized_ = true; |
| 147 } | 159 } |
| 148 | 160 |
| 149 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} | 161 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} |
| OLD | NEW |