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