All of lore.kernel.org
 help / color / mirror / Atom feed
* .pointer return value
@ 2009-04-23 14:04 Harsha, Priya
  2009-04-25 12:20 ` Giuliano Pochini
  0 siblings, 1 reply; 3+ messages in thread
From: Harsha, Priya @ 2009-04-23 14:04 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

Hi,

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?

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?

Thanks,
Harsha

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

* Re: .pointer return value
  2009-04-23 14:04 .pointer return value Harsha, Priya
@ 2009-04-25 12:20 ` Giuliano Pochini
  2009-04-25 17:13   ` Harsha, Priya
  0 siblings, 1 reply; 3+ messages in thread
From: Giuliano Pochini @ 2009-04-25 12:20 UTC (permalink / raw)
  To: Harsha, Priya; +Cc: alsa-devel@alsa-project.org

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" ?



-- 
Giuliano.

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

* Re: .pointer return value
  2009-04-25 12:20 ` Giuliano Pochini
@ 2009-04-25 17:13   ` Harsha, Priya
  0 siblings, 0 replies; 3+ messages in thread
From: Harsha, Priya @ 2009-04-25 17:13 UTC (permalink / raw)
  To: Giuliano Pochini; +Cc: alsa-devel@alsa-project.org

Thanks a lot. That helps.

>-----Original Message-----
>From: Giuliano Pochini [mailto:pochini@shiny.it]
>Sent: Saturday, April 25, 2009 5:50 PM
>To: Harsha, Priya
>Cc: alsa-devel@alsa-project.org
>Subject: Re: [alsa-devel] .pointer return value
>
>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" ?
>
>
>
>--
>Giuliano.

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

end of thread, other threads:[~2009-04-25 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-23 14:04 .pointer return value Harsha, Priya
2009-04-25 12:20 ` Giuliano Pochini
2009-04-25 17:13   ` Harsha, Priya

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.