From 5153dc3362348f40ed14a531c09e9e88d033764a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 18 Aug 2025 13:40:01 +0200 Subject: [PATCH] stream: emit RUNNING state from Start cd68819febdf27edfa2f8d4cda20858c5cf6c713 added code to follow the state change of the node because at the time it the Start code was async and it was better to complete it before emitting the state. 9b808558219f6dd37a1733c9720dcbd33178606e however made the Start command sync again and so we can safely emit the running state in the Start. The effect is that the Running state change is emitted first and then the node eventfd is added to the data loop that can then call the process callback. Having the process callback happen before the RUNNING state change is unexpected and racy. --- src/pipewire/stream.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pipewire/stream.c b/src/pipewire/stream.c index ddd53ebd0..4c279fe7b 100644 --- a/src/pipewire/stream.c +++ b/src/pipewire/stream.c @@ -719,6 +719,7 @@ static int impl_send_command(void *object, const struct spa_command *command) impl->io->status = SPA_STATUS_NEED_DATA; } copy_position(impl, impl->queued.incount); + stream_set_state(stream, PW_STREAM_STATE_STREAMING, 0, NULL); } break; default: @@ -1451,10 +1452,6 @@ static void node_state_changed(void *data, enum pw_node_state old, struct pw_stream *stream = data; switch (state) { - case PW_NODE_STATE_RUNNING: - if (stream->state == PW_STREAM_STATE_PAUSED) - stream_set_state(stream, PW_STREAM_STATE_STREAMING, 0, NULL); - break; case PW_NODE_STATE_ERROR: stream_set_state(stream, PW_STREAM_STATE_ERROR, -EIO, error); break;