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

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: Review fixes. 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') | media/base/audio_renderer_mixer.cc » ('J')
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" 11 #include "base/memory/ref_counted.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "media/base/audio_renderer_mixer_input.h" 13 #include "media/base/audio_renderer_mixer_input.h"
14 #include "media/base/audio_renderer_sink.h" 14 #include "media/base/audio_renderer_sink.h"
15 #include "media/base/multi_channel_resampler.h"
15 16
16 namespace media { 17 namespace media {
17 18
18 // Mixes a set of AudioRendererMixerInputs into a single output stream which is 19 // Mixes a set of AudioRendererMixerInputs into a single output stream which is
19 // funneled into a single shared AudioRendererSink; saving a bundle on renderer 20 // funneled into a single shared AudioRendererSink; saving a bundle on renderer
20 // side resources. 21 // side resources. Resampling is done post-mixing as it is the most expensive
21 // TODO(dalecurtis): Update documentation once resampling is available. 22 // process. If the input sample rate matches the audio hardware sample rate, no
23 // resampling is done.
22 class MEDIA_EXPORT AudioRendererMixer 24 class MEDIA_EXPORT AudioRendererMixer
23 : public base::RefCountedThreadSafe<AudioRendererMixer>, 25 : public base::RefCountedThreadSafe<AudioRendererMixer>,
24 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) { 26 NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
25 public: 27 public:
26 AudioRendererMixer(const AudioParameters& params, 28 AudioRendererMixer(const AudioParameters& params,
27 const scoped_refptr<AudioRendererSink>& sink); 29 const scoped_refptr<AudioRendererSink>& sink);
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: 35 protected:
34 friend class base::RefCountedThreadSafe<AudioRendererMixer>; 36 friend class base::RefCountedThreadSafe<AudioRendererMixer>;
35 virtual ~AudioRendererMixer(); 37 virtual ~AudioRendererMixer();
36 38
37 private: 39 private:
38 // AudioRendererSink::RenderCallback implementation. 40 // AudioRendererSink::RenderCallback implementation.
39 virtual int Render(const std::vector<float*>& audio_data, 41 virtual int Render(const std::vector<float*>& audio_data,
40 int number_of_frames, 42 int number_of_frames,
41 int audio_delay_milliseconds) OVERRIDE; 43 int audio_delay_milliseconds) OVERRIDE;
42 virtual void OnRenderError() OVERRIDE; 44 virtual void OnRenderError() OVERRIDE;
43 45
44 // AudioParameters this mixer was constructed with. 46 // Handles mixing and volume adjustment. Renders |number_of_frames| into
45 AudioParameters audio_parameters_; 47 // |audio_data|. When resamplingis necessary, ProvideInput() will be called
48 // by MultiChannelResampler when more data is necessary.
49 virtual void ProvideInput(const std::vector<float*>& audio_data,
scherkus (not reviewing) 2012/07/12 23:02:52 does this need to be virtual? I didn't see any ov
DaleCurtis 2012/07/13 00:01:25 Done.
50 int number_of_frames);
51
52 // Constructor using a fixed set of input and output parameters so unit tests
53 // don't care what audio hardware the test is running on.
54 friend class AudioRendererMixerTestCase;
55 friend class AudioRendererMixerInputTest;
56 AudioRendererMixer(const AudioParameters& input_params,
57 const AudioParameters& output_params,
58 const scoped_refptr<AudioRendererSink>& sink);
59
60 // Constructor helper method.
61 void Initialize(const AudioParameters& input_params,
62 const AudioParameters& output_params);
46 63
47 // Output sink for this mixer. 64 // Output sink for this mixer.
48 scoped_refptr<AudioRendererSink> audio_sink_; 65 scoped_refptr<AudioRendererSink> audio_sink_;
49 66
50 // Set of mixer inputs to be mixed by this mixer. Access is thread-safe 67 // Set of mixer inputs to be mixed by this mixer. Access is thread-safe
51 // through |mixer_inputs_lock_|. 68 // through |mixer_inputs_lock_|.
52 typedef std::set< scoped_refptr<AudioRendererMixerInput> > 69 typedef std::set< scoped_refptr<AudioRendererMixerInput> >
53 AudioRendererMixerInputSet; 70 AudioRendererMixerInputSet;
54 AudioRendererMixerInputSet mixer_inputs_; 71 AudioRendererMixerInputSet mixer_inputs_;
55 base::Lock mixer_inputs_lock_; 72 base::Lock mixer_inputs_lock_;
56 73
74 // Vector for rendering audio data from each mixer input.
75 int mixer_input_audio_data_size_;
76 std::vector<float*> mixer_input_audio_data_;
77
78 // Handles resampling post-mixing.
79 scoped_ptr<MultiChannelResampler> resampler_;
80
81 // The audio delay in milliseconds received by the last Render() call.
82 int current_audio_delay_milliseconds_;
83
57 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer); 84 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixer);
58 }; 85 };
59 86
60 } // namespace media 87 } // namespace media
61 88
62 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_ 89 #endif // MEDIA_BASE_AUDIO_RENDERER_MIXER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_renderer_mixer.cc » ('j') | media/base/audio_renderer_mixer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698