[alsa-devel] .pointer return value

Harsha, Priya priya.harsha at intel.com
Sat Apr 25 19:13:06 CEST 2009


Thanks a lot. That helps.

>-----Original Message-----
>From: Giuliano Pochini [mailto:pochini at shiny.it]
>Sent: Saturday, April 25, 2009 5:50 PM
>To: Harsha, Priya
>Cc: alsa-devel at alsa-project.org
>Subject: Re: [alsa-devel] .pointer return value
>
>On Thu, 23 Apr 2009 19:34:08 +0530
>"Harsha, Priya" <priya.harsha at intel.com> wrote:
>
>> Can anyone educate me on what value should be returned to .pointer function?
>> 	Should I be passing the number of frames played till that point from the time stream started or
>thnumber of frames played such that the bytes is within the buf_size?
>
>The latter: it's the index of the last transferred frame in the ring buffer.
>
>
>> And if I am using, snd_pcm_indirect_playback_pointer, what should be my input to it?
>> 	Should I be passing the number of bytes played till that point from the time stream started or the
>number of bytes within buf_size?
>
>In practice, they're both fine. After a quick look at the sources
>in /include/sound/pcm-indirect.h:
>
>----
>static inline snd_pcm_uframes_t
>snd_pcm_indirect_playback_pointer(struct snd_pcm_substream *substream,
>				struct snd_pcm_indirect *rec, unsigned int ptr) {
>        int bytes = ptr - rec->hw_io;
>        if (bytes < 0)
>                bytes += rec->hw_buffer_size;
>        rec->hw_io = ptr;
>----
>
>It cares about the difference from the last position to the current one and
>it adds hw_buffer_size if ptr wrapped around.
>
>Side note:
>I can guess it may not behave correctly in case of long latencies when
>bytes < -hw_buffer_size. Perhaps should the "if" be changed to "while" ?
>
>
>
>--
>Giuliano.


More information about the Alsa-devel mailing list