Realtime frame-clock for AV sync and animation.
Uses audio clock as master (audio glitches are more noticeable than video drops). Drives the animation system and frame pacing.
Architecture:
Audio Clock (master)
↓
Frame Pacer
↓
Video Frame Selection
↓
Frame Presentation
Summary
Functions
Returns a specification to start this module under a supervisor.
Get current AV drift in microseconds.
Report a video frame presentation (called by video renderer).
Start the frame clock.
Start ticking at the target FPS.
Get frame statistics.
Stop ticking.
Register a listener process that receives {:clock, :tick, %{frame: n, timestamp_us: us}}.
Unsubscribe a listener.
Update the audio master clock (called by audio output callback).
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Get current AV drift in microseconds.
@spec report_video_frame(clock_ref(), timestamp_us()) :: :ok
Report a video frame presentation (called by video renderer).
@spec start_link(keyword()) :: GenServer.on_start()
Start the frame clock.
@spec start_ticking(clock_ref()) :: :ok
Start ticking at the target FPS.
@spec stats(clock_ref()) :: %{ frame_count: non_neg_integer(), dropped_frames: non_neg_integer(), drift_us: integer(), target_fps: pos_integer() }
Get frame statistics.
@spec stop_ticking(clock_ref()) :: :ok
Stop ticking.
Register a listener process that receives {:clock, :tick, %{frame: n, timestamp_us: us}}.
Unsubscribe a listener.
@spec update_audio_clock(clock_ref(), timestamp_us()) :: :ok
Update the audio master clock (called by audio output callback).