ao_pipewire: add EOF handling

This commit is contained in:
Misaki Kasumi 2024-04-22 23:22:20 +08:00 committed by sfan5
parent a3a9bc289a
commit 3fc8929caf
1 changed files with 7 additions and 1 deletions

View File

@ -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);
}