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