diff options
author | dalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-30 01:00:23 +0000 |
---|---|---|
committer | dalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-30 01:00:23 +0000 |
commit | 6ed2de0c2b29723bec008ee1c20ee88a492154f2 (patch) | |
tree | dfcf0b36d532389b749cd4e2ce5578b22aa288ed /media/base/audio_converter.cc | |
parent | f7fe6a41c7c72b7927d65fbcaa67d61f03867887 (diff) | |
download | chromium_src-6ed2de0c2b29723bec008ee1c20ee88a492154f2.zip chromium_src-6ed2de0c2b29723bec008ee1c20ee88a492154f2.tar.gz chromium_src-6ed2de0c2b29723bec008ee1c20ee88a492154f2.tar.bz2 |
C++ readability review for dalecurtis.
AudioConverter is a tool for mixing and converting audio data from
one format to another; differences may include sample rates, channel
layout, and buffer size.
AudioConverter is the work horse behind several Chrome features:
- Allows mixing and conversion of HTML5 audio streams for thread savings:
https://code.google.com/p/chromium/codesearch#chromium/src/media/base/audio_renderer_mixer.cc
- Allows Pepper clients (like Flash) to be oblivious of hardware requirements:
https://code.google.com/p/chromium/codesearch#chromium/src/media/audio/audio_output_resampler.cc
- Tab Audio Mirroring:
https://code.google.com/p/chromium/codesearch#chromium/src/media/audio/virtual_audio_input_stream.cc
Original CL for context: https://codereview.chromium.org/11410012/
R=fischman@chromium.org, lmendes@google.com
Review URL: https://codereview.chromium.org/12670011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197197 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/audio_converter.cc')
-rw-r--r-- | media/base/audio_converter.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/media/base/audio_converter.cc b/media/base/audio_converter.cc index 151d88d..6434ee9 100644 --- a/media/base/audio_converter.cc +++ b/media/base/audio_converter.cc @@ -1,6 +1,12 @@ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// +// AudioConverter implementation. Uses MultiChannelSincResampler for resampling +// audio, ChannelMixer for channel mixing, and AudioPullFifo for buffering. +// +// Delay estimates are provided to InputCallbacks based on the frame delay +// information reported via the resampler and FIFO units. #include "media/base/audio_converter.h" @@ -117,10 +123,17 @@ void AudioConverter::Convert(AudioBus* dest) { return; } + // Determine if channel mixing should be done and if it should be done before + // or after resampling. If it's possible to reduce the channel count prior to + // resampling we can save a lot of processing time. Vice versa, we don't want + // to increase the channel count prior to resampling for the same reason. bool needs_mixing = channel_mixer_ && !downmix_early_; AudioBus* temp_dest = needs_mixing ? unmixed_audio_.get() : dest; DCHECK(temp_dest); + // Figure out which method to call based on whether we're resampling and + // rebuffering, just resampling, or just mixing. We want to avoid any extra + // steps when possible since we may be converting audio data in real time. if (!resampler_ && !audio_fifo_) { SourceCallback(0, temp_dest); } else { @@ -130,6 +143,7 @@ void AudioConverter::Convert(AudioBus* dest) { ProvideInput(0, temp_dest); } + // Finally upmix the channels if we didn't do so earlier. if (needs_mixing) { DCHECK_EQ(temp_dest->frames(), dest->frames()); channel_mixer_->Transform(temp_dest, dest); |