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 36617fc833
commit ef40bb1d48

View file

@ -4720,6 +4720,17 @@ static int do_activate(struct client *c)
return res; 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 SPA_EXPORT
int jack_activate (jack_client_t *client) int jack_activate (jack_client_t *client)
{ {
@ -4760,8 +4771,12 @@ done:
if (res < 0) { if (res < 0) {
c->active = false; c->active = false;
pw_data_loop_stop(c->loop); 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); pw_log_debug("%p: activate result:%d", c, res);
thaw_callbacks(c); thaw_callbacks(c);
pw_thread_loop_unlock(c->context.loop); pw_thread_loop_unlock(c->context.loop);