audioconvert: use a new boolean to check if ready

Use a new boolean to check if the follower is allowed to emit a ready
event. This can be done right after negotiating.

Set the started field to true after we finish setting the state of the
converter and follower. This fields is used to block calling into the
process function before we complete the setup.

This avoid a crash in always-process nodes when the node is scheduled
before the audioconverter completes setup.
This commit is contained in:
Wim Taymans 2023-04-25 18:00:13 +02:00
parent ecbb1b0c4c
commit b9381a9da6

View file

@ -87,6 +87,7 @@ struct impl {
unsigned int add_listener:1;
unsigned int have_format:1;
unsigned int started:1;
unsigned int ready:1;
unsigned int driver:1;
unsigned int async:1;
unsigned int passthrough:1;
@ -842,14 +843,16 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
return res;
if ((res = negotiate_buffers(this)) < 0)
return res;
this->started = true;
this->ready = true;
break;
case SPA_NODE_COMMAND_Suspend:
this->started = false;
this->ready = false;
spa_log_debug(this->log, "%p: suspending", this);
break;
case SPA_NODE_COMMAND_Pause:
this->started = false;
this->ready = false;
spa_log_debug(this->log, "%p: pausing", this);
break;
case SPA_NODE_COMMAND_Flush:
@ -877,6 +880,7 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
}
switch (SPA_NODE_COMMAND_ID(command)) {
case SPA_NODE_COMMAND_Start:
this->started = true;
spa_log_debug(this->log, "%p: started", this);
break;
case SPA_NODE_COMMAND_Suspend:
@ -1211,7 +1215,7 @@ static int follower_ready(void *data, int status)
spa_log_trace_fp(this->log, "%p: ready %d", this, status);
if (!this->started) {
if (!this->ready) {
spa_log_info(this->log, "%p: ready stopped node", this);
return -EIO;
}