stream: emit RUNNING state from Start

cd68819feb 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.

9b80855821 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.
This commit is contained in:
Wim Taymans 2025-08-18 13:40:01 +02:00
parent 3643c468e4
commit 5153dc3362

View file

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