class Mixer
Defined at line 31 of file ../../src/media/audio/audio_core/mixer/mixer.h
The Mixer class provides format-conversion, rechannelization, rate-connversion, and gain/mute
scaling. Each source in a multi-stream mix has its own Mixer instance. When Mixer::Mix() is
called, it adds that source's contribution, by reading audio from its source, generating the
appropriately processed result, and summing this output into a common destination buffer.
Public Members
Gain gain
TimelineFunction source_ref_clock_to_frac_source_frames
uint32_t source_ref_clock_to_frac_source_frames_generation
TimelineFunction clock_mono_to_frac_source_frames
TimelineFunction dest_frames_to_frac_source_frames
unique_ptr scale_arr
static const int64_t kScaleArrLen
Public Methods
void Mixer (std::shared_ptr<media_audio::Sampler> sampler, Gain::Limits gain_limits)
Defined at line 49 of file ../../src/media/audio/audio_core/mixer/mixer.cc
std::unique_ptr<Mixer> NoOp ()
Returns a no-op mixer.
Defined at line 57 of file ../../src/media/audio/audio_core/mixer/mixer.cc
std::unique_ptr<Mixer> Select (const fuchsia::media::AudioStreamType & source_format, const fuchsia::media::AudioStreamType & dest_format, Resampler resampler_type, Gain::Limits gain_limits)
Select
Select an appropriate mixer instance, based on an optionally-specified resampler type, or else
by the properties of source/destination formats.
When calling Mixer::Select, resampler_type is optional. If a caller specifies a particular
resampler, Mixer::Select will either instantiate what was requested or return nullptr, even if
it otherwise could have successfully instantiated a different one. Setting this to non-Default
says "I know exactly what I need: I want you to fail rather than give me anything else."
If resampler_type is absent or Default, this is determined by algorithm. For optimum system
performance across changing conditions, callers should use Default whenever possible.
Defined at line 68 of file ../../src/media/audio/audio_core/mixer/mixer.cc
void Mix (float * dest_ptr, int64_t dest_frames, int64_t * dest_offset_ptr, const void * source_void_ptr, int64_t source_frames, Fixed * source_offset_ptr, bool accumulate)
Mix
Perform a mixing operation from source buffer into destination buffer.
Within Mix(), the following source/dest/rate constraints are enforced:
* source_frames must be at least 1
* source_offset must be at least -pos_filter_width
cannot exceed source_frames
* dest_offset cannot exceed dest_frames
* step_size must exceed zero
* step_size_modulo must be either zero or less than denominator
* source_position_modulo must be either zero or less than denominator
Parameters
Defined at line 131 of file ../../src/media/audio/audio_core/mixer/mixer.cc
Fixed pos_filter_width ()
Filter widths
The positive and negative widths of the filter for this mixer, expressed in fixed-point
fractional source subframe units. These widths convey which source frames will be referenced by
the filter, when producing output for a specific instant in time. Positive filter width refers
to how far forward (positively) the filter looks, from the PTS in question; negative filter
width refers to how far backward (negatively) the filter looks, from that same PTS.
For example, a pure "sample and hold" resampler might have a negative filter width of almost
one frame and a positive filter width of zero.
Note that filter widths do NOT include the center PTS in question, so in that regard they are
not equivalent to the filter's length.
Let:
P = pos_filter_width()
N = neg_filter_width()
S = An arbitrary point in time at which the source stream will be sampled.
X = The PTS of an source frame.
If (X >= (S - N))
&
&
(X
<
= (S + P))
Then source frame X is within the filter and contributes to mix operation.
Conversely, source frame X contributes to the output samples S where
(S >= X - P) and (S
<
= X + N)
Defined at line 141 of file ../../src/media/audio/audio_core/mixer/mixer.h
Fixed neg_filter_width ()
Defined at line 142 of file ../../src/media/audio/audio_core/mixer/mixer.h
media_audio::Sampler::State & state ()
Defined at line 144 of file ../../src/media/audio/audio_core/mixer/mixer.h
const media_audio::Sampler::State & state ()
Defined at line 145 of file ../../src/media/audio/audio_core/mixer/mixer.h
void EagerlyPrepare ()
Eagerly precompute any needed data. If not called, that data should be lazily computed on the
first call to Mix().
TODO(https://fxbug.dev/42121558): This is for tests only and can be removed once filter
creation is eager.
Defined at line 151 of file ../../src/media/audio/audio_core/mixer/mixer.h
Enumerations
enum Resampler
| Name | Value |
|---|---|
| Default | 0 |
| SampleAndHold | 1 |
| WindowedSinc | 2 |
Resampler enum
This enum lists Fuchsia's available resamplers. Callers of Mixer::Select optionally use this
to specify a resampler type. Default allows an algorithm to select a resampler based on the
ratio of incoming-to-outgoing rates (currently we use WindowedSinc for all ratios except 1:1).
Defined at line 40 of file ../../src/media/audio/audio_core/mixer/mixer.h