libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
promeki::SDLPlayerMediaIO Class Reference

MediaIO sink that plays frames through SDL via FrameSync. More...

#include <sdlplayer.h>

Inheritance diagram for promeki::SDLPlayerMediaIO:
Collaboration diagram for promeki::SDLPlayerMediaIO:

Public Types

using UPtr = UniquePtr< SDLPlayerMediaIO >
 Unique-ownership pointer to an SDLPlayerMediaIO.
 

Public Member Functions

SDLPlayerWidgetwidget () const
 Returns the widget that owns this task.
 
SDLAudioOutputaudioOutput () const
 Returns the configured audio output.
 
bool useAudioClock () const
 True when the audio device drives timing.
 
void pause ()
 Pauses playback.
 
void resume ()
 Resumes playback after a pause.
 
void togglePause ()
 Convenience: calls pause or resume.
 
bool isPaused () const
 Returns true when the playback clock is paused.
 
Error describe (MediaIODescription *out) const override
 
Error proposeInput (const MediaDesc &offered, MediaDesc *preferred) const override
 
void cancelBlockingWork () override
 

Protected Member Functions

Error executeCmd (MediaIOCommandOpen &cmd) override
 
Error executeCmd (MediaIOCommandClose &cmd) override
 
Error executeCmd (MediaIOCommandWrite &cmd) override
 

Friends

class SDLPlayerWidget
 

Detailed Description

MediaIO sink that plays frames through SDL via FrameSync.

SDLPlayerMediaIO is a write-only MediaIO sink that consumes Frame objects via MediaIO::writeFrame(). It is always owned by an SDLPlayerWidget which provides both the render target and the user-facing controls (play/pause, focus routing, etc.) — clients should construct an SDLPlayerWidget rather than instantiating the backend directly.

Architecture
  • The strand worker does not pace per frame. executeCmd(Write) decodes compressed images and hands the frame to a FrameSync instance, then returns.
  • A dedicated pull thread drives FrameSync::pullFrame in a loop. The clock (SDL audio or wall) blocks the pull thread until each destination deadline; the output frame is then delivered to the SDLPlayerWidget for display and, if configured, to the SDLAudioOutput.
  • Back-pressure comes from FrameSync's input queue running in FrameSync::InputOverflowPolicy::Block mode.
  • Audio drift correction is real — the audio clock's rate ratio feeds FrameSync's audio resampler.
Thread Safety
Conditionally thread-safe. The dedicated worker thread, pull thread, and SDL event thread each touch a different subset of state, coordinated via FrameSync (lock-free queue), atomics on the clock state, and the SDL event-thread bounce for widget calls. Clients interact with the backend via the owning MediaIO sink, which marshals writeFrame() calls onto the worker — clients themselves may call from any thread.

Member Function Documentation

◆ pause()

void promeki::SDLPlayerMediaIO::pause ( )

Pauses playback.

Pauses the playback clock (which stops SDL audio consumption via SDLAudioClock::onPause) and tears down the pull thread so it isn't blocked on the clock. Safe to call from any thread; no-ops when no MediaIO is open or playback is already paused.

◆ resume()

void promeki::SDLPlayerMediaIO::resume ( )

Resumes playback after a pause.

Unpauses the clock and spawns a fresh pull thread. The base Clock's paused-offset accumulator rolls the deadline forward so the next output frame lands where it would have without the pause. No-op when no MediaIO is open or playback is not paused.


The documentation for this class was generated from the following file: