class ConsumerStage
Defined at line 25 of file ../../src/media/audio/services/mixer/mix/consumer_stage.h
A consumer that can run mix jobs.
Public Methods
void ConsumerStage (Args args)
Defined at line 18 of file ../../src/media/audio/services/mixer/mix/consumer_stage.cc
Status RunMixJob (MixJobContext & ctx, zx::time mix_job_start_time, zx::duration period)
Executes a single mix job that consumes `period` worth of audio data. This method should be
called at some time during range `R = [mix_job_start_time, mix_job_start_time + period)`,
relative to our reference clock, with the expectation that RunMixJob should complete before
`R.end`. This expectation is not checked -- it's the caller's responsibility to check for
overruns and underflows as desired.
Put differently, within RunMixJob, all calls to `ref_clock->now()` should return a value in
range `R`. The range `R` bounds the "actual current time" according to this consumer's
reference clock, not the presentation times of audio frames to consume. As described below, the
mix job actually consumes frames presented outside of range `R` -- either after `R` (in output
pipelines) or before `R` (in input pipelines).
## Output pipelines
Since this job may run until `mix_job_start_time + period`, we cannot consume any frames that
will be presented before `T = mix_job_start_time + period + downstream_delay`. Hence, we
consume frames in the range `[T, T + period)`.
In the diagram below, each `+` represents a frame ordered by presentation time, with
presentation time increasing to the right. The frames marked with `X` are consumed during the
mix job at `mix_job_start_time`.
```
downstream
|
<
-- period -->|
<
--- delay --->|
<
-- period -->| ...
frames: ++++++++++++++++++++++++++++++++++XXXXXXXXXXXXXXX+++++
^ ^ ^
mix job mix job T
start time end time
```
## Input pipelines
Since this job starts running as early as `mix_job_start_time`, we cannot consume any frames
that are presented after `T = mix_job_start_time - upstream_delay`. Hence, we consume frames in
the range `[T - period, T)`.
In the diagram below, each `+` represents a frame ordered by presentation time, with
presentation time increasing to the right. The frames marked with `X` are consumed during the
mix job at `mix_job_start_time`.
```
downstream
|
<
-- period -->|
<
--- delay --->|
<
-- period -->| ...
frames: +++XXXXXXXXXXXXXXX++++++++++++++++++++++++++++++++++++
^ ^ ^
T mix job mix job
start time end time
```
Defined at line 31 of file ../../src/media/audio/services/mixer/mix/consumer_stage.cc
void set_downstream_delay (zx::duration delay)
Sets the delay introduced by our downstream external output device, such as a physical speaker.
This is Node::max_downstream_output_pipeline_delay().
REQUIRED: must have `pipeline_direction == kOutput`
Defined at line 91 of file ../../src/media/audio/services/mixer/mix/consumer_stage.cc
void set_upstream_delay_for_source (zx::duration delay)
Sets the delay introduced by our source input pipeline, not including any delays introduced by
this ConsumerStage. This is Node::max_upstream_input_pipeline_delay() in our *source* node.
REQUIRED: must have `pipeline_direction == kInput`
Defined at line 96 of file ../../src/media/audio/services/mixer/mix/consumer_stage.cc