class ProducerStage
Defined at line 63 of file ../../src/media/audio/services/mixer/mix/producer_stage.h
A producer has zero source streams and a single destination stream.
## Starting, stopping, and timelines
Producers can be started and stopped. To simplify the implementation, a producer's Start and Stop
state are not exposed to downstream PipelineStages. Each ProducerStage uses two frame timelines:
* An *internal* frame timeline. This is defined relative to the Producer's media timeline, as
described in ../docs/timelines.md. FIDL commands use the media timeline directly, then get
translated to internal commands (Start, Stop) which use internal frames. The internal stage
uses this frame timeline.
* A *downstream* frame timeline. This is the same frame timeline used by our downstream
PipelineStage. Public methods (Read, Advance, presentation_time_to_frac_frame) use the
downstream frame timeline. Then, within AdvanceSourcesImpl and ReadImpl, we translate
downstream frames to internal frames on-the-fly.
This design makes it simpler to implement Start and Stop with frame accuracy. For example,
suppose we receive Start command that is scheduled to happen in the middle of a mix job. To
implement this accurately, the translation from downstream to internal frames needs to use one
function for all frames before the Start and a second function for all frames after the Start.
It's best to do this translation internally rather than force it on our downstream PipelineStage.
See additional discussion in ../docs/timelines.md.
The translation between downstream frame and presentation time is stored in
`presentation_time_to_frac_frame()`.
The translation between internal frame and presentation time is stored internally and not
exposed.
## Data production
This class does not directly produce any data. Instead, it is a wrapper around an internal
PipelineStage which produces data, typically a packet queue or ring buffer. This design allows us
to separate concerns and reuse code: ProducerStage handles Start and Stop commands and translates
between "downstream" and "internal" frame time, as described above, while the internal
PipelineStage runs on internal frame time and is responsible for actually producing data.
Public Methods
void ProducerStage (Args args)
Defined at line 19 of file ../../src/media/audio/services/mixer/mix/producer_stage.cc
void AddSource (PipelineStagePtr source, AddSourceOptions options)
Implements `PipelineStage`.
Defined at line 93 of file ../../src/media/audio/services/mixer/mix/producer_stage.h
void RemoveSource (PipelineStagePtr source)
Defined at line 96 of file ../../src/media/audio/services/mixer/mix/producer_stage.h
void UpdatePresentationTimeToFracFrame (std::optional<TimelineFunction> f)
Defined at line 132 of file ../../src/media/audio/services/mixer/mix/producer_stage.cc
Protected Methods
void AdvanceSelfImpl (Fixed frame)
Implements `PipelineStage`.
Defined at line 103 of file ../../src/media/audio/services/mixer/mix/producer_stage.h
void AdvanceSourcesImpl (MixJobContext & ctx, Fixed frame)
Defined at line 30 of file ../../src/media/audio/services/mixer/mix/producer_stage.cc
std::optional<Packet> ReadImpl (MixJobContext & ctx, Fixed start_frame, int64_t frame_count)
Defined at line 40 of file ../../src/media/audio/services/mixer/mix/producer_stage.cc