Skip to content

Fix --audio-wait-open with silent lead-in on open - #18890

Open
ThatDevopsGuy wants to merge 1 commit into
mpv-player:masterfrom
ThatDevopsGuy:audio-wait-open
Open

ThatDevopsGuy wants to merge 1 commit into
mpv-player:masterfrom
ThatDevopsGuy:audio-wait-open

Conversation

@ThatDevopsGuy

Copy link
Copy Markdown

This PR, specifically:

  • Fixes bug where passing --audio-wait-open=<secs> to let an HDMI/eARC receiver lock onto a new stream causes the option to be completely ignored (cutting off the first ~0.4–1.5 s of audio), by streaming silence as soon as the audio device opens and holding playback start until the wait period elapses.

Files changed:

  • audio/out/ao.h - Added the AO_INIT_WAIT_OPEN init flag by defining 1 << 5 in the AO init enum to signal that an AO should emit silence immediately upon open until ao_start().
  • audio/out/buffer.c - Modified struct buffer_state, init_buffer_post(), ao_play_data(), ao_thread(), ao_reset(), ao_start(), and ao_set_paused() by tracking wait_open_silence, starting pull AOs immediately on open, and pacing push-AO silence slices up to ~40 ms delay to stream continuous silent lead-in during --audio-wait-open.
  • player/audio.c - Modified reinit_audio_filters_and_output(), ao_chain_reset_state(), and fill_audio_out_buffers() by setting AO_INIT_WAIT_OPEN, guarding ao_resume_time against untimed AOs, clearing it on state reset, and holding STATUS_SYNCING via mp_set_timeout() until ao_resume_time elapses to make --audio-wait-open actually delay playback start.
  • DOCS/man/options.rst - Modified the --audio-wait-open=<secs> entry by documenting immediate timed silent lead-in without requiring --audio-stream-silence=yes and noting untimed/encode exclusions to keep user docs accurate.

Why this was done:

I frequently encounter issues with outputting HD audio via passthrough mode where high bitrate sections drop-out briefly (<100 ms). This PR pertains specifically to improving user experience when the AV receiver needs a few extra seconds to actually switch into the correct playback mode, which is related to solving "poor AVR <=> mpv performance" in general.

I used Gemini 4 Neon in combination with Antigravity and a microphone-assisted audio testing harness to iterate over these issues. I've manually reviewed the code changes and kept messages clean and sane for human reviewers (though I am copying this exact text in all the PRs).

Since b74c09e refactored AO data passing into async queues,
ao_c->ao_resume_time was set from --audio-wait-open on AO init but
never checked before transitioning STATUS_SYNCING to STATUS_READY,
leaving the option non-functional.

Add AO_INIT_WAIT_OPEN so timed pull and push AOs stream silence
immediately on open until ao_start() is called, and hold
STATUS_SYNCING in fill_audio_out_buffers() via mp_set_timeout() until
ao_resume_time elapses. Clear ao_resume_time on audio state resets and
update the --audio-wait-open documentation accordingly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant