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

Side by Side Diff: media/filters/audio_renderer_algorithm_base.cc

Issue 9395057: Fix muted audio when playback rate != 1.0 or 0.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT and issue 9442005 Created 8 years, 10 months 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) 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 "media/filters/audio_renderer_algorithm_base.h" 5 #include "media/filters/audio_renderer_algorithm_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 23 matching lines...) Expand all
34 // Audio at these speeds would sound better under a frequency domain algorithm. 34 // Audio at these speeds would sound better under a frequency domain algorithm.
35 static const float kMinPlaybackRate = 0.5f; 35 static const float kMinPlaybackRate = 0.5f;
36 static const float kMaxPlaybackRate = 4.0f; 36 static const float kMaxPlaybackRate = 4.0f;
37 37
38 AudioRendererAlgorithmBase::AudioRendererAlgorithmBase() 38 AudioRendererAlgorithmBase::AudioRendererAlgorithmBase()
39 : channels_(0), 39 : channels_(0),
40 samples_per_second_(0), 40 samples_per_second_(0),
41 bytes_per_channel_(0), 41 bytes_per_channel_(0),
42 playback_rate_(0.0f), 42 playback_rate_(0.0f),
43 audio_buffer_(0, kStartingBufferSizeInBytes), 43 audio_buffer_(0, kStartingBufferSizeInBytes),
44 crossfade_size_(0), 44 bytes_in_crossfade_(0),
45 bytes_per_frame_(0),
46 index_into_window_(0),
47 crossfade_frame_number_(0),
48 muted_(false),
49 needs_more_data_(false),
45 window_size_(0) { 50 window_size_(0) {
46 } 51 }
47 52
48 AudioRendererAlgorithmBase::~AudioRendererAlgorithmBase() {} 53 AudioRendererAlgorithmBase::~AudioRendererAlgorithmBase() {}
49 54
50 bool AudioRendererAlgorithmBase::ValidateConfig( 55 bool AudioRendererAlgorithmBase::ValidateConfig(
51 int channels, 56 int channels,
52 int samples_per_second, 57 int samples_per_second,
53 int bits_per_channel) { 58 int bits_per_channel) {
54 bool status = true; 59 bool status = true;
(...skipping 22 matching lines...) Expand all
77 int samples_per_second, 82 int samples_per_second,
78 int bits_per_channel, 83 int bits_per_channel,
79 float initial_playback_rate, 84 float initial_playback_rate,
80 const base::Closure& callback) { 85 const base::Closure& callback) {
81 DCHECK(!callback.is_null()); 86 DCHECK(!callback.is_null());
82 DCHECK(ValidateConfig(channels, samples_per_second, bits_per_channel)); 87 DCHECK(ValidateConfig(channels, samples_per_second, bits_per_channel));
83 88
84 channels_ = channels; 89 channels_ = channels;
85 samples_per_second_ = samples_per_second; 90 samples_per_second_ = samples_per_second;
86 bytes_per_channel_ = bits_per_channel / 8; 91 bytes_per_channel_ = bits_per_channel / 8;
92 bytes_per_frame_ = bytes_per_channel_ * channels_;
87 request_read_cb_ = callback; 93 request_read_cb_ = callback;
88 SetPlaybackRate(initial_playback_rate); 94 SetPlaybackRate(initial_playback_rate);
89 95
90 window_size_ = 96 window_size_ =
91 samples_per_second_ * bytes_per_channel_ * channels_ * kWindowDuration; 97 samples_per_second_ * bytes_per_channel_ * channels_ * kWindowDuration;
92 AlignToSampleBoundary(&window_size_); 98 AlignToFrameBoundary(&window_size_);
93 99
94 crossfade_size_ = 100 bytes_in_crossfade_ =
95 samples_per_second_ * bytes_per_channel_ * channels_ * kCrossfadeDuration; 101 samples_per_second_ * bytes_per_channel_ * channels_ * kCrossfadeDuration;
96 AlignToSampleBoundary(&crossfade_size_); 102 AlignToFrameBoundary(&bytes_in_crossfade_);
97 } 103
98 104 crossfade_buffer_.reset(new uint8[bytes_in_crossfade_]);
99 uint32 AudioRendererAlgorithmBase::FillBuffer(uint8* dest, uint32 length) { 105 }
100 if (IsQueueEmpty() || playback_rate_ == 0.0f) 106
107 uint32 AudioRendererAlgorithmBase::FillBuffer(
108 uint8* dest, uint32 requested_frames) {
109 DCHECK_NE(bytes_per_frame_, 0u);
110
111 if (playback_rate_ == 0.0f)
101 return 0; 112 return 0;
102 113
103 // Handle the simple case of normal playback. 114 uint32 total_frames_rendered = 0;
104 if (playback_rate_ == 1.0f) {
105 uint32 bytes_written =
106 CopyFromAudioBuffer(dest, std::min(length, bytes_buffered()));
107 AdvanceBufferPosition(bytes_written);
108 return bytes_written;
109 }
110
111 // Output muted data when out of acceptable quality range.
112 if (playback_rate_ < kMinPlaybackRate || playback_rate_ > kMaxPlaybackRate)
113 return MuteBuffer(dest, length);
114
115 uint32 input_step = window_size_;
116 uint32 output_step = window_size_;
117
118 if (playback_rate_ > 1.0f) {
119 // Playback is faster than normal; need to squish output!
120 output_step = ceil(window_size_ / playback_rate_);
121 } else {
122 // Playback is slower than normal; need to stretch input!
123 input_step = ceil(window_size_ * playback_rate_);
124 }
125
126 AlignToSampleBoundary(&input_step);
127 AlignToSampleBoundary(&output_step);
128 DCHECK_LE(crossfade_size_, input_step);
129 DCHECK_LE(crossfade_size_, output_step);
130
131 uint32 bytes_written = 0;
132 uint32 bytes_left_to_output = length;
133 uint8* output_ptr = dest; 115 uint8* output_ptr = dest;
134 116 while(total_frames_rendered < requested_frames) {
acolwell GONE FROM CHROMIUM 2012/02/24 00:48:33 nit: space after while.
vrk (LEFT CHROMIUM) 2012/02/27 18:19:13 Done.
135 // TODO(vrk): The while loop and if test below are lame! We are requiring the 117 if (index_into_window_ == window_size_)
136 // client to provide us with enough data to output only complete crossfaded 118 ResetWindow();
137 // windows. Instead, we should output as much data as we can, and add state to 119
138 // keep track of what point in the crossfade we are at. 120 bool rendered_frame = true;
139 // This is also the cause of crbug.com/108239. 121 if (playback_rate_ > 1.0)
140 while (bytes_left_to_output >= output_step) { 122 rendered_frame = OutputFasterPlayback(output_ptr);
141 // If there is not enough data buffered to complete an iteration of the 123 else if (playback_rate_ < 1.0)
142 // loop, mute the remaining and break. 124 rendered_frame = OutputSlowerPlayback(output_ptr);
143 if (bytes_buffered() < window_size_) { 125 else
144 bytes_written += MuteBuffer(output_ptr, bytes_left_to_output); 126 rendered_frame = OutputNormalPlayback(output_ptr);
127
128 if (!rendered_frame) {
129 needs_more_data_ = true;
145 break; 130 break;
146 } 131 }
147 132
148 // Copy |output_step| bytes into destination buffer. 133 output_ptr += bytes_per_frame_;
149 uint32 copied = CopyFromAudioBuffer(output_ptr, output_step); 134 total_frames_rendered++;
150 DCHECK_EQ(copied, output_step); 135 }
151 output_ptr += output_step; 136 return total_frames_rendered;
152 bytes_written += copied; 137 }
153 bytes_left_to_output -= copied; 138
154 139 void AudioRendererAlgorithmBase::ResetWindow() {
155 // Copy the |crossfade_size_| bytes leading up to the next window that will 140 DCHECK_LE(index_into_window_, window_size_);
156 // be played into an intermediate buffer. This will be used to crossfade 141 index_into_window_ = 0;
157 // from the current window to the next. 142 crossfade_frame_number_ = 0;
158 AdvanceBufferPosition(input_step - crossfade_size_); 143 muted_ = false;
159 scoped_array<uint8> next_window_intro(new uint8[crossfade_size_]); 144 }
160 uint32 bytes_copied = 145
161 CopyFromAudioBuffer(next_window_intro.get(), crossfade_size_); 146 bool AudioRendererAlgorithmBase::OutputFasterPlayback(uint8* dest) {
162 DCHECK_EQ(bytes_copied, crossfade_size_); 147 DCHECK_LT(index_into_window_, window_size_);
163 AdvanceBufferPosition(crossfade_size_); 148 DCHECK_GT(playback_rate_, 1.0);
164 149
165 // Prepare pointers to end of the current window and the start of the next 150 if (audio_buffer_.forward_bytes() < bytes_per_frame_)
166 // window. 151 return false;
167 uint8* start_of_outro = output_ptr - crossfade_size_; 152
168 const uint8* start_of_intro = next_window_intro.get(); 153 if (playback_rate_ > kMaxPlaybackRate)
169 154 muted_ = true;
170 // Do crossfade! 155
171 Crossfade(crossfade_size_, channels_, bytes_per_channel_, 156 // The audio data is output in a series of windows. For sped-up playback,
172 start_of_intro, start_of_outro); 157 // the window is comprised of the following phases:
173 } 158 //
174 159 // a) Output raw data.
175 return bytes_written; 160 // b) Save bytes for crossfade in |crossfade_buffer_|.
176 } 161 // c) Drop data.
177 162 // d) Output crossfaded audio leading up to the next window.
178 uint32 AudioRendererAlgorithmBase::MuteBuffer(uint8* dest, uint32 length) { 163 //
164 // The duration of each phase is computed below based on the |window_size_|
165 // and |playback_rate_|.
166 uint32 input_step = window_size_;
167 uint32 output_step = ceil(window_size_ / playback_rate_);
168 AlignToFrameBoundary(&output_step);
169 DCHECK_GT(input_step, output_step);
170
171 uint32 bytes_to_crossfade = bytes_in_crossfade_;
172 if (muted_ || bytes_to_crossfade > output_step)
173 bytes_to_crossfade = 0;
174
175 // This is the index of the end of phase a, beginning of phase b.
176 uint32 outtro_crossfade_begin = output_step - bytes_to_crossfade;
177
178 // This is the index of the end of phase b, beginning of phase c.
179 uint32 outtro_crossfade_end = output_step;
180
181 // This is the index of the end of phase c, beginning of phase d.
182 // This phase continues until |index_into_window_| reaches |window_size_|, at
183 // which point the window restarts.
184 uint32 intro_crossfade_begin = input_step - bytes_to_crossfade;
185
186 // a) Output a raw frame if we haven't reached the crossfade section.
187 if (index_into_window_ < outtro_crossfade_begin) {
188 CopyWithAdvance(dest);
189 index_into_window_ += bytes_per_frame_;
190 return true;
191 }
192
193 // b) Save outtro crossfade frames into intermediate buffer, but do not output
194 // anything to |dest|.
195 while (index_into_window_ < outtro_crossfade_end) {
196 if (audio_buffer_.forward_bytes() < bytes_per_frame_)
197 return false;
198
199 // This phase only applies if there are bytes to crossfade.
200 DCHECK_GT(bytes_to_crossfade, 0u);
201 uint8* place_to_copy = crossfade_buffer_.get() +
202 (index_into_window_ - outtro_crossfade_begin);
203 CopyWithAdvance(place_to_copy);
204 index_into_window_ += bytes_per_frame_;
205 }
206
207 // c) Drop frames until we reach the intro crossfade section.
208 while (index_into_window_ < intro_crossfade_begin) {
209 if (audio_buffer_.forward_bytes() < bytes_per_frame_)
210 return false;
211
212 DropFrame();
213 index_into_window_ += bytes_per_frame_;
214 }
215
216 // Return if we have yet to finish phase c) or if |audio_buffer_| has run
217 // out of data.
218 if (index_into_window_ < intro_crossfade_begin ||
acolwell GONE FROM CHROMIUM 2012/02/24 00:48:33 I think this condition can be removed since it mat
vrk (LEFT CHROMIUM) 2012/02/27 18:19:13 Done.
219 audio_buffer_.forward_bytes() < bytes_per_frame_) {
220 return false;
221 }
222
223 // Phase d) doesn't apply if there are no bytes to crossfade.
224 if (bytes_to_crossfade == 0) {
225 DCHECK_EQ(index_into_window_, window_size_);
226 return false;
227 }
228
229 // d) Crossfade and output a frame.
230 DCHECK_LT(index_into_window_, window_size_);
231 uint32 offset_into_buffer = index_into_window_ - intro_crossfade_begin;
232 memcpy(dest, crossfade_buffer_.get() + offset_into_buffer,
233 bytes_per_frame_);
234 scoped_array<uint8> intro_frame_ptr(new uint8[bytes_per_frame_]);
235 audio_buffer_.Read(intro_frame_ptr.get(), bytes_per_frame_);
236 OutputCrossfadedFrame(dest, intro_frame_ptr.get());
237 index_into_window_ += bytes_per_frame_;
238 return true;
239 }
240
241 bool AudioRendererAlgorithmBase::OutputSlowerPlayback(uint8* dest) {
242 DCHECK_LT(index_into_window_, window_size_);
243 DCHECK_LT(playback_rate_, 1.0);
179 DCHECK_NE(playback_rate_, 0.0); 244 DCHECK_NE(playback_rate_, 0.0);
180 // Note: This may not play at the speed requested as we can only consume as 245
181 // much data as we have, and audio timestamps drive the pipeline clock. 246 if (audio_buffer_.forward_bytes() < bytes_per_frame_)
182 // 247 return false;
183 // Furthermore, we won't end up scaling the very last bit of audio, but 248
184 // we're talking about <8ms of audio data. 249 if (playback_rate_ < kMinPlaybackRate)
185 250 muted_ = true;
186 // Cap the |input_step| by the amount of bytes buffered. 251
187 uint32 input_step = 252 // The audio data is output in a series of windows. For slowed down playback,
188 std::min(static_cast<uint32>(length * playback_rate_), bytes_buffered()); 253 // the window is comprised of the following phases:
189 uint32 output_step = input_step / playback_rate_; 254 //
190 AlignToSampleBoundary(&input_step); 255 // a) Output raw data.
191 AlignToSampleBoundary(&output_step); 256 // b) Output and save bytes for crossfade in |crossfade_buffer_|.
192 257 // c) Output* raw data.
193 DCHECK_LE(output_step, length); 258 // d) Output* crossfaded audio leading up to the next window.
194 if (output_step > length) { 259 //
195 LOG(ERROR) << "OLA: output_step (" << output_step << ") calculated to " 260 // * Phases c) and d) do not progress |audio_buffer_|'s cursor so that the
196 << "be larger than destination length (" << length << ")"; 261 // |audio_buffer_|'s cursor is in the correct place for the next window.
197 output_step = length; 262 //
198 } 263 // The duration of each phase is computed below based on the |window_size_|
199 264 // and |playback_rate_|.
200 memset(dest, 0, output_step); 265 uint32 input_step = ceil(window_size_ * playback_rate_);
201 AdvanceBufferPosition(input_step); 266 AlignToFrameBoundary(&input_step);
202 return output_step; 267 uint32 output_step = window_size_;
268 DCHECK_LT(input_step, output_step);
269
270 uint32 bytes_to_crossfade = bytes_in_crossfade_;
271 if (muted_ || bytes_to_crossfade > input_step)
272 bytes_to_crossfade = 0;
273
274 // This is the index of the end of phase a, beginning of phase b.
275 uint32 intro_crossfade_begin = input_step - bytes_to_crossfade;
276
277 // This is the index of the end of phase b, beginning of phase c.
278 uint32 intro_crossfade_end = input_step;
279
280 // This is the index of the end of phase c, beginning of phase d.
281 // This phase continues until |index_into_window_| reaches |window_size_|, at
282 // which point the window restarts.
283 uint32 outtro_crossfade_begin = output_step - bytes_to_crossfade;
284
285 // a) Output a raw frame.
286 if (index_into_window_ < intro_crossfade_begin) {
287 CopyWithAdvance(dest);
288 index_into_window_ += bytes_per_frame_;
289 return true;
290 }
291
292 // b) Save the raw frame for the intro crossfade section, then output the
293 // frame to |dest|.
294 if (index_into_window_ < intro_crossfade_end) {
295 uint32 offset = index_into_window_ - intro_crossfade_begin;
296 uint8* place_to_copy = crossfade_buffer_.get() + offset;
297 CopyWithoutAdvance(place_to_copy);
298 CopyWithAdvance(dest);
299 index_into_window_ += bytes_per_frame_;
300 return true;
301 }
302
303 uint32 audio_buffer_offset = index_into_window_ - intro_crossfade_end;
304
305 if (audio_buffer_.forward_bytes() < audio_buffer_offset + bytes_per_frame_)
306 return false;
307
308 // c) Output a raw frame into |dest| without advancing the |audio_buffer_|
309 // cursor. See function-level comment.
310 DCHECK_GE(index_into_window_, intro_crossfade_end);
311 CopyWithoutAdvance(dest, audio_buffer_offset);
312
313 // d) Crossfade the next frame of |crossfade_buffer_| into |dest| if we've
314 // reached the outtro crossfade section of the window.
315 if (index_into_window_ >= outtro_crossfade_begin) {
316 uint32 offset_into_crossfade_buffer =
317 index_into_window_ - outtro_crossfade_begin;
318 uint8* intro_frame_ptr =
319 crossfade_buffer_.get() + offset_into_crossfade_buffer;
320 OutputCrossfadedFrame(dest, intro_frame_ptr);
321 }
322
323 index_into_window_ += bytes_per_frame_;
324 return true;
325 }
326
327 bool AudioRendererAlgorithmBase::OutputNormalPlayback(uint8* dest) {
328 if (audio_buffer_.forward_bytes() >= bytes_per_frame_) {
329 CopyWithAdvance(dest);
330 index_into_window_ += bytes_per_frame_;
331 return true;
332 }
333 return false;
334 }
335
336 void AudioRendererAlgorithmBase::CopyWithAdvance(uint8* dest) {
337 CopyWithoutAdvance(dest);
338 DropFrame();
339 }
340
341 void AudioRendererAlgorithmBase::CopyWithoutAdvance(uint8* dest) {
342 CopyWithoutAdvance(dest, 0);
343 }
344
345 void AudioRendererAlgorithmBase::CopyWithoutAdvance(
346 uint8* dest, uint32 offset) {
347 if (muted_) {
348 memset(dest, 0, bytes_per_frame_);
349 return;
350 }
351 uint32 copied = audio_buffer_.Peek(dest, bytes_per_frame_, offset);
352 DCHECK_EQ(bytes_per_frame_, copied);
353 }
354
355 void AudioRendererAlgorithmBase::DropFrame() {
356 audio_buffer_.Seek(bytes_per_frame_);
357
358 if (!IsQueueFull())
359 request_read_cb_.Run();
360 }
361
362 void AudioRendererAlgorithmBase::OutputCrossfadedFrame(
363 uint8* outtro, const uint8* intro) {
364 DCHECK_LE(index_into_window_, window_size_);
365 DCHECK(!muted_);
366
367 switch (bytes_per_channel_) {
368 case 4:
369 CrossfadeFrame(reinterpret_cast<int32*>(outtro),
370 reinterpret_cast<const int32*>(intro));
371 break;
372 case 2:
373 CrossfadeFrame(reinterpret_cast<int16*>(outtro),
374 reinterpret_cast<const int16*>(intro));
375 break;
376 case 1:
377 CrossfadeFrame(outtro, intro);
378 break;
379 default:
380 NOTREACHED() << "Unsupported audio bit depth in crossfade.";
381 }
382 }
383
384 template <class Type>
385 void AudioRendererAlgorithmBase::CrossfadeFrame(
386 Type* outtro, const Type* intro) {
387 uint32 frames_in_crossfade = bytes_in_crossfade_ / bytes_per_frame_;
388 float crossfade_ratio =
389 static_cast<float>(crossfade_frame_number_) / frames_in_crossfade;
390 for (int channel = 0; channel < channels_; ++channel) {
391 *outtro = (*outtro) * (1.0 - crossfade_ratio) + (*intro) * crossfade_ratio;
392 outtro++;
393 intro++;
394 }
395 crossfade_frame_number_++;
203 } 396 }
204 397
205 void AudioRendererAlgorithmBase::SetPlaybackRate(float new_rate) { 398 void AudioRendererAlgorithmBase::SetPlaybackRate(float new_rate) {
206 DCHECK_GE(new_rate, 0.0); 399 DCHECK_GE(new_rate, 0.0);
207 playback_rate_ = new_rate; 400 playback_rate_ = new_rate;
208 } 401 }
209 402
210 void AudioRendererAlgorithmBase::AlignToSampleBoundary(uint32* value) { 403 void AudioRendererAlgorithmBase::AlignToFrameBoundary(uint32* value) {
211 (*value) -= ((*value) % (channels_ * bytes_per_channel_)); 404 (*value) -= ((*value) % bytes_per_frame_);
212 } 405 }
213 406
214 void AudioRendererAlgorithmBase::FlushBuffers() { 407 void AudioRendererAlgorithmBase::FlushBuffers() {
408 ResetWindow();
409
215 // Clear the queue of decoded packets (releasing the buffers). 410 // Clear the queue of decoded packets (releasing the buffers).
216 audio_buffer_.Clear(); 411 audio_buffer_.Clear();
217 request_read_cb_.Run(); 412 request_read_cb_.Run();
218 } 413 }
219 414
220 base::TimeDelta AudioRendererAlgorithmBase::GetTime() { 415 base::TimeDelta AudioRendererAlgorithmBase::GetTime() {
221 return audio_buffer_.current_time(); 416 return audio_buffer_.current_time();
222 } 417 }
223 418
224 void AudioRendererAlgorithmBase::EnqueueBuffer(Buffer* buffer_in) { 419 void AudioRendererAlgorithmBase::EnqueueBuffer(Buffer* buffer_in) {
225 // If we're at end of stream, |buffer_in| contains no data. 420 DCHECK(!buffer_in->IsEndOfStream());
226 if (!buffer_in->IsEndOfStream()) 421 audio_buffer_.Append(buffer_in);
227 audio_buffer_.Append(buffer_in); 422 needs_more_data_ = false;
228 423
229 // If we still don't have enough data, request more. 424 // If we still don't have enough data, request more.
230 if (!IsQueueFull()) 425 if (!IsQueueFull())
231 request_read_cb_.Run(); 426 request_read_cb_.Run();
232 } 427 }
233 428
429 bool AudioRendererAlgorithmBase::NeedsMoreData() {
430 return needs_more_data_ || IsQueueEmpty();
431 }
432
234 bool AudioRendererAlgorithmBase::IsQueueEmpty() { 433 bool AudioRendererAlgorithmBase::IsQueueEmpty() {
235 return audio_buffer_.forward_bytes() == 0; 434 return audio_buffer_.forward_bytes() == 0;
236 } 435 }
237 436
238 bool AudioRendererAlgorithmBase::IsQueueFull() { 437 bool AudioRendererAlgorithmBase::IsQueueFull() {
239 return audio_buffer_.forward_bytes() >= audio_buffer_.forward_capacity(); 438 return audio_buffer_.forward_bytes() >= audio_buffer_.forward_capacity();
240 } 439 }
241 440
242 uint32 AudioRendererAlgorithmBase::QueueCapacity() { 441 uint32 AudioRendererAlgorithmBase::QueueCapacity() {
243 return audio_buffer_.forward_capacity(); 442 return audio_buffer_.forward_capacity();
244 } 443 }
245 444
246 void AudioRendererAlgorithmBase::IncreaseQueueCapacity() { 445 void AudioRendererAlgorithmBase::IncreaseQueueCapacity() {
247 audio_buffer_.set_forward_capacity( 446 audio_buffer_.set_forward_capacity(
248 std::min(2 * audio_buffer_.forward_capacity(), kMaxBufferSizeInBytes)); 447 std::min(2 * audio_buffer_.forward_capacity(), kMaxBufferSizeInBytes));
249 } 448 }
250 449
251 void AudioRendererAlgorithmBase::AdvanceBufferPosition(uint32 bytes) {
252 audio_buffer_.Seek(bytes);
253
254 if (!IsQueueFull())
255 request_read_cb_.Run();
256 }
257
258 uint32 AudioRendererAlgorithmBase::CopyFromAudioBuffer(
259 uint8* dest, uint32 bytes) {
260 return audio_buffer_.Peek(dest, bytes);
261 }
262
263 } // namespace media 450 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698