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

Side by Side Diff: media/base/audio_renderer_mixer.h

Issue 14358049: Refactor AudioRendererMixer to be more generic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 6 #define MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
7 7
8 #include <list> 8 #include <map>
9 9
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "base/time.h" 11 #include "base/time.h"
12 #include "media/base/audio_converter.h" 12 #include "media/base/audio_converter.h"
13 #include "media/base/audio_renderer_mixer_input.h"
14 #include "media/base/audio_renderer_sink.h" 13 #include "media/base/audio_renderer_sink.h"
15 14
16 namespace media { 15 namespace media {
17 16
18 // Mixes a set of AudioRendererMixerInputs into a single output stream which is 17 // Mixes a set of AudioConverter::InputCallbacks into a single output stream
19 // funneled into a single shared AudioRendererSink; saving a bundle on renderer 18 // which is funneled into a single shared AudioRendererSink; saving a bundle
20 // side resources. 19 // on renderer side resources.
21 class MEDIA_EXPORT AudioRendererMixer 20 class MEDIA_EXPORT AudioRendererMixer
22 : NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { 21 : NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
23 public: 22 public:
24 AudioRendererMixer(const AudioParameters& input_params, 23 AudioRendererMixer(const AudioParameters& input_params,
25 const AudioParameters& output_params, 24 const AudioParameters& output_params,
26 const scoped_refptr<AudioRendererSink>& sink); 25 const scoped_refptr<AudioRendererSink>& sink);
27 virtual ~AudioRendererMixer(); 26 virtual ~AudioRendererMixer();
28 27
29 // Add or remove a mixer input from mixing; called by AudioRendererMixerInput. 28 // Add or remove a mixer input from mixing; called by AudioRendererMixerInput.
30 void AddMixerInput(const scoped_refptr<AudioRendererMixerInput>& input); 29 void AddMixerInput(AudioConverter::InputCallback* input,
31 void RemoveMixerInput(const scoped_refptr<AudioRendererMixerInput>& input); 30 const base::Closure& error_cb);
31 void RemoveMixerInput(AudioConverter::InputCallback* input);
32 32
33 void set_pause_delay_for_testing(base::TimeDelta delay) { 33 void set_pause_delay_for_testing(base::TimeDelta delay) {
34 pause_delay_ = delay; 34 pause_delay_ = delay;
35 } 35 }
36 36
37 private: 37 private:
38 // AudioRendererSink::RenderCallback implementation. 38 // AudioRendererSink::RenderCallback implementation.
39 virtual int Render(AudioBus* audio_bus, 39 virtual int Render(AudioBus* audio_bus,
40 int audio_delay_milliseconds) OVERRIDE; 40 int audio_delay_milliseconds) OVERRIDE;
41 virtual void OnRenderError() OVERRIDE; 41 virtual void OnRenderError() OVERRIDE;
42 42
43 // Output sink for this mixer. 43 // Output sink for this mixer.
44 scoped_refptr<AudioRendererSink> audio_sink_; 44 scoped_refptr<AudioRendererSink> audio_sink_;
45 45
46 // Set of mixer inputs to be mixed by this mixer. Access is thread-safe 46 // Set of mixer inputs to be mixed by this mixer. Access is thread-safe
47 // through |mixer_inputs_lock_|. 47 // through |mixer_inputs_lock_|.
48 typedef std::list<scoped_refptr<AudioRendererMixerInput> > 48 typedef std::map<AudioConverter::InputCallback*, base::Closure>
49 AudioRendererMixerInputSet; 49 AudioRendererMixerInputSet;
50 AudioRendererMixerInputSet mixer_inputs_; 50 AudioRendererMixerInputSet mixer_inputs_;
51 base::Lock mixer_inputs_lock_; 51 base::Lock mixer_inputs_lock_;
52 52
53 // Handles mixing and resampling between input and output parameters. 53 // Handles mixing and resampling between input and output parameters.
54 AudioConverter audio_converter_; 54 AudioConverter audio_converter_;
55 55
56 // Handles physical stream pause when no inputs are playing. For latency 56 // Handles physical stream pause when no inputs are playing. For latency
57 // reasons we don't want to immediately pause the physical stream. 57 // reasons we don't want to immediately pause the physical stream.
58 base::TimeDelta pause_delay_; 58 base::TimeDelta pause_delay_;
59 base::Time last_play_time_; 59 base::Time last_play_time_;
60 bool playing_; 60 bool playing_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer); 62 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer);
63 }; 63 };
64 64
65 } // namespace media 65 } // namespace media
66 66
67 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 67 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698