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/renderer_webaudiodevice_impl.h" | 5 #include "content/renderer/media/renderer_webaudiodevice_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/renderer/media/audio_device_factory.h" | 8 #include "content/renderer/media/audio_device_factory.h" |
9 | 9 |
10 using content::AudioDeviceFactory; | 10 using content::AudioDeviceFactory; |
(...skipping 24 matching lines...) Expand all Loading... |
35 if (is_running_) { | 35 if (is_running_) { |
36 audio_device_->Stop(); | 36 audio_device_->Stop(); |
37 is_running_ = false; | 37 is_running_ = false; |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 double RendererWebAudioDeviceImpl::sampleRate() { | 41 double RendererWebAudioDeviceImpl::sampleRate() { |
42 return 44100.0; | 42 return 44100.0; |
43 } | 43 } |
44 | 44 |
45 int RendererWebAudioDeviceImpl::Render(const std::vector<float*>& audio_data, | 45 int RendererWebAudioDeviceImpl::Render(media::AudioBus* audio_bus, |
46 int number_of_frames, | 46 int number_of_frames, |
47 int audio_delay_milliseconds) { | 47 int audio_delay_milliseconds) { |
48 // Make the client callback to get rendered audio. | 48 // Make the client callback to get rendered audio. |
49 DCHECK(client_callback_); | 49 DCHECK(client_callback_); |
50 if (client_callback_) { | 50 if (client_callback_) { |
51 // Wrap the pointers using WebVector. | 51 // Wrap the pointers using WebVector. |
52 WebVector<float*> web_audio_data(audio_data.size()); | 52 WebVector<float*> web_audio_data( |
53 for (size_t i = 0; i < audio_data.size(); ++i) | 53 static_cast<size_t>(audio_bus->channels())); |
54 web_audio_data[i] = audio_data[i]; | 54 for (int i = 0; i < audio_bus->channels(); ++i) |
| 55 web_audio_data[i] = audio_bus->channel(i); |
55 | 56 |
56 client_callback_->render(web_audio_data, number_of_frames); | 57 client_callback_->render(web_audio_data, number_of_frames); |
57 } | 58 } |
58 return number_of_frames; | 59 return number_of_frames; |
59 } | 60 } |
60 | 61 |
61 void RendererWebAudioDeviceImpl::OnRenderError() { | 62 void RendererWebAudioDeviceImpl::OnRenderError() { |
62 // TODO(crogers): implement error handling. | 63 // TODO(crogers): implement error handling. |
63 } | 64 } |
OLD | NEW |