From: James Courtier-Dutton <James@superbug.demon.co.uk>
To: Robert Spier <rspier@pobox.com>
Cc: Paul Davis <paul@linuxaudiosystems.com>,
alsa-devel@lists.sourceforge.net
Subject: Re: Using alsa-lib for timing
Date: Tue, 26 Nov 2002 22:27:08 +1100 [thread overview]
Message-ID: <3DE35A8C.5030109@superbug.demon.co.uk> (raw)
In-Reply-To: <15829.12424.589673.766811@rls.cx>
Robert Spier wrote:
>Paul,
>
> Thank you for your clear explanation. I've submitted a small
> documentation patch to the sf.net project which might prevent the
> next person who comes along from falling into the same trap.
>
>
>
>>the basic problem is that you are going about this in the wrong
>>way. there have been many discussions here and on LAD about how to do
>>this sort of thing. its not easy. your first and most basic problem is
>>that you are trying to sync two clocks (the video frame clock and the
>>audio frame clock) that do *not* run in sync. any solution that starts
>>with this as its approach is going to fail, for better or for worse.
>>
>>
>
> We've gone back to our standby method of timing everything off the
> audio, using polling to trigger the RTC for a per-frame delay.
> It's CPU intensive, but works well enough for our purposes.
> (Although definitely sub-optimal and quite nasty.)
>
>-R
>
>
One approach I have taken to try and overcome the problem of using audio
card clocks and system clocks, it that I use resampling. So I use the
system clock to sync audio/video, and then let the audio card ask for
samples, using a sort of callback method from alsa, similar to the way
jack gets alsa to simulate a callback interface.
If my application notices that the sound card is outputting samples too
quickly(I.E. audio hardware clock is slightly faster than the system
clock), it does some resampling, thus making the sound card have to
output more samples. As the sound card now has more samples, it then is
kept in step with the system clock.
I have found that the linux system clock is always more accurate than
most sound card clocks, so I believe that this approach is quite good.
Cheers
James
-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T
handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
prev parent reply other threads:[~2002-11-26 11:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-15 17:36 Using alsa-lib for timing Robert Spier
2002-11-15 20:16 ` Paul Davis
2002-11-26 6:03 ` Robert Spier
2002-11-26 11:27 ` James Courtier-Dutton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DE35A8C.5030109@superbug.demon.co.uk \
--to=james@superbug.demon.co.uk \
--cc=alsa-devel@lists.sourceforge.net \
--cc=paul@linuxaudiosystems.com \
--cc=rspier@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.