Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(852)

Side by Side Diff: content/renderer/media/audio_renderer_impl.cc

Issue 8686010: <video> decode in hardware! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop INTRA/CONSTRAINED in profile, add missing 'virtual', add MEDIA_EXPORT, fix RemoveFilter loop Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 void AudioRendererImpl::Render(const std::vector<float*>& audio_data, 195 void AudioRendererImpl::Render(const std::vector<float*>& audio_data,
196 size_t number_of_frames, 196 size_t number_of_frames,
197 size_t audio_delay_milliseconds) { 197 size_t audio_delay_milliseconds) {
198 if (stopped_ || GetPlaybackRate() == 0.0f) { 198 if (stopped_ || GetPlaybackRate() == 0.0f) {
199 // Output silence if stopped. 199 // Output silence if stopped.
200 for (size_t i = 0; i < audio_data.size(); ++i) 200 for (size_t i = 0; i < audio_data.size(); ++i)
201 memset(audio_data[i], 0, sizeof(float) * number_of_frames); 201 memset(audio_data[i], 0, sizeof(float) * number_of_frames);
202 return; 202 return;
203 } 203 }
204 204
205 // Adjust the playback delay.
206 base::Time current_time = base::Time::Now();
207
208 base::TimeDelta request_delay = 205 base::TimeDelta request_delay =
209 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds); 206 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds);
210 207
211 // Finally we need to adjust the delay according to playback rate. 208 // Finally we need to adjust the delay according to playback rate.
212 if (GetPlaybackRate() != 1.0f) { 209 if (GetPlaybackRate() != 1.0f) {
213 request_delay = base::TimeDelta::FromMicroseconds( 210 request_delay = base::TimeDelta::FromMicroseconds(
214 static_cast<int64>(ceil(request_delay.InMicroseconds() * 211 static_cast<int64>(ceil(request_delay.InMicroseconds() *
215 GetPlaybackRate()))); 212 GetPlaybackRate())));
216 } 213 }
217 214
(...skipping 22 matching lines...) Expand all
240 bytes_per_frame / channels, 237 bytes_per_frame / channels,
241 filled_frames); 238 filled_frames);
242 239
243 // If FillBuffer() didn't give us enough data then zero out the remainder. 240 // If FillBuffer() didn't give us enough data then zero out the remainder.
244 if (filled_frames < number_of_frames) { 241 if (filled_frames < number_of_frames) {
245 int frames_to_zero = number_of_frames - filled_frames; 242 int frames_to_zero = number_of_frames - filled_frames;
246 memset(audio_data[channel_index], 0, sizeof(float) * frames_to_zero); 243 memset(audio_data[channel_index], 0, sizeof(float) * frames_to_zero);
247 } 244 }
248 } 245 }
249 } 246 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698