diff --git a/spa/plugins/support/loop.c b/spa/plugins/support/loop.c index 07e0bffff..17abad226 100644 --- a/spa/plugins/support/loop.c +++ b/spa/plugins/support/loop.c @@ -85,6 +85,7 @@ struct impl { struct spa_ratelimit rate_limit; int retry_timeout; + bool prio_inherit; union tag head; @@ -1371,9 +1372,6 @@ impl_init(const struct spa_handle_factory *factory, SPA_VERSION_LOOP_UTILS, &impl_loop_utils, impl); - CHECK(pthread_mutexattr_init(&attr), error_exit); - CHECK(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE), error_exit_free_attr); - impl->rate_limit.interval = 2 * SPA_NSEC_PER_SEC; impl->rate_limit.burst = 1; impl->retry_timeout = DEFAULT_RETRY; @@ -1383,13 +1381,15 @@ impl_init(const struct spa_handle_factory *factory, impl->control.iface.cb.funcs = &impl_loop_control_cancel; if ((str = spa_dict_lookup(info, "loop.retry-timeout")) != NULL) impl->retry_timeout = atoi(str); - if ((str = spa_dict_lookup(info, "loop.prio-inherit")) != NULL && - spa_atob(str)) { - CHECK(pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT), - error_exit_free_attr) - } + if ((str = spa_dict_lookup(info, "loop.prio-inherit")) != NULL) + impl->prio_inherit = spa_atob(str); } + CHECK(pthread_mutexattr_init(&attr), error_exit); + CHECK(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE), error_exit_free_attr); + if (impl->prio_inherit) + CHECK(pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT), + error_exit_free_attr) CHECK(pthread_mutex_init(&impl->lock, &attr), error_exit_free_attr); pthread_mutexattr_destroy(&attr); diff --git a/spa/plugins/support/node-driver.c b/spa/plugins/support/node-driver.c index c8777caa3..701a5b7bf 100644 --- a/spa/plugins/support/node-driver.c +++ b/spa/plugins/support/node-driver.c @@ -280,7 +280,7 @@ static int reassign_follower(struct impl *this) if (following != this->following) { spa_log_debug(this->log, "%p: reassign follower %d->%d", this, this->following, following); this->following = following; - spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); + spa_loop_locked(this->data_loop, do_set_timers, 0, NULL, 0, this); } return 0; } @@ -431,7 +431,7 @@ static int do_start(struct impl *this) this->following = is_following(this); this->started = true; this->last_time = 0; - spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); + spa_loop_locked(this->data_loop, do_set_timers, 0, NULL, 0, this); return 0; } @@ -440,7 +440,7 @@ static int do_stop(struct impl *this) if (!this->started) return 0; this->started = false; - spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); + spa_loop_locked(this->data_loop, do_set_timers, 0, NULL, 0, this); return 0; } @@ -573,7 +573,7 @@ static int impl_clear(struct spa_handle *handle) this = (struct impl *) handle; - spa_loop_invoke(this->data_loop, do_remove_timer, 0, NULL, 0, true, this); + spa_loop_locked(this->data_loop, do_remove_timer, 0, NULL, 0, this); spa_system_close(this->data_system, this->timer_source.fd); if (this->clock_fd != -1) diff --git a/spa/plugins/support/null-audio-sink.c b/spa/plugins/support/null-audio-sink.c index 997a66810..70edd4ff2 100644 --- a/spa/plugins/support/null-audio-sink.c +++ b/spa/plugins/support/null-audio-sink.c @@ -230,7 +230,7 @@ static int reassign_follower(struct impl *this) if (following != this->following) { spa_log_debug(this->log, "%p: reassign follower %d->%d", this, this->following, following); this->following = following; - spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); + spa_loop_locked(this->data_loop, do_set_timers, 0, NULL, 0, this); } return 0; } @@ -314,7 +314,7 @@ static int do_start(struct impl *this) this->following = is_following(this); this->started = true; - spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); + spa_loop_locked(this->data_loop, do_set_timers, 0, NULL, 0, this); return 0; } @@ -323,7 +323,7 @@ static int do_stop(struct impl *this) if (!this->started) return 0; this->started = false; - spa_loop_invoke(this->data_loop, do_set_timers, 0, NULL, 0, true, this); + spa_loop_locked(this->data_loop, do_set_timers, 0, NULL, 0, this); return 0; } @@ -847,7 +847,7 @@ static int impl_clear(struct spa_handle *handle) this = (struct impl *) handle; - spa_loop_invoke(this->data_loop, do_remove_timer, 0, NULL, 0, true, this); + spa_loop_locked(this->data_loop, do_remove_timer, 0, NULL, 0, this); spa_system_close(this->data_system, this->timer_source.fd); return 0; diff --git a/spa/plugins/v4l2/v4l2-utils.c b/spa/plugins/v4l2/v4l2-utils.c index 887094eff..58758f758 100644 --- a/spa/plugins/v4l2/v4l2-utils.c +++ b/spa/plugins/v4l2/v4l2-utils.c @@ -1928,7 +1928,7 @@ static int spa_v4l2_stream_off(struct impl *this) spa_log_debug(this->log, "stopping"); - spa_loop_invoke(this->data_loop, do_remove_source, 0, NULL, 0, true, port); + spa_loop_locked(this->data_loop, do_remove_source, 0, NULL, 0, port); type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (xioctl(dev->fd, VIDIOC_STREAMOFF, &type) < 0) {