loop: add method to run a function with the lock

Convert some _invoke to _locked
This commit is contained in:
Wim Taymans 2025-03-10 17:24:13 +01:00
parent fb49e0795c
commit f7fdafc203
18 changed files with 99 additions and 57 deletions

View file

@ -684,7 +684,7 @@ static void stop_driver_timer(struct impl *this)
/* Perform the actual stop within
* the dataloop to avoid data races. */
spa_loop_invoke(this->data_loop, do_remove_driver_timer_source, 0, NULL, 0, true, this);
spa_loop_locked(this->data_loop, do_remove_driver_timer_source, 0, NULL, 0, this);
}
static void on_driver_timeout(struct spa_source *source)
@ -795,7 +795,7 @@ static void reevaluate_following_state(struct impl *this)
if (following != this->following) {
spa_log_debug(this->log, "%p: following state changed: %d->%d", this, this->following, following);
this->following = following;
spa_loop_invoke(this->data_loop, do_reevaluate_following_state, 0, NULL, 0, true, this);
spa_loop_locked(this->data_loop, do_reevaluate_following_state, 0, NULL, 0, this);
}
}

View file

@ -3739,7 +3739,7 @@ int spa_alsa_start(struct state *state)
}
state->started = true;
spa_loop_invoke(state->data_loop, do_state_sync, 0, NULL, 0, true, state);
spa_loop_locked(state->data_loop, do_state_sync, 0, NULL, 0, state);
return 0;
}
@ -3783,7 +3783,7 @@ int spa_alsa_reassign_follower(struct state *state)
}
setup_matching(state);
if (state->started)
spa_loop_invoke(state->data_loop, do_state_sync, 0, NULL, 0, true, state);
spa_loop_locked(state->data_loop, do_state_sync, 0, NULL, 0, state);
else if (state->want_started)
spa_alsa_start(state);
@ -3812,7 +3812,7 @@ int spa_alsa_pause(struct state *state)
spa_log_debug(state->log, "%p: pause", state);
state->started = false;
spa_loop_invoke(state->data_loop, do_state_sync, 0, NULL, 0, true, state);
spa_loop_locked(state->data_loop, do_state_sync, 0, NULL, 0, state);
spa_list_for_each(follower, &state->followers, driver_link)
spa_alsa_pause(follower);

View file

@ -1176,7 +1176,7 @@ int spa_alsa_seq_reassign_follower(struct seq_state *state)
if (following != state->following) {
spa_log_debug(state->log, "alsa %p: reassign follower %d->%d", state, state->following, following);
state->following = following;
spa_loop_invoke(state->data_loop, do_reassign_follower, 0, NULL, 0, true, state);
spa_loop_locked(state->data_loop, do_reassign_follower, 0, NULL, 0, state);
}
return 0;
}
@ -1205,7 +1205,7 @@ int spa_alsa_seq_pause(struct seq_state *state)
spa_log_debug(state->log, "alsa %p: pause", state);
spa_loop_invoke(state->data_loop, do_remove_source, 0, NULL, 0, true, state);
spa_loop_locked(state->data_loop, do_remove_source, 0, NULL, 0, state);
if ((res = snd_seq_stop_queue(state->event.hndl, state->event.queue_id, NULL)) < 0) {
spa_log_warn(state->log, "failed to stop queue: %s", snd_strerror(res));