Topic
  • 1 reply
  • Latest Post - ‏2011-12-02T15:54:31Z by SystemAdmin
SystemAdmin
SystemAdmin
2364 Posts

Pinned topic ALSA configuration to enable device sharing between multiple processes

‏2011-11-22T05:37:55Z |
I have the following code in the .asoundrc file in my home directory -

pcm.lol
{
type dmix
ipc_key 1024
ipc_key_add_uid true
slave{
pcm "hw:0,0"
period_time 125000
rate 48000
format S32_LE
channels 2
}
}

When I run this sample example (http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html) it works fine (I changed the device name to plug:lol). I can hear a sound playing in my headphones. The problem occurs when two or more processes try to output audio data at the same time. In this case, the later process cannot output its audio data properly.

For example, I ran a media player which was playing a song and then I tried running that example. I couldn't hear any sound from it, all I could hear was the music playing in the media player. Similar thing happens when I run this example first and then the media player, in which case I only listen audio output from my example.

How can I solve this problem? Is there any error with my pcm device configuration? Or do I have to provide any additional PCM configuration parameters in the example code ?

Also, it would have been really nice if I could create this logical device configuration programmatically rather than using a configuration file like this.
Updated on 2011-12-02T15:54:31Z at 2011-12-02T15:54:31Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    2364 Posts

    Re: ALSA configuration to enable device sharing between multiple processes

    ‏2011-12-02T15:54:31Z  
    Typically ALSA does a pretty good job of supporting multiple programs with the defaults. Do you know how this .asoundrc file was generated? What distribution of Linux are you running?