From 4419baec45145c3ad58e18c242f18bbf3c56b5f9 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 16 Jan 2022 16:49:03 +0100 Subject: [PATCH] module-rt: Use magic value for user config prio Instead of having the context priority hardcoded at 88. --- spa/include/spa/support/thread.h | 4 +++- src/modules/module-rt.c | 5 +++++ src/pipewire/context.c | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) 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));