I want to playback some audio data using ALSA to a PCM device. As an example I have downloaded this sample example and run it in my PC. It works fine when no other process is currently using the sound card. But it doesn't play anything when some other process uses the audio device (i.e., media player playing songs) and shows following error -
Playback open error: Device or resource busy
Looking at the source code of this example I could say that the snd_pcm_open function at line 882 is throwing this error. It finds the device busy since another process is currently using it.
I also tried the reverse way - first started the example then tried to start a song. In this case the media player stays idle, showing "idle" just beside the progress bar (I am using Banshee). I am assuming that snd_pcm_open
gains exclusive right of the device resource so that no other process can use it.
But I don't want that. I want to play sound to a audio device without requiring any exclusive rights so that other processes in the PC can share the same device for outputting audio data.
How can I do that? How can I open a PCM device so that other processes can also share the same device?