[mythtv] ALSA Sound Driver Question

Ed W lists at wildgooses.com
Fri Jun 3 00:35:21 UTC 2005

>I ran into a couple of other issues which I am still chasing but thought it
>was worth putting my "findings so far" out there.
>1. Using the Alsa driver, a call to "getBufferOnSoundcard" returns zero
>immediately after the first few calls to AddSamples. I think this is because
>it only calls snd_pcm_delay if the state is running or draining, but the
>state seems to stay as "PREPARED" for a while. I don't understand ALSA
>enough to know what causes it to change from Prepared to Running, i.e. will
>the first call to writei do this or does it need a minimum number of bytes?
>2. Because of the asynchronous nature of the drivers, there can be a gap of
>around 5ms to 10ms between my first call to AddSamples and the data being
>sent to the soundcard. (i.e. it has to wake from a sleep and then the task
>has to be scheduled by the kernel). Can you think of any way of getting rid
>of this?  Is it not possible to feed the soundcard from AddSamples directly
>if the soundcard is empty?

Is the issue to sync the record and playback streams?

I wonder if we shouldn't just move the record code into the audio driver 
and then we can use the various alsa features to ensure absolutely 
perfect record and playback sync?  This does mean adding a fairly 
serious bunch of code, but it needs to go somewhere I guess...

I use Jack for my audio in and out, so I'm going to have to write record 
routines for this anyway.  Perhaps we should be designing the interface 
in order to just add this stuff into the audio classes?

Ed W

More information about the mythtv-dev mailing list