2008/5/28 Paul Adolph <padolph@xxxxxxxxx>: > On Wed, May 28, 2008 at 9:04 AM, James Courtier-Dutton > <james.dutton@xxxxxxxxx> wrote: >> 2008/5/28 Paul Adolph <padolph@xxxxxxxxx>: >>> Is there any way to divine a count of samples that leave the ALSA ring >>> buffer during playback? My application requires that I send a callback >>> when a buffer-full of data is actually played for it to do A/V sync >>> correctly. Right now I'm doing math to figure out the right clock >>> time to issue the callback, using the latency value from >>> snd_pcm_delay(), but this is not working very well. >>> >>> Thanks in advance. >>> >> >> I don't know what sort of A/V method you are using, but needing a >> callback for it seems wrong to me. > > Tell me about it. I'm porting an existing system to a new platform and > unfortunately this is the model I'm stuck with. > >> snd_pcm_delay() gives you a way to calculate the delay between you >> writing samples to the buffer and them actually arriving at the >> speakers. You can therefore calculate the exact time a particular >> sample will reach the speakers, and work out the A/V sync required >> from that. This is how xine works to achieve A/V sync. > > OK - that is the method I'm using. Good to know that it is used > elsewhere with success. There must be a bug in my code somewhere. > > Thanks for your help. > Also, the important thing is not to actually try to sync Audio to Video or visa versa. The trick is to have a monotonic system clock, and sync Audio to the System clock, and sync Video to the system clock. The by product of this is that audio and video will then be in sync. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Alsa-user mailing list Alsa-user@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-user