From 2e5d0d6e07b373445dfecc3bb59454d08d9439d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Date: Fri, 28 Oct 2022 03:13:04 +0200 Subject: [PATCH] ao_pipewire: reload ao on stream disconnect This allows the core of mpv to know about issues in the AO. Otherwise playback will just freeze as no more data callbacks are sent by PipeWire. Also it allows mpv to try to reconnect the AO or find another, working AO. --- audio/out/ao_pipewire.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/audio/out/ao_pipewire.c b/audio/out/ao_pipewire.c index 0bb0bed937..8fe11f6b33 100644 --- a/audio/out/ao_pipewire.c +++ b/audio/out/ao_pipewire.c @@ -223,6 +223,11 @@ static void on_state_changed(void *userdata, enum pw_stream_state old, enum pw_s MP_WARN(ao, "Stream in error state, trying to reload...\n"); ao_request_reload(ao); } + + if (state == PW_STREAM_STATE_UNCONNECTED && old != PW_STREAM_STATE_UNCONNECTED) { + MP_WARN(ao, "Stream disconnected, trying to reload...\n"); + ao_request_reload(ao); + } } static float spa_volume_to_mp_volume(float vol)