mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
support: add support for checking loop context
Add check for running the the loop context and thread. Add checks in filter and stream to avoid doing things when not run from the context main-loop because this can crash things when doing IPC from concurrent threads.
This commit is contained in:
parent
a6497839bb
commit
74831aa967
7 changed files with 147 additions and 2 deletions
|
|
@ -356,6 +356,13 @@ static void loop_leave(void *object)
|
|||
}
|
||||
}
|
||||
|
||||
static int loop_check(void *object)
|
||||
{
|
||||
struct impl *impl = object;
|
||||
pthread_t thread_id = pthread_self();
|
||||
return (impl->thread == 0 || pthread_equal(impl->thread, thread_id)) ? 1 : 0;
|
||||
}
|
||||
|
||||
static inline void free_source(struct source_impl *s)
|
||||
{
|
||||
detach_source(&s->source);
|
||||
|
|
@ -826,6 +833,7 @@ static const struct spa_loop_control_methods impl_loop_control = {
|
|||
.enter = loop_enter,
|
||||
.leave = loop_leave,
|
||||
.iterate = loop_iterate,
|
||||
.check = loop_check,
|
||||
};
|
||||
|
||||
static const struct spa_loop_utils_methods impl_loop_utils = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue