diff --git a/spa/include/spa/support/thread.h b/spa/include/spa/support/thread.h index 158fd4fc5..1bff45080 100644 --- a/spa/include/spa/support/thread.h +++ b/spa/include/spa/support/thread.h @@ -68,7 +68,9 @@ struct spa_thread_utils_methods { /** get realtime priority range for threads created with \a props */ int (*get_rt_range) (void *data, const struct spa_dict *props, int *min, int *max); - /** acquire realtime priority */ + /** acquire realtime priority, a priority of -1 refers to the priority + * configured in the realtime module + */ int (*acquire_rt) (void *data, struct spa_thread *thread, int priority); /** drop realtime priority */ int (*drop_rt) (void *data, struct spa_thread *thread); diff --git a/src/modules/module-rt.c b/src/modules/module-rt.c index 23458b592..a16405235 100644 --- a/src/modules/module-rt.c +++ b/src/modules/module-rt.c @@ -682,6 +682,11 @@ static int impl_acquire_rt(void *data, struct spa_thread *thread, int priority) pthread_t pt = (pthread_t)thread; pid_t pid; + // See the docstring on `spa_thread_utils_methods::acquire_rt` + if (priority == -1) { + priority = impl->rt_prio; + } + if (impl->use_rtkit) { rtprio_limit = pw_rtkit_get_max_realtime_priority(impl->system_bus); if (rtprio_limit >= 0) diff --git a/src/pipewire/context.c b/src/pipewire/context.c index 365f39a42..123a7ba54 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -134,7 +134,8 @@ static int context_set_freewheel(struct pw_context *context, bool freewheel) res = pw_thread_utils_drop_rt(thr); } else { pw_log_info("%p: exit freewheel", context); - res = pw_thread_utils_acquire_rt(thr, 88); + // Use the priority as configured within the realtime module + res = pw_thread_utils_acquire_rt(thr, -1); } if (res < 0) pw_log_info("%p: freewheel error:%s", context, spa_strerror(res));