audiotestsrc: Operate as follower too

Don't start the timer but fill buffers when following another driver.
This commit is contained in:
Jonas Holmberg 2025-12-16 13:15:00 +01:00
parent ee42b18226
commit 12b2e5d67c

View file

@ -113,6 +113,7 @@ struct impl {
struct props props; struct props props;
struct spa_io_clock *clock; struct spa_io_clock *clock;
struct spa_io_position *position; struct spa_io_position *position;
bool following;
struct spa_hook_list hooks; struct spa_hook_list hooks;
struct spa_callbacks callbacks; struct spa_callbacks callbacks;
@ -306,6 +307,8 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
default: default:
return -ENOENT; return -ENOENT;
} }
this->following = this->position && this->clock && this->position->clock.id != this->clock->id;
return 0; return 0;
} }
@ -422,7 +425,8 @@ static int make_buffer(struct impl *this)
this->sample_count += n_samples; this->sample_count += n_samples;
this->elapsed_time = SAMPLES_TO_TIME(this, this->sample_count); this->elapsed_time = SAMPLES_TO_TIME(this, this->sample_count);
set_timer(this, true); if (!this->following)
set_timer(this, true);
io->buffer_id = b->id; io->buffer_id = b->id;
io->status = SPA_STATUS_HAVE_DATA; io->status = SPA_STATUS_HAVE_DATA;
@ -475,7 +479,8 @@ static int impl_node_send_command(void *object, const struct spa_command *comman
this->elapsed_time = 0; this->elapsed_time = 0;
this->started = true; this->started = true;
set_timer(this, true); if (!this->following)
set_timer(this, true);
break; break;
} }
case SPA_NODE_COMMAND_Suspend: case SPA_NODE_COMMAND_Suspend:
@ -891,7 +896,7 @@ static inline void reuse_buffer(struct impl *this, struct port *port, uint32_t i
b->outstanding = false; b->outstanding = false;
spa_list_append(&port->empty, &b->link); spa_list_append(&port->empty, &b->link);
if (!this->props.live) if (!this->props.live && !this->following)
set_timer(this, true); set_timer(this, true);
} }
@ -966,7 +971,7 @@ static int impl_node_process(void *object)
io->buffer_id = SPA_ID_INVALID; io->buffer_id = SPA_ID_INVALID;
} }
if (!this->props.live) if (!this->props.live || this->following)
return make_buffer(this); return make_buffer(this);
else else
return SPA_STATUS_OK; return SPA_STATUS_OK;