mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
module-x11-bell: protect libcanberra calls with a mutex
The libcanberra calls use libtool, which can not be called from multiple threads at the same time. Use a global lock to serialize these calls in the x11-bell module. This is only a problem when multiple libcanberra calls are made in the same process, such when you load the x11-bell module twice. There is no guarantee that other libcanberra calls will not interfere but for now we only use libcanberra here. Fixes #2834
This commit is contained in:
parent
da464853e5
commit
893b46c0d0
1 changed files with 6 additions and 0 deletions
|
|
@ -62,6 +62,10 @@
|
|||
PW_LOG_TOPIC_STATIC(mod_topic, "mod." NAME);
|
||||
#define PW_LOG_TOPIC_DEFAULT mod_topic
|
||||
|
||||
/* libcanberra is not thread safe when doing ca_context_create()
|
||||
* and so we need a global lock */
|
||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
struct impl {
|
||||
struct pw_context *context;
|
||||
struct pw_thread_loop *thread_loop;
|
||||
|
|
@ -83,6 +87,7 @@ static int play_sample(struct impl *impl)
|
|||
ca_context *ca;
|
||||
int res;
|
||||
|
||||
pthread_mutex_lock(&lock);
|
||||
if (impl->properties)
|
||||
sample = pw_properties_get(impl->properties, "sample.name");
|
||||
if (sample == NULL)
|
||||
|
|
@ -113,6 +118,7 @@ static int play_sample(struct impl *impl)
|
|||
exit_destroy:
|
||||
ca_context_destroy(ca);
|
||||
exit:
|
||||
pthread_mutex_unlock(&lock);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue