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

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

Issue 10824304: Upgrade AudioBus to support wrapping, interleaving. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 4 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_impl.h" 5 #include "media/filters/audio_renderer_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 int bytes_per_frame = audio_parameters_.GetBytesPerFrame(); 345 int bytes_per_frame = audio_parameters_.GetBytesPerFrame();
346 346
347 const int buf_size = audio_bus->frames() * bytes_per_frame; 347 const int buf_size = audio_bus->frames() * bytes_per_frame;
348 scoped_array<uint8> buf(new uint8[buf_size]); 348 scoped_array<uint8> buf(new uint8[buf_size]);
349 349
350 int frames_filled = FillBuffer(buf.get(), audio_bus->frames(), request_delay); 350 int frames_filled = FillBuffer(buf.get(), audio_bus->frames(), request_delay);
351 int bytes_filled = frames_filled * bytes_per_frame; 351 int bytes_filled = frames_filled * bytes_per_frame;
352 DCHECK_LE(bytes_filled, buf_size); 352 DCHECK_LE(bytes_filled, buf_size);
353 UpdateEarliestEndTime(bytes_filled, request_delay, base::Time::Now()); 353 UpdateEarliestEndTime(bytes_filled, request_delay, base::Time::Now());
354 354
355 // Deinterleave each audio channel. 355 // Deinterleave audio data into the output bus.
356 int channels = audio_bus->channels(); 356 audio_bus->FromInterleaved(
357 for (int channel_index = 0; channel_index < channels; ++channel_index) { 357 buf.get(), frames_filled, audio_parameters_.bits_per_sample() / 8);
358 media::DeinterleaveAudioChannel(buf.get(),
359 audio_bus->channel(channel_index),
360 channels,
361 channel_index,
362 bytes_per_frame / channels,
363 frames_filled);
364 358
365 // If FillBuffer() didn't give us enough data then zero out the remainder.
366 if (frames_filled < audio_bus->frames()) {
367 int frames_to_zero = audio_bus->frames() - frames_filled;
368 memset(audio_bus->channel(channel_index) + frames_filled, 0,
369 sizeof(*audio_bus->channel(channel_index)) * frames_to_zero);
370 }
371 }
372 return frames_filled; 359 return frames_filled;
373 } 360 }
374 361
375 uint32 AudioRendererImpl::FillBuffer(uint8* dest, 362 uint32 AudioRendererImpl::FillBuffer(uint8* dest,
376 uint32 requested_frames, 363 uint32 requested_frames,
377 const base::TimeDelta& playback_delay) { 364 const base::TimeDelta& playback_delay) {
378 base::TimeDelta current_time = kNoTimestamp(); 365 base::TimeDelta current_time = kNoTimestamp();
379 base::TimeDelta max_time = kNoTimestamp(); 366 base::TimeDelta max_time = kNoTimestamp();
380 367
381 size_t frames_written = 0; 368 size_t frames_written = 0;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 case kUnderflow: 516 case kUnderflow:
530 case kRebuffering: 517 case kRebuffering:
531 case kStopped: 518 case kStopped:
532 if (status != PIPELINE_OK) 519 if (status != PIPELINE_OK)
533 error_cb_.Run(status); 520 error_cb_.Run(status);
534 return; 521 return;
535 } 522 }
536 } 523 }
537 524
538 } // namespace media 525 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698