From 3fc8929caf6ba4b89c849a8fcde76841f26d8584 Mon Sep 17 00:00:00 2001 From: Misaki Kasumi Date: Mon, 22 Apr 2024 23:22:20 +0800 Subject: [PATCH] ao_pipewire: add EOF handling --- audio/out/ao_pipewire.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/audio/out/ao_pipewire.c b/audio/out/ao_pipewire.c index a04ae9d3d0..7b094b3f65 100644 --- a/audio/out/ao_pipewire.c +++ b/audio/out/ao_pipewire.c @@ -206,7 +206,8 @@ static void on_process(void *userdata) #endif end_time -= pw_stream_get_nsec(p->stream) - time.now; - int samples = ao_read_data(ao, data, nframes, end_time, NULL, false, false); + bool eof; + int samples = ao_read_data(ao, data, nframes, end_time, &eof, false, false); b->size = samples; for (int i = 0; i < buf->n_datas; i++) { @@ -217,6 +218,11 @@ static void on_process(void *userdata) pw_stream_queue_buffer(p->stream, b); + if (eof) { + pw_stream_flush(p->stream, true); + ao_stop_streaming(ao); + } + MP_TRACE(ao, "queued %d of %d samples\n", samples, nframes); }