On Thu, 23 Apr 2009 19:34:08 +0530 "Harsha, Priya" priya.harsha@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" ?