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

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

Issue 11410012: Collapse AudioRendererMixer and OnMoreDataResampler into AudioTransform. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First draft. Created 8 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_AUDIO_TRANSFORM_H_
6 #define MEDIA_BASE_AUDIO_TRANSFORM_H_
7
8 #include <list>
9
10 #include "base/callback.h"
11 #include "base/time.h"
12 #include "media/audio/audio_parameters.h"
13 #include "media/base/media_export.h"
14
15 namespace media {
16
17 class AudioBus;
18 class AudioPullFifo;
19 class ChannelMixer;
20 class MultiChannelResampler;
21
22 // AudioTransform is a complete mixing, resampling, rebuffering, and channel
23 // mixing solution for converting data from one set of AudioParameters to
24 // another. For efficiency pieces are only invoked when necessary; e.g. the
25 // resampler is only used if the input and output sample rates differ. Mixing
26 // and channel down mixing are done prior to resampling to maximize efficiency.
27 class MEDIA_EXPORT AudioTransform {
Chris Rogers 2012/11/14 23:50:49 This is just a naming nit, but always good to get
DaleCurtis 2012/11/16 23:51:05 Done. I'll rename the file in the last patch set t
28 public:
29 class MEDIA_EXPORT AudioTransformInput {
scherkus (not reviewing) 2012/11/14 22:43:50 nit: this can be "Input" because its name is alrea
DaleCurtis 2012/11/15 00:30:59 Just what we discussed at dinner the other day. Yo
DaleCurtis 2012/11/16 23:51:05 Changed to InputCallback a la RenderCallback
30 public:
31 // Method for providing more data into the transform. Expects |audio_bus|
32 // to be completely filled with data upon return; zero padded if not enough
33 // frames are available to satisfy the request. The return value is the
34 // volume level of the provided audio data. If a volume level of zero is
Chris Rogers 2012/11/14 23:50:49 can you elaborate a little more in this comment on
DaleCurtis 2012/11/16 23:51:05 Done.
35 // returned no further processing will be done on the provided data.
36 virtual float ProvideAudioTransformInput(AudioBus* audio_bus,
37 base::TimeDelta buffer_delay) = 0;
38
39 protected:
40 virtual ~AudioTransformInput() {}
41 };
42
43 AudioTransform(const AudioParameters& input_params,
44 const AudioParameters& output_params);
45 ~AudioTransform();
46
47 // Transforms audio from all inputs into the |dest|. |dest| must be sized for
48 // data matching the output AudioParameters provided during construction.
49 void Transform(AudioBus* dest);
50
51 // Add or remove an input from the transform.
52 void AddInput(AudioTransformInput* input);
justinlin 2012/11/12 20:29:38 Purely from an interface point of view, would it m
DaleCurtis 2012/11/12 20:48:18 Currently AudioRendererMixerManager does a similar
53 void RemoveInput(AudioTransformInput* input);
54
55 // Flush all buffered data. Automatically called when all inputs are removed.
56 void Reset();
57
58 private:
59 // Called by MultiChannelResampler when more data is necessary.
60 void ProvideInput(AudioBus* audio_bus);
61
62 // Called by AudioPullFifo when more data is necessary.
63 void SourceCallback(AudioBus* audio_bus);
64
65 // Set of inputs for Transform().
66 typedef std::list<AudioTransformInput*> AudioTransformInputSet;
67 AudioTransformInputSet transform_inputs_;
68
69 // Used to buffer data between the client and the output device in cases where
70 // the client buffer size is not the same as the output device buffer size.
71 scoped_ptr<AudioPullFifo> audio_fifo_;
72
73 // Handles resampling.
74 scoped_ptr<MultiChannelResampler> resampler_;
75
76 // Handles channel transforms. |unmixed_audio_| is a temporary destination
77 // for audio data before it goes into the channel mixer.
78 scoped_ptr<ChannelMixer> channel_mixer_;
79 scoped_ptr<AudioBus> unmixed_audio_;
80
81 // Temporary AudioBus destination for mixing inputs.
82 scoped_ptr<AudioBus> mixer_input_audio_bus_;
83
84 // Since resampling is expensive, figure out if we should downmix channels
85 // before resampling.
86 bool downmix_early_;
87
88 // Used to calculate buffer delay information AudioTransformInputs.
89 base::TimeDelta input_frame_duration_;
90 base::TimeDelta output_frame_duration_;
91
92 DISALLOW_COPY_AND_ASSIGN(AudioTransform);
93 };
94
95 } // namespace media
96
97 #endif // MEDIA_BASE_AUDIO_TRANSFORM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698