summaryrefslogtreecommitdiffstats
path: root/media/base/audio_renderer_mixer_input.h
diff options
context:
space:
mode:
authordalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 22:42:05 +0000
committerdalecurtis@chromium.org <dalecurtis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 22:42:05 +0000
commit7953ef8eea2001287dbd233421226ad3f0e16448 (patch)
tree542fc1849b60665e2a3df6e4295ffaa2f0093ece /media/base/audio_renderer_mixer_input.h
parent57ec6e9bd7de2a4c9cb1c795a1fc913f984d5098 (diff)
downloadchromium_src-7953ef8eea2001287dbd233421226ad3f0e16448.zip
chromium_src-7953ef8eea2001287dbd233421226ad3f0e16448.tar.gz
chromium_src-7953ef8eea2001287dbd233421226ad3f0e16448.tar.bz2
Lays the base work and initial unit tests for renderer side audio mixing! Right
now nothing except unit tests are plumbed since mixing has poor performance with the large buffer sizes we're currently using; I.e., for a 140ms clip we attempt to render the full 170ms buffer, adding 30ms of overhead to the pipeline. Once another CL introduces resampling we can switch over to the low latency path for audio and turn on mixing at the same time. Chris also has some other ideas on how we might fix this prior to introducing resampling. Design revolves around each renderer creating an AudioRendererMixerInput which funnels into a common AudioRendererMixer (based on the AudioParameters each AudioRendererMixerInput is configured with). Each AudioRendererMixer owns a single AudioDevice which output from each AudioRendererMixerInput is mixed into. As mentioned above, for the initial landing of this CL the code which creates an AudioRendererMixerInput in RenderAudioSourceProvider has been disabled. Please look at https://chromiumcodereview.appspot.com/10636036/ if you're interested in what this looks like. BUG=133637 TEST=unit tests. audio_latency_perf. drum machine. manual testing. asan. Review URL: https://chromiumcodereview.appspot.com/10544130 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/audio_renderer_mixer_input.h')
-rw-r--r--media/base/audio_renderer_mixer_input.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/media/base/audio_renderer_mixer_input.h b/media/base/audio_renderer_mixer_input.h
new file mode 100644
index 0000000..7e8c9f1
--- /dev/null
+++ b/media/base/audio_renderer_mixer_input.h
@@ -0,0 +1,61 @@
+// 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.
+
+#ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
+#define MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_
+
+#include <vector>
+
+#include "media/base/audio_renderer_sink.h"
+
+namespace media {
+
+class AudioRendererMixer;
+
+class MEDIA_EXPORT AudioRendererMixerInput
+ : NON_EXPORTED_BASE(public AudioRendererSink) {
+ public:
+ explicit AudioRendererMixerInput(
+ const scoped_refptr<AudioRendererMixer>& mixer);
+
+ // Each input should manage its own data buffer. The mixer will call this
+ // method when it needs a buffer for rendering.
+ const std::vector<float*>& audio_data() { return audio_data_; }
+ AudioRendererSink::RenderCallback* callback() { return callback_; }
+ bool playing() { return playing_; }
+
+ // AudioRendererSink implementation.
+ virtual void Start() OVERRIDE;
+ virtual void Stop() OVERRIDE;
+ virtual void Play() OVERRIDE;
+ virtual void Pause(bool flush) OVERRIDE;
+ virtual bool SetVolume(double volume) OVERRIDE;
+ virtual void GetVolume(double* volume) OVERRIDE;
+ virtual void Initialize(const AudioParameters& params,
+ AudioRendererSink::RenderCallback* renderer) OVERRIDE;
+
+ protected:
+ virtual ~AudioRendererMixerInput();
+
+ private:
+ bool playing_;
+ bool initialized_;
+ double volume_;
+
+ // AudioRendererMixer is reference counted by all its AudioRendererMixerInputs
+ // and is destroyed when all AudioRendererMixerInputs have called RemoveMixer.
+ scoped_refptr<AudioRendererMixer> mixer_;
+
+ // Source of audio data which is provided to the mixer.
+ AudioRendererSink::RenderCallback* callback_;
+
+ // Vector for rendering audio data which will be used by the mixer.
+ std::vector<float*> audio_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerInput);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_INPUT_H_