OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "webkit/glue/webaudiodevice_impl.h" |
| 6 |
| 7 using WebKit::WebAudioDevice; |
| 8 using WebKit::WebVector; |
| 9 |
| 10 namespace webkit_glue { |
| 11 |
| 12 WebAudioDeviceImpl::WebAudioDeviceImpl(size_t buffer_size, |
| 13 int channels, |
| 14 double sample_rate, |
| 15 WebAudioDevice::RenderCallback* callback) |
| 16 : audio_device_(buffer_size, channels, sample_rate, this), |
| 17 client_callback_(callback) { |
| 18 } |
| 19 |
| 20 WebAudioDeviceImpl::~WebAudioDeviceImpl() { |
| 21 stop(); |
| 22 } |
| 23 |
| 24 void WebAudioDeviceImpl::start() { |
| 25 audio_device_.Start(); |
| 26 } |
| 27 |
| 28 void WebAudioDeviceImpl::stop() { |
| 29 audio_device_.Stop(); |
| 30 } |
| 31 |
| 32 void WebAudioDeviceImpl::Render(const std::vector<float*>& audio_data, |
| 33 size_t number_of_frames) { |
| 34 // Make the client callback to get rendered audio. |
| 35 DCHECK(client_callback_); |
| 36 if (client_callback_) { |
| 37 // Wrap the pointers using WebVector. |
| 38 WebVector<float*> web_audio_data(audio_data.size()); |
| 39 for (size_t i = 0; i < audio_data.size(); ++i) |
| 40 web_audio_data[i] = audio_data[i]; |
| 41 |
| 42 client_callback_->render(web_audio_data, number_of_frames); |
| 43 } |
| 44 } |
| 45 |
| 46 } // namespace webkit_glue |
OLD | NEW |