alsa: use semaphore semantics for the eventfd

Because we write from multiple threads, a thread might write a second
wakeup and a concurrent thread might remove all wakeups before seeing
it's error and retrying, which would leave the eventfd in a wrong state.

With a semaphore, things balance out and the eventfd always ends up in
a consistent state.
This commit is contained in:
Wim Taymans 2024-05-06 16:23:07 +02:00
parent a30c27dce0
commit 6ab10237cd

View file

@ -1262,7 +1262,8 @@ static int snd_pcm_pipewire_open(snd_pcm_t **pcmp,
pw_core_add_listener(pw->core, &pw->core_listener, &core_events, pw); pw_core_add_listener(pw->core, &pw->core_listener, &core_events, pw);
pw_thread_loop_unlock(pw->main_loop); pw_thread_loop_unlock(pw->main_loop);
pw->fd = spa_system_eventfd_create(pw->system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); pw->fd = spa_system_eventfd_create(pw->system,
SPA_FD_EVENT_SEMAPHORE | SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
if (pw->fd < 0) { if (pw->fd < 0) {
err = pw->fd; err = pw->fd;
goto error; goto error;