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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/renderer/media/audio_device_factory.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
rClient.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
rClient.h" |
10 | 11 |
| 12 using content::AudioDeviceFactory; |
11 using std::vector; | 13 using std::vector; |
12 using WebKit::WebVector; | 14 using WebKit::WebVector; |
13 | 15 |
14 RenderAudioSourceProvider::RenderAudioSourceProvider() | 16 RenderAudioSourceProvider::RenderAudioSourceProvider() |
15 : is_initialized_(false), | 17 : is_initialized_(false), |
16 channels_(0), | 18 channels_(0), |
17 sample_rate_(0), | 19 sample_rate_(0), |
18 is_running_(false), | 20 is_running_(false), |
19 volume_(1.0), | 21 volume_(1.0), |
20 renderer_(NULL), | 22 renderer_(NULL), |
21 client_(NULL) { | 23 client_(NULL) { |
22 // We create the AudioDevice here because it must be created in the | 24 // We create the AudioDevice here using the factory. But we don't yet know |
23 // main thread. But we don't yet know the audio format (sample-rate, etc.) | 25 // the audio format (sample-rate, etc.) at this point. Later, when |
24 // at this point. Later, when Initialize() is called, we have | 26 // Initialize() is called, we have the audio format information and call |
25 // the audio format information and call the AudioDevice::Initialize() | 27 // the AudioDevice::Initialize() method to fully initialize it. |
26 // method to fully initialize it. | 28 default_sink_ = AudioDeviceFactory::Create(); |
27 default_sink_ = new AudioDevice(); | |
28 } | 29 } |
29 | 30 |
30 void RenderAudioSourceProvider::setClient( | 31 void RenderAudioSourceProvider::setClient( |
31 WebKit::WebAudioSourceProviderClient* client) { | 32 WebKit::WebAudioSourceProviderClient* client) { |
32 // Synchronize with other uses of client_ and default_sink_. | 33 // Synchronize with other uses of client_ and default_sink_. |
33 base::AutoLock auto_lock(sink_lock_); | 34 base::AutoLock auto_lock(sink_lock_); |
34 | 35 |
35 if (client && client != client_) { | 36 if (client && client != client_) { |
36 // Detach the audio renderer from normal playback. | 37 // Detach the audio renderer from normal playback. |
37 default_sink_->Stop(); | 38 default_sink_->Stop(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 140 |
140 if (client_) { | 141 if (client_) { |
141 // Inform WebKit about the audio stream format. | 142 // Inform WebKit about the audio stream format. |
142 client_->setFormat(channels_, sample_rate_); | 143 client_->setFormat(channels_, sample_rate_); |
143 } | 144 } |
144 | 145 |
145 is_initialized_ = true; | 146 is_initialized_ = true; |
146 } | 147 } |
147 | 148 |
148 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} | 149 RenderAudioSourceProvider::~RenderAudioSourceProvider() {} |
OLD | NEW |