[alsa-devel] opening a device multiple times?
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
On 29 June 2011 12:47, Ákos Maróy akos@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.
participants (2)
-
James Courtier-Dutton
-
Ákos Maróy