[alsa-devel] opening a device multiple times?

James Courtier-Dutton james.dutton at gmail.com
Wed Jun 29 14:13:50 CEST 2011


On 29 June 2011 12:47, Ákos Maróy <akos at maroy.hu> wrote:
> Hi,
>
> I'm writing a piece of code that uses ALSA audio devices, where I open
> the same output device multiple times, as a simple way to have parallel
> audio channels, where I can send audio data to each 'channel' (PCM
> handle) simultaneously, and the ALSA layer will mix the audio together.
>
> My experience is that this works with some audio devices (for example,
> with a pulse audio - ALSA gateway), but not on some other devices (for
> example, on a USB sound device, driven by ALSA). In the latter case,
> snd_pcm_open() will refuse to open the audio device multiple times.
>
> I wonder what the generic concept here is - is it generally 'OK' to open
> an audio device multiple times? If not, why not? :)
>

It depends on the hardware.
The pulse audio is software, and supports multi open.
Some sound cards can only handle one PCM stream, others can handle
more. e.g. 32 opens before it fails.
If you are writing an application now, it is probably better to write
to the pulse audio API as this is present on most Linux desktops now,
and it has some extra features.
Pulse Audio then talks to ALSA and the hardware.


More information about the Alsa-devel mailing list