mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-10 13:30:05 -05:00
data-loop: add function to invoke
Add function that invokes the given function in the context of the thread or the caller thread depending on if the thread is running.
This commit is contained in:
parent
5e99e7da49
commit
cec26494f8
2 changed files with 19 additions and 0 deletions
|
|
@ -252,3 +252,16 @@ bool pw_data_loop_in_thread(struct pw_data_loop * loop)
|
|||
{
|
||||
return pthread_equal(loop->thread, pthread_self());
|
||||
}
|
||||
|
||||
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,
|
||||
bool block, void *user_data)
|
||||
{
|
||||
int res;
|
||||
if (loop->running)
|
||||
res = pw_loop_invoke(loop->loop, func, seq, data, size, block, user_data);
|
||||
else
|
||||
res = func(loop->loop->loop, false, seq, data, size, user_data);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@ 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);
|
||||
|
||||
/** 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,
|
||||
spa_invoke_func_t func, uint32_t seq, const void *data, size_t size,
|
||||
bool block, void *user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue