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

Unified Diff: media/base/audio_renderer_mixer.h

Issue 1483433003: Second layer of mixing for audio elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: That fix Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/audio_renderer_mixer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_renderer_mixer.h
diff --git a/media/base/audio_renderer_mixer.h b/media/base/audio_renderer_mixer.h
index 9bc383934d4e43a9a764ff5eb052fbeb7e286452..e8a0f8d92430c1c5f1bb494e47899da9e5a6b00d 100644
--- a/media/base/audio_renderer_mixer.h
+++ b/media/base/audio_renderer_mixer.h
@@ -8,10 +8,12 @@
#include <map>
#include <string>
+#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/time/time.h"
#include "media/base/audio_converter.h"
#include "media/base/audio_renderer_sink.h"
+#include "media/base/loopback_audio_converter.h"
namespace media {
@@ -21,14 +23,15 @@ namespace media {
class MEDIA_EXPORT AudioRendererMixer
: NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
public:
- AudioRendererMixer(const AudioParameters& input_params,
- const AudioParameters& output_params,
+ AudioRendererMixer(const AudioParameters& output_params,
const scoped_refptr<AudioRendererSink>& sink);
~AudioRendererMixer() override;
// Add or remove a mixer input from mixing; called by AudioRendererMixerInput.
- void AddMixerInput(AudioConverter::InputCallback* input);
- void RemoveMixerInput(AudioConverter::InputCallback* input);
+ void AddMixerInput(const AudioParameters& input_params,
+ AudioConverter::InputCallback* input);
+ void RemoveMixerInput(const AudioParameters& input_params,
+ AudioConverter::InputCallback* input);
// Since errors may occur even when no inputs are playing, an error callback
// must be registered separately from adding a mixer input. The same callback
@@ -47,13 +50,23 @@ class MEDIA_EXPORT AudioRendererMixer
OutputDevice* GetOutputDevice();
private:
+ // Maps input sample rate to the dedicated converter.
+ typedef std::map<int, scoped_ptr<LoopbackAudioConverter>> AudioConvertersMap;
+
// AudioRendererSink::RenderCallback implementation.
int Render(AudioBus* audio_bus, int audio_delay_milliseconds) override;
void OnRenderError() override;
+ bool is_master_sample_rate(int sample_rate) {
+ return sample_rate == output_params_.sample_rate();
+ }
+
// Output sink for this mixer.
scoped_refptr<AudioRendererSink> audio_sink_;
+ // Output parameters for this mixer.
+ AudioParameters output_params_;
+
// ---------------[ All variables below protected by |lock_| ]---------------
base::Lock lock_;
@@ -61,8 +74,14 @@ class MEDIA_EXPORT AudioRendererMixer
typedef std::list<base::Closure> ErrorCallbackList;
ErrorCallbackList error_callbacks_;
- // Handles mixing and resampling between input and output parameters.
- AudioConverter audio_converter_;
+ // Each of these converters mixes inputs with a given sample rate and
+ // resamples them to the output sample rate. Inputs not reqiuring resampling
+ // go directly to |master_converter_|.
+ AudioConvertersMap converters_;
+
+ // Master converter which mixes all the outputs from |converters_| as well as
+ // mixer inputs that are in the output sample rate.
+ AudioConverter master_converter_;
// Handles physical stream pause when no inputs are playing. For latency
// reasons we don't want to immediately pause the physical stream.
« no previous file with comments | « media/base/BUILD.gn ('k') | media/base/audio_renderer_mixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698