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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 int RendererWebAudioDeviceImpl::Render(base::TimeDelta delay, | 104 int RendererWebAudioDeviceImpl::Render(base::TimeDelta delay, |
105 base::TimeTicks delay_timestamp, | 105 base::TimeTicks delay_timestamp, |
106 int prior_frames_skipped, | 106 int prior_frames_skipped, |
107 media::AudioBus* dest) { | 107 media::AudioBus* dest) { |
108 // Wrap the output pointers using WebVector. | 108 // Wrap the output pointers using WebVector. |
109 WebVector<float*> web_audio_dest_data(static_cast<size_t>(dest->channels())); | 109 WebVector<float*> web_audio_dest_data(static_cast<size_t>(dest->channels())); |
110 for (int i = 0; i < dest->channels(); ++i) | 110 for (int i = 0; i < dest->channels(); ++i) |
111 web_audio_dest_data[i] = dest->channel(i); | 111 web_audio_dest_data[i] = dest->channel(i); |
112 | 112 |
| 113 if (!delay.is_zero()) { // Zero values are send at the first call. |
| 114 // Substruct the bus duration to get hardware delay. |
| 115 delay -= media::AudioTimestampHelper::FramesToTime(dest->frames(), |
| 116 params_.sample_rate()); |
| 117 } |
| 118 DCHECK_GE(delay, base::TimeDelta()); |
| 119 |
113 // TODO(xians): Remove the following |web_audio_source_data| after | 120 // TODO(xians): Remove the following |web_audio_source_data| after |
114 // changing the blink interface. | 121 // changing the blink interface. |
115 WebVector<float*> web_audio_source_data(static_cast<size_t>(0)); | 122 WebVector<float*> web_audio_source_data(static_cast<size_t>(0)); |
116 client_callback_->render(web_audio_source_data, web_audio_dest_data, | 123 client_callback_->render(web_audio_source_data, web_audio_dest_data, |
117 dest->frames()); | 124 dest->frames(), delay.InSecondsF(), |
| 125 (delay_timestamp - base::TimeTicks()).InSecondsF(), |
| 126 prior_frames_skipped); |
| 127 |
118 return dest->frames(); | 128 return dest->frames(); |
119 } | 129 } |
120 | 130 |
121 void RendererWebAudioDeviceImpl::OnRenderError() { | 131 void RendererWebAudioDeviceImpl::OnRenderError() { |
122 // TODO(crogers): implement error handling. | 132 // TODO(crogers): implement error handling. |
123 } | 133 } |
124 | 134 |
125 } // namespace content | 135 } // namespace content |
OLD | NEW |