diff options
author | dalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 04:24:19 +0000 |
---|---|---|
committer | dalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 04:24:19 +0000 |
commit | 4187ea43e11dd33ec2d542edd76163d8fc7ed1c1 (patch) | |
tree | 142e57255a31a095905e78423279f1fa2f4eb42e /media/audio/audio_output_resampler.h | |
parent | 2d115a11ba119dc8d3df465b3fdb96fb94a0e1bc (diff) | |
download | chromium_src-4187ea43e11dd33ec2d542edd76163d8fc7ed1c1.zip chromium_src-4187ea43e11dd33ec2d542edd76163d8fc7ed1c1.tar.gz chromium_src-4187ea43e11dd33ec2d542edd76163d8fc7ed1c1.tar.bz2 |
Collapse AudioRendererMixer and OnMoreDataResampler into AudioTransform.
Currently we have roughly equivalent functionality in two places, and
the CloudView project will add a third. As such there's a need for a
single super class which can handle mixing, resampling, and general
conversion from one set of AudioParameters to another.
This change introduces the AudioTransform object which collapses the
key functionality from AudioRendererMixer and OnMoreDataResampler into
a single AudioTransform class which can do everything and is oblivious
to the peculiars of RenderCallback vs AudioSourceCallback.
It also introduces output_frames_ready() methods to the AudioPullFifo
and MultiChannelResampler classes so that buffer delay can be measured
accurately without resorting to input vs output byte counting.
Due to the bulk of AudioRendererMixer's functionality moving into the
new AudioTransform, it made sense to move some decisions into the
AudioRendererMixerInput class as well.
On my Z600, benchmarking 50000 iterations:
Convert() w/ FIFO took 7030.11ms.
Convert() w/o FIFO took 5218.83ms.
BUG=none
TEST=AudioTransform* unittests.
TBR=sergeyu
Review URL: https://chromiumcodereview.appspot.com/11410012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168976 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/audio_output_resampler.h')
-rw-r--r-- | media/audio/audio_output_resampler.h | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/media/audio/audio_output_resampler.h b/media/audio/audio_output_resampler.h index 7643437..057cf34 100644 --- a/media/audio/audio_output_resampler.h +++ b/media/audio/audio_output_resampler.h @@ -17,31 +17,24 @@ namespace media { -class OnMoreDataResampler; +class OnMoreDataConverter; -// AudioOutputResampler is a browser-side resampling and rebuffering solution -// which ensures audio data is always output at given parameters. The rough -// flow is: Client -> [FIFO] -> [Resampler] -> Output Device. -// -// The FIFO and resampler are only used when necessary. To be clear: -// - The resampler is only used if the input and output sample rates differ. -// - The FIFO is only used if the input and output frame sizes differ or if -// the resampler is used. +// AudioOutputResampler is a browser-side resampling and buffering solution +// which ensures audio data is always output at given parameters. See the +// AudioConverter class for details on the conversion process. // // AOR works by intercepting the AudioSourceCallback provided to StartStream() -// and redirecting to the appropriate resampling or FIFO callback which passes -// through to the original callback only when necessary. +// and redirecting it through an AudioConverter instance. AudioBuffersState is +// adjusted for buffer delay caused by the conversion process. // // AOR will automatically fall back from AUDIO_PCM_LOW_LATENCY to // AUDIO_PCM_LINEAR if the output device fails to open at the requested output // parameters. +// // TODO(dalecurtis): Ideally the low latency path will be as reliable as the // high latency path once we have channel mixing and support querying for the // hardware's configured bit depth. Monitor the UMA stats for fallback and // remove fallback support once it's stable. http://crbug.com/148418 -// -// Currently channel downmixing and upmixing is not supported. -// TODO(dalecurtis): Add channel remixing. http://crbug.com/138762 class MEDIA_EXPORT AudioOutputResampler : public AudioOutputDispatcher { public: AudioOutputResampler(AudioManager* audio_manager, @@ -63,21 +56,17 @@ class MEDIA_EXPORT AudioOutputResampler : public AudioOutputDispatcher { friend class base::RefCountedThreadSafe<AudioOutputResampler>; virtual ~AudioOutputResampler(); - // Used to initialize the FIFO and resamplers. + // Used to initialize and reinitialize |dispatcher_|. void Initialize(); // Dispatcher to proxy all AudioOutputDispatcher calls too. scoped_refptr<AudioOutputDispatcher> dispatcher_; - // Map of outstanding OnMoreDataResampler objects. A new object is created + // Map of outstanding OnMoreDataConverter objects. A new object is created // on every StartStream() call and destroyed on CloseStream(). - typedef std::map<AudioOutputProxy*, OnMoreDataResampler*> CallbackMap; + typedef std::map<AudioOutputProxy*, OnMoreDataConverter*> CallbackMap; CallbackMap callbacks_; - // Ratio of input bytes to output bytes used to correct playback delay with - // regard to buffering and resampling. - double io_ratio_; - // Used by AudioOutputDispatcherImpl; kept so we can reinitialize on the fly. base::TimeDelta close_delay_; |