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

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

Issue 10698066: Switch to pcm_low_latency and enable resampling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments! Created 8 years, 5 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
« no previous file with comments | « no previous file | media/base/audio_renderer_mixer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
13 #include "media/base/audio_renderer_mixer_input.h" 12 #include "media/base/audio_renderer_mixer_input.h"
14 #include "media/base/audio_renderer_sink.h" 13 #include "media/base/audio_renderer_sink.h"
14 #include "media/base/multi_channel_resampler.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 // Mixes a set of AudioRendererMixerInputs into a single output stream which is 18 // Mixes a set of AudioRendererMixerInputs into a single output stream which is
19 // funneled into a single shared AudioRendererSink; saving a bundle on renderer 19 // funneled into a single shared AudioRendererSink; saving a bundle on renderer
20 // side resources. 20 // side resources. Resampling is done post-mixing as it is the most expensive
21 // TODO(dalecurtis): Update documentation once resampling is available. 21 // process. If the input sample rate matches the audio hardware sample rate, no
22 // resampling is done.
22 class MEDIA_EXPORT AudioRendererMixer 23 class MEDIA_EXPORT AudioRendererMixer
23 : public base::RefCountedThreadSafe<AudioRendererMixer>, 24 : NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
24 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
25 public: 25 public:
26 AudioRendererMixer(const AudioParameters& params, 26 AudioRendererMixer(const AudioParameters& input_params,
27 const AudioParameters& output_params,
27 const scoped_refptr<AudioRendererSink>& sink); 28 const scoped_refptr<AudioRendererSink>& sink);
29 virtual ~AudioRendererMixer();
28 30
29 // Add or remove a mixer input from mixing; called by AudioRendererMixerInput. 31 // Add or remove a mixer input from mixing; called by AudioRendererMixerInput.
30 void AddMixerInput(const scoped_refptr<AudioRendererMixerInput>& input); 32 void AddMixerInput(const scoped_refptr<AudioRendererMixerInput>& input);
31 void RemoveMixerInput(const scoped_refptr<AudioRendererMixerInput>& input); 33 void RemoveMixerInput(const scoped_refptr<AudioRendererMixerInput>& input);
32 34
33 protected:
34 friend class base::RefCountedThreadSafe<AudioRendererMixer>;
35 virtual ~AudioRendererMixer();
36
37 private: 35 private:
38 // AudioRendererSink::RenderCallback implementation. 36 // AudioRendererSink::RenderCallback implementation.
39 virtual int Render(const std::vector<float*>& audio_data, 37 virtual int Render(const std::vector<float*>& audio_data,
40 int number_of_frames, 38 int number_of_frames,
41 int audio_delay_milliseconds) OVERRIDE; 39 int audio_delay_milliseconds) OVERRIDE;
42 virtual void OnRenderError() OVERRIDE; 40 virtual void OnRenderError() OVERRIDE;
43 41
44 // AudioParameters this mixer was constructed with. 42 // Handles mixing and volume adjustment. Renders |number_of_frames| into
45 AudioParameters audio_parameters_; 43 // |audio_data|. When resampling is necessary, ProvideInput() will be called
44 // by MultiChannelResampler when more data is necessary.
45 void ProvideInput(const std::vector<float*>& audio_data,
46 int number_of_frames);
46 47
47 // Output sink for this mixer. 48 // Output sink for this mixer.
48 scoped_refptr<AudioRendererSink> audio_sink_; 49 scoped_refptr<AudioRendererSink> audio_sink_;
49 50
50 // Set of mixer inputs to be mixed by this mixer. Access is thread-safe 51 // Set of mixer inputs to be mixed by this mixer. Access is thread-safe
51 // through |mixer_inputs_lock_|. 52 // through |mixer_inputs_lock_|.
52 typedef std::set< scoped_refptr<AudioRendererMixerInput> > 53 typedef std::set< scoped_refptr<AudioRendererMixerInput> >
53 AudioRendererMixerInputSet; 54 AudioRendererMixerInputSet;
54 AudioRendererMixerInputSet mixer_inputs_; 55 AudioRendererMixerInputSet mixer_inputs_;
55 base::Lock mixer_inputs_lock_; 56 base::Lock mixer_inputs_lock_;
56 57
58 // Vector for rendering audio data from each mixer input.
59 int mixer_input_audio_data_size_;
60 std::vector<float*> mixer_input_audio_data_;
61
62 // Handles resampling post-mixing.
63 scoped_ptr<MultiChannelResampler> resampler_;
64
65 // The audio delay in milliseconds received by the last Render() call.
66 int current_audio_delay_milliseconds_;
67
57 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer); 68 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer);
58 }; 69 };
59 70
60 } // namespace media 71 } // namespace media
61 72
62 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 73 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_renderer_mixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698