mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-14 20:02:38 +00:00
alsa: remove racy atomic operations
The atomic operations were used in an attempt to limit the amount of wakeups done on the eventfd. It's however racy and causes trouble in some cases. Remove the atomic operations all together, it's probably not worth optimizing this too much.
This commit is contained in:
parent
68ed40570d
commit
62aa77d469
|
@ -58,8 +58,6 @@ typedef struct {
|
||||||
unsigned int hw_params_changed:1;
|
unsigned int hw_params_changed:1;
|
||||||
unsigned int negotiated:1;
|
unsigned int negotiated:1;
|
||||||
|
|
||||||
bool active;
|
|
||||||
|
|
||||||
snd_pcm_uframes_t hw_ptr;
|
snd_pcm_uframes_t hw_ptr;
|
||||||
snd_pcm_uframes_t boundary;
|
snd_pcm_uframes_t boundary;
|
||||||
snd_pcm_uframes_t min_avail;
|
snd_pcm_uframes_t min_avail;
|
||||||
|
@ -94,9 +92,9 @@ static int update_active(snd_pcm_ioplug_t *io)
|
||||||
{
|
{
|
||||||
snd_pcm_pipewire_t *pw = io->private_data;
|
snd_pcm_pipewire_t *pw = io->private_data;
|
||||||
snd_pcm_sframes_t avail;
|
snd_pcm_sframes_t avail;
|
||||||
bool active, old;
|
bool active;
|
||||||
|
uint64_t val;
|
||||||
|
|
||||||
retry:
|
|
||||||
avail = snd_pcm_ioplug_avail(io, pw->hw_ptr, io->appl_ptr);
|
avail = snd_pcm_ioplug_avail(io, pw->hw_ptr, io->appl_ptr);
|
||||||
|
|
||||||
if (pw->error > 0) {
|
if (pw->error > 0) {
|
||||||
|
@ -114,13 +112,10 @@ retry:
|
||||||
else {
|
else {
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
old = SPA_ATOMIC_LOAD(pw->active);
|
|
||||||
if (old != active) {
|
|
||||||
uint64_t val;
|
|
||||||
|
|
||||||
pw_log_trace("%p: avail:%lu min-avail:%lu state:%s hw:%lu appl:%lu active:%d->%d state:%s",
|
pw_log_trace("%p: avail:%lu min-avail:%lu state:%s hw:%lu appl:%lu active:%d state:%s",
|
||||||
pw, avail, pw->min_avail, snd_pcm_state_name(io->state),
|
pw, avail, pw->min_avail, snd_pcm_state_name(io->state),
|
||||||
pw->hw_ptr, io->appl_ptr, pw->active, active,
|
pw->hw_ptr, io->appl_ptr, active,
|
||||||
snd_pcm_state_name(io->state));
|
snd_pcm_state_name(io->state));
|
||||||
|
|
||||||
if (active)
|
if (active)
|
||||||
|
@ -128,9 +123,6 @@ retry:
|
||||||
else
|
else
|
||||||
spa_system_eventfd_read(pw->system, io->poll_fd, &val);
|
spa_system_eventfd_read(pw->system, io->poll_fd, &val);
|
||||||
|
|
||||||
if (!SPA_ATOMIC_CAS(pw->active, old, active))
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1263,7 +1255,7 @@ static int snd_pcm_pipewire_open(snd_pcm_t **pcmp,
|
||||||
pw_thread_loop_unlock(pw->main_loop);
|
pw_thread_loop_unlock(pw->main_loop);
|
||||||
|
|
||||||
pw->fd = spa_system_eventfd_create(pw->system,
|
pw->fd = spa_system_eventfd_create(pw->system,
|
||||||
SPA_FD_EVENT_SEMAPHORE | SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||||
if (pw->fd < 0) {
|
if (pw->fd < 0) {
|
||||||
err = pw->fd;
|
err = pw->fd;
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in a new issue