Re: [alsa-devel] Opening a PCM device in shared mode
Hi Anders,
Thanks for your reply. I have created a /*.asoundrc*/ file in my home directory as you suggested and added the following configuration there (as you can see, these are basically the exact default configuration that the dmix plugin has) -
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 } }
Now when I start my program while a media player is running, it doesn't show any /*Device or Resource busy */error. It successfully opens the device and starts to write the sine wave into it. But the problem is I can't hear its output. I should have heard two sounds simultaneously but I can only hear the song in the media player, not the output sound from the example program. Similar things happens when I start the example first and the start a media player, I can only hear sounds from the first one.
Also, when I try to run the example program on different rate (i.e., rate 8000, channel 1) it throws an error saying format doesn't match. I guess it's because of the configuration rate that I specified in the file. I tried to supply multiple values for rate using array notations ( rate [8000, 48000] ) but it threw an error telling that the /*.asoundrc */file is corrupted or old.
Actually the whole point of my exploration is this - I want to display a list of available audio cards/devices in my system to my application user who will then select the input and output audio card to record/playback audio data accordingly.
Thank you.
Regards, Sayem Ahmed
On 11/21/2011 01:41 PM, Anders Gnistrup wrote:
Hi Sayem
It's because you open the device plughw:0,0. It's actually the device hw:0,0 with a additional "plug" pluggin. The plug pluggin takes care of resampling. Devices is not mixing device by design. This is handled by plugins (the dmix plugin)
What you want is a device that can mix (and possible resample). For that you need a new virtual device. I have had the same problem myself, and the solution I have used is a .asoundrc configuration.
pcm.mydmix { type dmix ipc_key 1024 slave { pcm "hw:0,0" period_time 0 period_size 1024 buffer_size 8192 rate 44100 format "S32_LE" } }
Instead of the slave definition you could make your own. Now the device mydmix can be used as a mixing device.
Sayem Ahmed wrote:
Also, when I try to run the example program on different rate (i.e., rate 8000, channel 1) it throws an error saying format doesn't match.
The "default" device for your hardware should have the plug plugin on top of the dmix plugin.
Actually the whole point of my exploration is this - I want to display a list of available audio cards/devices in my system to my application user who will then select the input and output audio card to record/playback audio data accordingly.
This is the job of the desktop environment. Is there a reason why your application needs to duplicate this?
Regards, Clemens
On 11/24/2011 11:31 PM, Clemens Ladisch wrote:
Is there a reason why your application needs to duplicate this?
Yes. Clients would like to install multiple sound cards into their system so that they can perform multiple VoIP calls at the same time. For each call a different sound card will be used. This is why I need this functionality in my application.
Sayem Ahmed wrote:
On 11/24/2011 11:31 PM, Clemens Ladisch wrote:
Is there a reason why your application needs to duplicate this?
Yes. Clients would like to install multiple sound cards into their system so that they can perform multiple VoIP calls at the same time.
Use snd_card_next() to enumerate cards. To open the default device of a specific card, try device name "default:CARD=x", but this won't work if the user has redefined the "default" device definition.
Regards, Clemens
participants (2)
-
Clemens Ladisch
-
Sayem Ahmed