jack: client_thread_id should return the data thread

Add a function in data-loop to get the natvive thread and use that
in client_thread_id() so that it returns the pthread of the
data thread instead of the caller thread.
This commit is contained in:
Wim Taymans 2021-07-02 11:39:44 +02:00
parent 4b9b97841d
commit e2d6545e77
3 changed files with 24 additions and 1 deletions

View file

@ -3239,7 +3239,15 @@ int jack_get_client_pid (const char *name)
SPA_EXPORT
jack_native_thread_t jack_client_thread_id (jack_client_t *client)
{
return pthread_self();
struct client *c = (struct client *) client;
void *thr;
spa_return_val_if_fail(c != NULL, -EINVAL);
thr = pw_data_loop_get_thread(c->loop);
if (thr == NULL)
return pthread_self();
return *(pthread_t*)thr;
}
SPA_EXPORT

View file

@ -253,6 +253,18 @@ bool pw_data_loop_in_thread(struct pw_data_loop * loop)
return pthread_equal(loop->thread, pthread_self());
}
/** Get the thread object.
* \param loop the data loop to get the thread of
* \return the thread object or NULL when the thread is not running
*
* On posix based systems this returns a pthread_t *
*/
SPA_EXPORT
void *pw_data_loop_get_thread(struct pw_data_loop * loop)
{
return loop->running ? &loop->thread : NULL;
}
SPA_EXPORT
int pw_data_loop_invoke(struct pw_data_loop *loop,
spa_invoke_func_t func, uint32_t seq, const void *data, size_t size,

View file

@ -87,6 +87,9 @@ int pw_data_loop_stop(struct pw_data_loop *loop);
/** Check if the current thread is the processing thread */
bool pw_data_loop_in_thread(struct pw_data_loop *loop);
/** Get the thread object */
void *pw_data_loop_get_thread(struct pw_data_loop *loop);
/** invoke func in the context of the thread or in the caller thread when
* the loop is not running. Since 0.3.3 */
int pw_data_loop_invoke(struct pw_data_loop *loop,