diff --git a/spa/plugins/alsa/alsa-pcm-sink.c b/spa/plugins/alsa/alsa-pcm-sink.c index 7ef1b6a63..aa8105ab1 100644 --- a/spa/plugins/alsa/alsa-pcm-sink.c +++ b/spa/plugins/alsa/alsa-pcm-sink.c @@ -873,7 +873,12 @@ impl_init(const struct spa_handle_factory *factory, this->data_system = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataSystem); this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop); + this->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop); + if (this->main_loop == NULL) { + spa_log_error(this->log, "a main loop is needed"); + return -EINVAL; + } if (this->data_loop == NULL) { spa_log_error(this->log, "a data loop is needed"); return -EINVAL; diff --git a/spa/plugins/alsa/alsa-pcm-source.c b/spa/plugins/alsa/alsa-pcm-source.c index b0df17c30..0a8ffec49 100644 --- a/spa/plugins/alsa/alsa-pcm-source.c +++ b/spa/plugins/alsa/alsa-pcm-source.c @@ -829,7 +829,12 @@ impl_init(const struct spa_handle_factory *factory, this->data_system = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataSystem); this->data_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataLoop); + this->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop); + if (this->main_loop == NULL) { + spa_log_error(this->log, "a main loop is needed"); + return -EINVAL; + } if (this->data_loop == NULL) { spa_log_error(this->log, "%p: a data loop is needed", this); return -EINVAL; diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 2830b1aca..e2d7835bb 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -706,7 +706,7 @@ static void bind_ctls_for_params(struct state *state) state->ctl_sources[i].fd = pfds[i].fd; state->ctl_sources[i].mask = SPA_IO_IN; state->ctl_sources[i].rmask = 0; - spa_loop_add_source(state->data_loop, &state->ctl_sources[i]); + spa_loop_add_source(state->main_loop, &state->ctl_sources[i]); } for (unsigned int i = 0; i < state->num_bind_ctls; i++) { @@ -839,7 +839,7 @@ int spa_alsa_clear(struct state *state) if (state->ctl) { for (int i = 0; i < state->ctl_n_fds; i++) { - spa_loop_remove_source(state->data_loop, &state->ctl_sources[i]); + spa_loop_remove_source(state->main_loop, &state->ctl_sources[i]); } snd_ctl_close(state->ctl); diff --git a/spa/plugins/alsa/alsa-pcm.h b/spa/plugins/alsa/alsa-pcm.h index 599628e7d..c3cfe0e51 100644 --- a/spa/plugins/alsa/alsa-pcm.h +++ b/spa/plugins/alsa/alsa-pcm.h @@ -105,6 +105,7 @@ struct state { struct spa_log *log; struct spa_system *data_system; struct spa_loop *data_loop; + struct spa_loop *main_loop; FILE *log_file; struct spa_ratelimit rate_limit;