[alsa-devel] Races in alsa-lib with threads

Jaroslav Kysela perex at perex.cz
Sun Nov 11 17:35:10 CET 2012


Date 10.11.2012 14:53, Takashi Iwai wrote:
> At Fri, 9 Nov 2012 18:03:25 -0800,
> Trent Piepho wrote:
>>
>> We've found a race with alsa-lib functions are called from multiple
>> threads.  I was under the impression that alsa-lib was supposed to be
>> thread safe.  Is this not the case and all alsa calls should be done
>> one from thread or protected by a mutex?
> 
> Yes.  alsa-lib isn't thread-safe.

The alsa-lib is designed to be thread safe but the calls for one handle
(PCM, control, rawmidi etc.) should be serialized using mutexes in apps.
Or basically, it's assumed that one thread will maintain one handle.

This should be documented somewhere.

					Jaroslav

-- 
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.


More information about the Alsa-devel mailing list