Chromium Code Reviews| 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/audio_renderer_impl.h" | 5 #include "content/renderer/media/audio_renderer_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 static_cast<int64>(ceil(request_delay.InMicroseconds() * | 211 static_cast<int64>(ceil(request_delay.InMicroseconds() * |
| 212 GetPlaybackRate()))); | 212 GetPlaybackRate()))); |
| 213 } | 213 } |
| 214 | 214 |
| 215 uint32 bytes_per_frame = | 215 uint32 bytes_per_frame = |
| 216 audio_parameters_.bits_per_sample * audio_parameters_.channels / 8; | 216 audio_parameters_.bits_per_sample * audio_parameters_.channels / 8; |
| 217 | 217 |
| 218 const size_t buf_size = number_of_frames * bytes_per_frame; | 218 const size_t buf_size = number_of_frames * bytes_per_frame; |
| 219 scoped_array<uint8> buf(new uint8[buf_size]); | 219 scoped_array<uint8> buf(new uint8[buf_size]); |
| 220 | 220 |
| 221 uint32 filled = FillBuffer(buf.get(), buf_size, request_delay); | 221 uint32 filled_frames = FillBuffer(buf.get(), number_of_frames, request_delay); |
|
acolwell GONE FROM CHROMIUM
2012/02/22 07:51:40
nit: rename frames_filled to be consistent with by
vrk (LEFT CHROMIUM)
2012/02/23 20:33:06
Done.
| |
| 222 DCHECK_LE(filled, buf_size); | 222 uint32 bytes_filled = filled_frames * bytes_per_frame; |
| 223 UpdateEarliestEndTime(filled, request_delay, base::Time::Now()); | 223 DCHECK_LE(bytes_filled, buf_size); |
| 224 | 224 UpdateEarliestEndTime(bytes_filled, request_delay, base::Time::Now()); |
| 225 uint32 filled_frames = filled / bytes_per_frame; | |
| 226 | 225 |
| 227 // Deinterleave each audio channel. | 226 // Deinterleave each audio channel. |
| 228 int channels = audio_data.size(); | 227 int channels = audio_data.size(); |
| 229 for (int channel_index = 0; channel_index < channels; ++channel_index) { | 228 for (int channel_index = 0; channel_index < channels; ++channel_index) { |
| 230 media::DeinterleaveAudioChannel(buf.get(), | 229 media::DeinterleaveAudioChannel(buf.get(), |
| 231 audio_data[channel_index], | 230 audio_data[channel_index], |
| 232 channels, | 231 channels, |
| 233 channel_index, | 232 channel_index, |
| 234 bytes_per_frame / channels, | 233 bytes_per_frame / channels, |
| 235 filled_frames); | 234 filled_frames); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 247 | 246 |
| 248 void AudioRendererImpl::OnRenderError() { | 247 void AudioRendererImpl::OnRenderError() { |
| 249 host()->DisableAudioRenderer(); | 248 host()->DisableAudioRenderer(); |
| 250 } | 249 } |
| 251 | 250 |
| 252 void AudioRendererImpl::OnRenderEndOfStream() { | 251 void AudioRendererImpl::OnRenderEndOfStream() { |
| 253 // TODO(enal): schedule callback instead of polling. | 252 // TODO(enal): schedule callback instead of polling. |
| 254 if (base::Time::Now() >= earliest_end_time_) | 253 if (base::Time::Now() >= earliest_end_time_) |
| 255 SignalEndOfStream(); | 254 SignalEndOfStream(); |
| 256 } | 255 } |
| OLD | NEW |