← Back to Pull requests

LibMedia: Give the media pipeline defined roles for producers/processors/sinks #9288

Closed
unknown closed this pull request without merging on May 13, 2026 07:05 UTC
View on GitHub
unknown unknown commented on May 06, 2026 21:20 UTC
Author

tl;dr: The main purpose of this change is to split up the process of mixing multi-track audio and the actual audio playback. Audio is mixed/processed into a queue by a thread in AudioPlaybackSink so that the data callback doesn't block.

The Big Changes

All parts of the pipeline dealing with raw media data (decoded video frames, float PCM audio) are now classified as producers, sinks or processors. Producers can be connected as inputs to sinks. Processors are both producers and sinks, and so can have an input connected to them, and have their output connected to a sink as input. This allows the entire pipeline to become modular so that any extra processing we need can be inserted at any stage, particularly before/after mixing of audio.

Speaking of mixing, that is now handled by a processor called AudioMixer. It is currently the only processor that can accept multiple inputs, and it mixes the connected inputs into a singular output stream of AudioBlocks. Later, instead of connecting directly to the AudioPlaybackSink, this will pass through a time scale modification processor for playback rate control.

Previously, SeekingStateHandler initiated a seek at the decoders and coordinated pausing/resuming of the sinks based on the state of those seeks. Now, the seek is initiated at the sink, and propagates up the pipeline to the initial producers. The pipeline then processes data up to the sink, which then notifies the PlaybackManager through a callback that new data is available. Each node in the pipeline ensures that data from prior to the initiated seek is discarded, so that the seek can be propagated synchronously all the way up to the initial producers to make sure that latency is still minimal.

Due to this change to the seeking, fast seeking must determine a timestamp to jump to _before_ initiating the seek, rather than after it has resolved. Thus, the demuxers now have a function to find the timestamp of random access point to jump to when fast seeking. Doing it this way allows the audio seeks to begin immediately instead of waiting for the video seek to complete, reducing latency for fast seeks.

However, FFmpeg's seek index uses the decode timestamps instead of presentation timestamps, and the decode timestamp of an H.264 keyframe can be less than its presentation timestamp. The side effect of this is that seeking to a timestamp that falls within the duration of a keyframe can result in an output frame with a timestamp later than the seek target, so the DisplayingVideoSink ends up with a nonexistent current frame. When using their seek index to look up the timestamp to jump to in this new fast seeking setup, we're _guaranteed_ to hit this edge case, so FFmpegDemuxer just defaults to the original seek timestamp instead of consulting the index. I don't believe that FFmpeg exposes PTS except by requesting a packet back, which requires both reading the underlying media data (we may still be waiting for it over the network), and copying the coded data out of that media data unnecessarily. My intention in the future is to implement an MP4 reader for MSE, then expand that to support plain old files later in order to enable fast seeking.

Diff: 400 lines (+300 / -100) across 5 files Reviewer: R-Goc Review duration: 9224m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 400 lines diff across 5 files
0.45
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.359
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #9288"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 44.7% (MEDIUM) · Higher = larger blast radius
44.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.7% · Safe to merge
17.7%