diff --git a/spa/plugins/support/node-driver.c b/spa/plugins/support/node-driver.c index 466378e11..b9538e2d4 100644 --- a/spa/plugins/support/node-driver.c +++ b/spa/plugins/support/node-driver.c @@ -149,7 +149,7 @@ static int set_timers(struct impl *this) spa_log_debug(this->log, "%p now:%"PRIu64, this, this->next_time); - if (this->following) { + if (this->following || !this->started) { set_timeout(this, 0); } else { set_timeout(this, this->next_time); @@ -162,7 +162,7 @@ static inline bool is_following(struct impl *this) return this->position && this->clock && this->position->clock.id != this->clock->id; } -static int do_reassign_follower(struct spa_loop *loop, +static int do_set_timers(struct spa_loop *loop, bool async, uint32_t seq, const void *data, @@ -189,7 +189,7 @@ static int reassign_follower(struct impl *this) if (following != this->following) { spa_log_debug(this->log, NAME" %p: reassign follower %d->%d", this, this->following, following); this->following = following; - spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this); + spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); } return 0; } @@ -323,9 +323,9 @@ static int do_start(struct impl *this) return 0; this->following = is_following(this); - set_timers(this); this->started = true; this->last_time = 0; + spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); return 0; } @@ -334,7 +334,7 @@ static int do_stop(struct impl *this) if (!this->started) return 0; this->started = false; - set_timeout(this, 0); + spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); return 0; } diff --git a/spa/plugins/support/null-audio-sink.c b/spa/plugins/support/null-audio-sink.c index ee4ffe362..8c11774b3 100644 --- a/spa/plugins/support/null-audio-sink.c +++ b/spa/plugins/support/null-audio-sink.c @@ -191,7 +191,7 @@ static int set_timers(struct impl *this) return res; this->next_time = SPA_TIMESPEC_TO_NSEC(&now); - if (this->following) { + if (this->following || !this->started) { set_timeout(this, 0); } else { set_timeout(this, this->next_time); @@ -204,7 +204,7 @@ static inline bool is_following(struct impl *this) return this->position && this->clock && this->position->clock.id != this->clock->id; } -static int do_reassign_follower(struct spa_loop *loop, +static int do_set_timers(struct spa_loop *loop, bool async, uint32_t seq, const void *data, @@ -227,7 +227,7 @@ static int reassign_follower(struct impl *this) if (following != this->following) { spa_log_debug(this->log, NAME" %p: reassign follower %d->%d", this, this->following, following); this->following = following; - spa_loop_invoke(this->data_loop, do_reassign_follower, 0, NULL, 0, true, this); + spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); } return 0; } @@ -310,8 +310,8 @@ static int do_start(struct impl *this) return 0; this->following = is_following(this); - set_timers(this); this->started = true; + spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); return 0; } @@ -320,7 +320,7 @@ static int do_stop(struct impl *this) if (!this->started) return 0; this->started = false; - set_timeout(this, 0); + spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); return 0; }