alsamixer: Fix race condition that made alsamixer not working properly
authorAntoine Tremblay <hexa00@gmail.com>
Tue, 10 Feb 2009 10:00:12 +0000 (11:00 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 10 Feb 2009 10:00:12 +0000 (11:00 +0100)
commitfc23037a9aaf0beca99f9494948b2fb1169a03db
tree70bb2492a7b6baebc9b171222b5ab4b7eccf4d06
parent6e7fe156d8934c8dc1c14f166626cf255019bd8c
alsamixer: Fix race condition that made alsamixer not working properly

This is due to race conditions between functions that
modified the mixer like set_volume and
snd_mixer_handle_events since the handle_events
can now be called at any time.

Fixed by adding locking around any snd_mixer call
since even read functions can modify the mixer stucture, since
alsa likes to clear it's values before reading new ones.

The favorite race condition seemed to be that set_volume
called read_elem (in alsalib) that reset the volumes to
0 and then read them with read_x_volume. This read looped
on each channel and as the race condition occured the
channels value could be anything , most of the time
it was 0. Thus no value was read or only the value of
one channel was and the volume was reset to 0.

Fixes bug #478512.
ext/alsa/gstalsamixer.c