All of lore.kernel.org
 help / color / mirror / Atom feed
* How does ALSA detect underrun in OSS emulation?
@ 2008-02-25 15:22 Timur Tabi
  2008-02-25 15:33 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Timur Tabi @ 2008-02-25 15:22 UTC (permalink / raw)
  To: alsa-devel

Can someone explain to me the exact method that ALSA uses to detect underrun 
with OSS emulation?  I have a driver that reports underrun on almost every 
period when I use OSS emulation and I'm playing with a non-supported sample 
rate.  So I'm assuming that maybe my hardware is playing the audio too fast or 
too slow, and the driver is returning periods before ALSA expects them.  What I 
don't understand is: how does ALSA know that a period was finished too early. 
Does it use a timer, or is it purely application driven?

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* Re: How does ALSA detect underrun in OSS emulation?
  2008-02-25 15:22 How does ALSA detect underrun in OSS emulation? Timur Tabi
@ 2008-02-25 15:33 ` Takashi Iwai
  2008-02-25 15:38   ` Timur Tabi
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2008-02-25 15:33 UTC (permalink / raw)
  To: Timur Tabi; +Cc: alsa-devel

At Mon, 25 Feb 2008 09:22:41 -0600,
Timur Tabi wrote:
> 
> Can someone explain to me the exact method that ALSA uses to detect underrun 
> with OSS emulation?  I have a driver that reports underrun on almost every 
> period when I use OSS emulation and I'm playing with a non-supported sample 
> rate.  So I'm assuming that maybe my hardware is playing the audio too fast or 
> too slow, and the driver is returning periods before ALSA expects them.  What I 
> don't understand is: how does ALSA know that a period was finished too early. 
> Does it use a timer, or is it purely application driven?

It's just as same as on ALSA native API, checks the validity of the
current position reported by pointer callback in
snd_pcm_period_elapsed().


Takashi

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

* Re: How does ALSA detect underrun in OSS emulation?
  2008-02-25 15:33 ` Takashi Iwai
@ 2008-02-25 15:38   ` Timur Tabi
  2008-02-25 15:45     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Timur Tabi @ 2008-02-25 15:38 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:

> It's just as same as on ALSA native API, checks the validity of the
> current position reported by pointer callback in
> snd_pcm_period_elapsed().

Are you talking about this code in snd_pcm_update_hw_ptr_pos?

	pos = substream->ops->pointer(substream);
	if (pos == SNDRV_PCM_POS_XRUN)
		return pos; /* XRUN */

What if my 'pointer' function never returns SNDRV_PCM_POS_XRUN?  How else can I 
get an underrun detected?

-- 
Timur Tabi
Linux kernel developer at Freescale

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

* Re: How does ALSA detect underrun in OSS emulation?
  2008-02-25 15:38   ` Timur Tabi
@ 2008-02-25 15:45     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2008-02-25 15:45 UTC (permalink / raw)
  To: Timur Tabi; +Cc: alsa-devel

At Mon, 25 Feb 2008 09:38:38 -0600,
Timur Tabi wrote:
> 
> Takashi Iwai wrote:
> 
> > It's just as same as on ALSA native API, checks the validity of the
> > current position reported by pointer callback in
> > snd_pcm_period_elapsed().
> 
> Are you talking about this code in snd_pcm_update_hw_ptr_pos?
> 
> 	pos = substream->ops->pointer(substream);
> 	if (pos == SNDRV_PCM_POS_XRUN)
> 		return pos; /* XRUN */

This is one part that ALSA detects XRUN.

> 
> What if my 'pointer' function never returns SNDRV_PCM_POS_XRUN?  How else can I 
> get an underrun detected?

Another part is in snd_pcm_update_hw_ptr_post().  It checks whether
the updated empty space (snd_pcm_playback_avail()) is bigger than
stop_threshold (usually equal with the buffer size).


Takashi

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

end of thread, other threads:[~2008-02-25 15:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-25 15:22 How does ALSA detect underrun in OSS emulation? Timur Tabi
2008-02-25 15:33 ` Takashi Iwai
2008-02-25 15:38   ` Timur Tabi
2008-02-25 15:45     ` Takashi Iwai

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.