module-rt: Use magic value for user config prio

Instead of having the context priority hardcoded at 88.
This commit is contained in:
Robbert van der Helm 2022-01-16 16:49:03 +01:00
parent 674858cd6e
commit 4419baec45
3 changed files with 10 additions and 2 deletions

View file

@ -68,7 +68,9 @@ struct spa_thread_utils_methods {
/** get realtime priority range for threads created with \a props */ /** 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); 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); int (*acquire_rt) (void *data, struct spa_thread *thread, int priority);
/** drop realtime priority */ /** drop realtime priority */
int (*drop_rt) (void *data, struct spa_thread *thread); int (*drop_rt) (void *data, struct spa_thread *thread);

View file

@ -682,6 +682,11 @@ static int impl_acquire_rt(void *data, struct spa_thread *thread, int priority)
pthread_t pt = (pthread_t)thread; pthread_t pt = (pthread_t)thread;
pid_t pid; pid_t pid;
// See the docstring on `spa_thread_utils_methods::acquire_rt`
if (priority == -1) {
priority = impl->rt_prio;
}
if (impl->use_rtkit) { if (impl->use_rtkit) {
rtprio_limit = pw_rtkit_get_max_realtime_priority(impl->system_bus); rtprio_limit = pw_rtkit_get_max_realtime_priority(impl->system_bus);
if (rtprio_limit >= 0) if (rtprio_limit >= 0)

View file

@ -134,7 +134,8 @@ static int context_set_freewheel(struct pw_context *context, bool freewheel)
res = pw_thread_utils_drop_rt(thr); res = pw_thread_utils_drop_rt(thr);
} else { } else {
pw_log_info("%p: exit freewheel", context); 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) if (res < 0)
pw_log_info("%p: freewheel error:%s", context, spa_strerror(res)); pw_log_info("%p: freewheel error:%s", context, spa_strerror(res));