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
This commit is contained in:
Wim Taymans 2024-09-09 12:56:22 +02:00
parent 2c905fc548
commit 75b428ea55

View file

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