class StartStopControl
Defined at line 26 of file ../../src/media/audio/services/mixer/mix/start_stop_control.h
Controls an audio stream using Start and Stop commands. Commands can be scheduled to happen in
the future. At most one command (Start or Stop) can be pending at any time.
Public Methods
void StartStopControl (const Format & format, TimelineRate media_ticks_per_ns, UnreadableClock reference_clock)
Defined at line 16 of file ../../src/media/audio/services/mixer/mix/start_stop_control.cc
void CancelCommand (Command & cmd)
static
Defined at line 25 of file ../../src/media/audio/services/mixer/mix/start_stop_control.cc
void Start (StartCommand cmd)
Queues a Start or Stop command. The command will remain pending until it is scheduled to occur.
It is not allowed to queue a Start or Stop command while another command is already pending.
If a Start command arrives while the control is already started, the Start command behaves as
if it was preceded instantaneously by a Stop.
If a Stop command arrives while the control is already stopped, the Stop command fails with
error code kAlreadyStopped.
Defined at line 33 of file ../../src/media/audio/services/mixer/mix/start_stop_control.cc
void Stop (StopCommand cmd)
Defined at line 38 of file ../../src/media/audio/services/mixer/mix/start_stop_control.cc
std::optional<TimelineFunction> presentation_time_to_frac_frame ()
Returns a function that translates from reference clock presentation time to frame time, where
frame time is represented by a `Fixed::raw_value()` while presentation time is represented by a
`zx::time`.
Returns std::nullopt if the control is stopped.
Defined at line 49 of file ../../src/media/audio/services/mixer/mix/start_stop_control.cc
void AdvanceTo (const ClockSnapshots & clocks, zx::time reference_time)
Applies all commands scheduled to happen at or before `reference_time`, then advances our
current time to `reference_time`.
REQUIRED: `reference_time` is >= the last advanced-to time
Defined at line 56 of file ../../src/media/audio/services/mixer/mix/start_stop_control.cc
std::optional<std::pair<When, CommandType>> PendingCommand (const ClockSnapshots & clocks)
Defined at line 94 of file ../../src/media/audio/services/mixer/mix/start_stop_control.cc
bool is_started ()
Reports if the command is currently started.
Defined at line 111 of file ../../src/media/audio/services/mixer/mix/start_stop_control.h
Enumerations
enum WhichClock
| Name | Value |
|---|---|
| kSystemMonotonic | 0 |
| kReference | 1 |
Defined at line 31 of file ../../src/media/audio/services/mixer/mix/start_stop_control.h
enum StartError
| Name | Value |
|---|---|
| kCanceled | 0 |
An error returned by Start.
Defined at line 59 of file ../../src/media/audio/services/mixer/mix/start_stop_control.h
enum StopError
| Name | Value |
|---|---|
| kCanceled | 0 |
| kAlreadyStopped | 1 |
An error returned by Stop.
Defined at line 64 of file ../../src/media/audio/services/mixer/mix/start_stop_control.h
enum CommandType
| Name | Value |
|---|---|
| kStart | 0 |
| kStop | 1 |
Reports if there is a command scheduled to execute. If so, returns the scheduled times and the
type of the next command.
If the next command is scheduled a long ways in the future on the system monotonic clock, the
returned time may be inaccurate because the reference clock may change rate in unpredictable
ways between now and the time the command is scheduled. In the worst case, the
time-until-scheduled may be off by 0.2% (the maximum rate slew of a zx::clock).
REQUIRED: `AdvanceTo` must called at least once before this method (we need a "current time" to
report a scheduled time for commands that happen "immediately" and before the first AdvanceTo,
the current time is unknown).
Defined at line 137 of file ../../src/media/audio/services/mixer/mix/start_stop_control.h