class MixerSource

Defined at line 52 of file ../../src/media/audio/services/mixer/mix/mixer_source.h

Class that manages relevant information of a `MixerStage` source to mix onto destination stream.

This consists of the computation of the combined gain to be applied into the source stream, as

well as processing the samples in the source stream to mix onto the destination stream using an

appropriate sampler implementation with respect to the synchronization needs between the source

and destination streams.

Combined gain computation is done by using the set of `GainControl`s that are connected to the

source, combined with the `GainControl`s that are connected to the destination. The source gain

controls are selected during the creation of this mixer source edge, and are accessed by the

`options.gain_ids`. Similarly, the initial destination gain controls are passed via

`dest_gain_ids` at construction to build the total set of gain controls to be combined. However,

while the source gain controls are guaranteed to remain constant after the edge creation, the

destination gain controls can be modified after the creation of this mixer source. Therefore, we

keep track of the destination gain controls and update them via `SetDestGains` as requested.

Once the combined gain is computed and updated via `PrepareSourceGainForNextMix` call,

corresponding source samples can be processed and mixed onto the destination stream via `Advance`

and `Mix` calls. These mainly follow the same `PipelineStage::Advance` and `PipelineStage::Read`

call patterns, where `Read` roughly expands to a sequence of `PrepareSourceGainForNextMix` and

`Mix` calls respectively.

Public Methods

void MixerSource (PipelineStagePtr source, PipelineStage::AddSourceOptions options, const std::unordered_set<GainControlId> & dest_gain_ids, int64_t max_dest_frame_count_per_mix)

Defined at line 53 of file ../../src/media/audio/services/mixer/mix/mixer_source.cc

void Advance (MixJobContext & ctx, const TimelineFunction & dest_time_to_dest_frac_frame, Fixed dest_frame)

Advances source to `dest_frame`.

Defined at line 80 of file ../../src/media/audio/services/mixer/mix/mixer_source.cc

const PipelineStagePtr & original_source ()

Returns the original source.

Defined at line 83 of file ../../src/media/audio/services/mixer/mix/mixer_source.h

const std::unordered_set<GainControlId> & all_gain_ids ()

Returns the set of all gains to be applied to this source. For debugging purposes only.

Defined at line 86 of file ../../src/media/audio/services/mixer/mix/mixer_source.h

bool Mix (MixJobContext & ctx, const TimelineFunction & dest_time_to_dest_frac_frame, Fixed dest_start_frame, int64_t dest_frame_count, float * dest_samples, bool accumulate)

Mixes source onto destination with a given `dest_start_frame` and `dest_frame_count`, where

`dest_samples` points to the destination samples starting at `dest_start_frame`. If

`accumulate` is true, source samples will be accumulated into the existing `dest_samples`.

Otherwise, `dest_samples` will be filled directly by the corresponding source samples. Finally,

returns true if there were "potentially" non-silent frames that were mixed onto `dest_samples`.

Returns false otherwise, if no frames were mixed or all frames were guaranteed to be silent.

Defined at line 90 of file ../../src/media/audio/services/mixer/mix/mixer_source.cc

Sampler::Gain gain ()

Returns the most recently computed combined source gain to be used in the next `Mix` call. This

is prepared at the beginning of each `PipelineStage::Read` call in the destination stream by a

set of `PrepareSourceGainForNextMix` calls. For debugging purposes only.

Defined at line 91 of file ../../src/media/audio/services/mixer/mix/mixer_source.h

void PrepareSourceGainForNextMix (MixJobContext & ctx, const MixerGainControls & gain_controls, const TimelineFunction & dest_time_to_dest_frac_frame, int64_t dest_frame_offset, int64_t dest_frame_count)

Prepares combined source gain for the next `Mix` call for a given frame range of

`[dest_frame_offset, dest_frame_count)`, using the current state of `gain_controls`. Note that

combined source gain for the preceding frame range of `[0, dest_frame_offset)` must have

already been prepared by calling the function respectively prior to this call.

Defined at line 283 of file ../../src/media/audio/services/mixer/mix/mixer_source.cc

void SetDestGains (const std::unordered_set<GainControlId> & dest_gain_ids)

Sets the set of `dest_gain_ids` to be applied to the output edge.

Defined at line 363 of file ../../src/media/audio/services/mixer/mix/mixer_source.cc