alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Join play of pcm in multiple playback devices
@ 2012-01-03  6:24 Irfan shaikh
  2012-01-03 21:32 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 2+ messages in thread
From: Irfan shaikh @ 2012-01-03  6:24 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

Hello All,

              I have written an application which supports join play of 
PCM Audio.
i.e Capture and write to playback device 1 and playback device 2 
simultaneously.

Below code is just to explain the above scenario :

/######################/

while(1)
{
     retval=snd_pcm_readi(pAlsaConfig->pcm_handle, buffer, 
pAlsaConfig->alsaBufferSize);
     snd_pcm_writei(pAlsaConfig->pcm_handle1, buffer,retval);
     snd_pcm_writei(pAlsaConfig->pcm_handle2, buffer,retval);
}

/######################/

In above case, renderer 2 lags behind the renderer 1 i.e there is delay 
between two audio devices when actually heard.


Please help me if some better implementation for join play.
I have seen some thing as snd_pcm_link(). But i was not clear with its 
usage, while doing snd_pcm_writei ???

Thanks and regards,
Irfan

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Join play of pcm in multiple playback devices
  2012-01-03  6:24 Join play of pcm in multiple playback devices Irfan shaikh
@ 2012-01-03 21:32 ` Pierre-Louis Bossart
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre-Louis Bossart @ 2012-01-03 21:32 UTC (permalink / raw)
  To: alsa-devel

> while(1)
> {
>       retval=snd_pcm_readi(pAlsaConfig->pcm_handle, buffer,
> pAlsaConfig->alsaBufferSize);
>       snd_pcm_writei(pAlsaConfig->pcm_handle1, buffer,retval);
>       snd_pcm_writei(pAlsaConfig->pcm_handle2, buffer,retval);
> }

This code doesn't work in the general case where the different devices 
don't share a common audio clock and have different physical 
capture/playback rates. Compensating for clock drift requires the use of 
asynchronous sample-rate conversion.
Assuming you have a perfectly synchronous system, you could make use of 
snd_pcm_delay() to compensate for delays incurred in the 
driver/firmware/hardware. This is not well supported by all drivers though.
-Pierre

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-03 21:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-03  6:24 Join play of pcm in multiple playback devices Irfan shaikh
2012-01-03 21:32 ` Pierre-Louis Bossart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).