thread: make it possible to set a custom create function

Make a property to pass a custom function pointer to create threads
instead of pthread_create.

Use this in jack instead of bypassing the thread utils create function,
which gives the wrong thread rt priority with rtkit.

Fixes #4099
This commit is contained in:
Wim Taymans 2024-07-09 17:04:35 +02:00
parent f357798715
commit 16f629d224
3 changed files with 23 additions and 20 deletions

View file

@ -90,10 +90,16 @@ static struct spa_thread *impl_create(void *object,
pthread_attr_t *attr = NULL, attributes;
const char *str;
int err;
int (*create_func)(pthread_t *, const pthread_attr_t *attr, void *(*start)(void*), void *) = NULL;
attr = pw_thread_fill_attr(props, &attributes);
err = pthread_create(&pt, attr, start, arg);
if (props == NULL ||
(str = spa_dict_lookup(props, SPA_KEY_THREAD_CREATOR)) == NULL ||
sscanf(str, "pointer:%p", &create_func) != 1)
create_func = pthread_create;
err = create_func(&pt, attr, start, arg);
if (attr)
pthread_attr_destroy(attr);