You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: vlc-video: Stop near a playlist track boundary can take up to 3 s (drain_abort reset races the stop) #1011
Found while looking at test_vlc_playlist_gap's stop_at_track_end_is_prompt failure listed on #838 (merge-group run 38850208674, Rust Tier 2 Linux ON): stopping at the end of a track took 2.068 s (state 1). State 1 is PLAYING and 2.068 s is where the test gives up (1000 × 2 ms), so the stop had not taken effect at all. That is not "slow under load" like the other #838 cases.
Location
plugins/vlc-video/vlc-video-source.c
drain_abort is a manual-reset event. vlcs_stop (and restart/next/prev/update/destroy) calls abort_drain (signal) so that vlcs_audio_play's pacing wait and vlcs_audio_drain (each up to MAX_DRAIN_MS = 3000 ms, on libVLC's audio thread) end at once, then calls libvlc_media_list_player_stop_, which waits for that thread.
vlcs_started does os_event_reset(c->drain_abort). It is attached to libvlc_MediaPlayerOpening (:1036), which libVLC fires on its event thread when the next playlist item opens, i.e. at a track boundary.
obs_source_media_stop queues MEDIA_ACTION_STOP; vlcs_stop runs on a later tick.
Race
Stop near a track boundary: vlcs_stop signals drain_abort, the next item's Opening event resets it right after, libVLC's audio thread re-enters a pacing/drain wait for up to 3 s, and libvlc_media_list_player_stop_ blocks behind it. The source still reports PLAYING meanwhile. Load makes that interleaving more likely, so it shows up as a flake in the merge queue (it removed #936 once).
Class
Race (stop not honored); user-visible as Stop/hotkey taking up to 3 s on a playlist.
Proposed fix
Do not let an asynchronous libVLC event undo a stop. E.g. an atomic stop_requested set by abort_drain callers that stop (and cleared by the calls that start playback: play, restart, update), with vlcs_started resetting drain_abort only when no stop is pending; or reset the event only from the OBS-side calls that start playback, never from the libVLC event thread.
Test
The ordering is not controllable from outside, so: a stress case (stop exactly at item boundaries, repeated) that fails before the fix, plus a deterministic unit test of the abort/reset logic once it is factored into a small helper. Refs #838, #301.
Activity
zackees commentedon Oct 16, 2026
Claiming: confirm with a repeated boundary-stop run, then fix as above (RED then GREEN).
test: A VLC Stop must survive the next item opening right after it (RED)
vlc-video: Keep a Stop in force when the next playlist item opens (GR…
test: A VLC Stop must survive the next item opening right after it (RED)
vlc-video: Keep a Stop in force when the next playlist item opens (GR…
vlc-video: Keep a Stop in force when the next playlist item opens (#1037