All of lore.kernel.org
 help / color / mirror / Atom feed
* Misusing snd_pcm_avail_update()
@ 2009-01-20  2:57 Lennart Poettering
  2009-01-20  8:29 ` Clemens Ladisch
  0 siblings, 1 reply; 15+ messages in thread
From: Lennart Poettering @ 2009-01-20  2:57 UTC (permalink / raw)
  To: ALSA Development Mailing List

Heya!

Currently in the 'glitch-free' logic of PulseAudio I use
snd_pcm_avail_update() to estimate how I need to program my system
timers for the next wake-up for the next buffer fill-up. For that I
assume that the current fill level of the hardware buffer is the
hardware buffer size minus what s_p_a_u() returns. I then convert that
fill level from sample units to time units, and fix it up by the
deviation of the sound card time from the system time. Finally I
substract some extra margin just to make sure.

This I assumed would tell me how much time will pass until an underrun
happens if I don't write anything. 

Mostly this logic works fine. But on some setups and cases it
doesn't. ALSA will signal an underrun much much earlier than what I
estimated like this.

I am now wondering why? One possibility of course is that s_p_a_u() is
not reliable, due to driver issues (there were problems in the HDA
driver about this, right?). Also, s_p_a_u() might simply lag behind
quite a bit, or -- what I think is most likely -- because samples are
popped in larger blocks form the hw playback buffer we reach the
underrun much earlier than expected.

I do acknowledge that the way i use s_p_a_u() is probably a misuse of
the API. I make asssumptions I probably shouldn't make.

Now, considering all this I'd like to ask for a new API function that
tells me how much time I really have before the next underrun. It
probably should just return a value in sample units, leaving it for
the application to deal with system/sound card clock deviations.

Any opinions on this?

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net         ICQ# 11060553
http://0pointer.net/lennart/           GnuPG 0x1A015CC4

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

end of thread, other threads:[~2009-01-29  8:28 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-20  2:57 Misusing snd_pcm_avail_update() Lennart Poettering
2009-01-20  8:29 ` Clemens Ladisch
2009-01-20  8:32   ` Clemens Ladisch
2009-01-20 14:26   ` Lennart Poettering
2009-01-20 18:48     ` Clemens Ladisch
2009-01-20 20:29       ` Lennart Poettering
2009-01-21  0:39         ` Takashi Iwai
2009-01-22 22:20           ` Lennart Poettering
2009-01-23 17:13             ` Takashi Iwai
2009-01-23 17:56               ` Clemens Ladisch
2009-01-24  9:52                 ` Takashi Iwai
2009-01-28 18:30                 ` Lennart Poettering
2009-01-29  8:28                   ` Clemens Ladisch
2009-01-28 18:26               ` Lennart Poettering
2009-01-23 18:49           ` James Courtier-Dutton

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.