alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Underrun problem and some basic queries
@ 2010-01-25 10:23 ANISH KUMAR
  0 siblings, 0 replies; 3+ messages in thread
From: ANISH KUMAR @ 2010-01-25 10:23 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org


Hi Takashi et al,
 
This post of mine is just a reminder about my earlier unanswered questions
which i raised about underrun.
http://mailman.alsa-project.org/pipermail/alsa-devel/2010-January/024286.html

I guess you were on holiday and i think this is a bit long list of questions which
no body cared to answer.This time please answer them as this would help all the
new entrants to understand ALSA.

Best Regards,
anish

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Underrun problem and some basic queries
@ 2010-01-04 11:09 ANISH KUMAR
  2010-01-25 10:56 ` Jaroslav Kysela
  0 siblings, 1 reply; 3+ messages in thread
From: ANISH KUMAR @ 2010-01-04 11:09 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org


Dear ALSA Team,
I have some queries.Please answer them.(previous post please ignore as they couldn't appear because of encoding problem)
I am getting underrun problem whenever the playback is about to get finished.
happening in snd_pcm_update_hw_ptr_post function:
if (avail >= stop_threshold) {
        if (substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING)
            snd_pcm_drain_done(substream);
        else
            xrun(substream); //here it is happening..........
        return -EPIPE;
}
1. As i understand if i dont call drain function this will happen.Ismy understanding correct?Because if am calling drain function then thisproblem is not happening.If the application doesn't call drain functionthen xrun is the only way to stop ALSA or does ALSA detect that thereare no more samples to play and automatically stop the play(if yes,canyou point out the source code)?
2. snd_pcm_playback_avail() returns the number of samples that stillneeds to be played?Below is the diagram which is my understanding.
        
    Ring buffer (DMA buffer created using preallocated buffer during system initalisation)
-----------------------------------------------------------------
|          |          |          |          |          |          |
-----------------------------------------------------------------
    ^  ^            
    |   |
hw_ptr appl_ptr
After first write call:   
-----------------------------------------------------------------
|          |          |          |          |          |          |
-----------------------------------------------------------------
     ^                               ^            
     |                                |
 appl_ptr                     hw_ptr 
So my understanding is once wait_for_avail_min returns insnd_pcm_lib_write1 function.hw_ptr is increased by some amount(periodsize) but appl_ptr will increase only when wait_for_avail_minreturns.And difference of (hw_ptr+runtime->buffersize-appl_ptr) will give us unplayed samples in the case of playback?
Is this whole ring buffer is filled after the snd_pcm_lib_write_transfer function is returned?
3.In some rare cases (playback case) i have seen thatwait_for_avail_min doesn't return and driver pointer function keeps ongetting called causing hw_ptr to increase.This causessnd_pcm_playback_avail() function to return a value less than avail_min(as hw_ptr is increasing and appl_ptr is stagnant as it is stuck insnd_pcm_lib_write1 function) which inturn causes wake-up fromsnd_pcm_update_hw_ptr_post() not to get called.When this type ofscenario happens?Is it a normal scenario if yes,then how will it willever come out from wait_for_avail_min?
According to my understanding appl_ptr will increase only when we return from wait_for_avail_min?
4.how does alsa know that it is running short of data?As iunderstand that it does not free the memory and data is onlyoverwritten.So how does it distinguish between old and new data?
5.Burst of noise due to stale data problem reported by Jon Smirl and for which Mr Jaroslav has suggested this solution http://mailman.alsa-project.org/pipermail/alsa-devel/2009-May/017119.html.Is it implemented?
 
Best Regards..

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

end of thread, other threads:[~2010-01-25 10:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-25 10:23 Underrun problem and some basic queries ANISH KUMAR
  -- strict thread matches above, loose matches on Subject: below --
2010-01-04 11:09 ANISH KUMAR
2010-01-25 10:56 ` Jaroslav Kysela

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).