From 75b428ea55e9b719092c7c565d77c9afe70c1b65 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 9 Sep 2024 12:56:22 +0200 Subject: [PATCH] jack: emit buffer_size during jack_activate() JACK emits the bufsize callback from the processing thread while jack_activate() is called. Do the same with a blocking invoke. The GStreamer plugin relies on this and when it reives the bufsize callback later, it will error out. Fixes #4260 --- pipewire-jack/src/pipewire-jack.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 6dbf49d52..99040ecae 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -4537,6 +4537,17 @@ static int do_activate(struct client *c) return res; } +static int +do_emit_buffer_size(struct spa_loop *loop, + bool async, uint32_t seq, const void *data, size_t size, void *user_data) +{ + struct client *c = user_data; + c->buffer_frames = c->rt.position->clock.duration; + pw_log_debug("%p: emit buffersize %d", c, c->buffer_frames); + c->bufsize_callback(c->buffer_frames, c->bufsize_arg); + return 0; +} + SPA_EXPORT int jack_activate (jack_client_t *client) { @@ -4577,8 +4588,12 @@ done: if (res < 0) { c->active = false; pw_data_loop_stop(c->loop); + } else if (SPA_LIKELY(c->bufsize_callback != NULL)) { + pw_thread_loop_unlock(c->context.loop); + pw_data_loop_invoke(c->loop, + do_emit_buffer_size, SPA_ID_INVALID, NULL, 0, true, c); + pw_thread_loop_lock(c->context.loop); } - pw_log_debug("%p: activate result:%d", c, res); thaw_callbacks(c); pw_thread_loop_unlock(c->context.loop);