Skip to contentSkip to conversation

opening a device multiple times?

DISCUSSION Ákos Maróy 2 participants 2 messages Jun 29, 2011

lore
Share & tools
lore
#0 lore raw

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? :)

Akos

#1 lore raw
Quoted 7 lines · Ákos Maróy

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.

Quoted 8 lines

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.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel