All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: marcelg <marcelsbox@quicknet.nl>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>
Subject: Re: PCM buffering ussues ( or probably the lack of understanding )
Date: Sat, 20 Apr 2013 13:17:21 +0200	[thread overview]
Message-ID: <51727941.20003@metafoo.de> (raw)
In-Reply-To: <5172750A.4030805@quicknet.nl>

On 04/20/2013 12:59 PM, marcelg wrote:
> Lars Peter,
> 
> Thanks for your reply.
> 
> Some things are more clear now, however one issue I still wonder.
> 
> 
> Quote
> 
> "
>> Suppose I want to have some buffering inside my pcm driver, how will I be
>> able to get some samples in advance before starting playback ? Can I just
>> call pcm_period_elapsed() a few times in  a row to get the buffer filled
>> before starting the actual playcback, or does this cause side effects ?
>>
> Why'd you want to do that?
> "
> 
> 
> If Alsa is not having an internal buffer as you pointed out. An my driver
> for example advertises
> min periods = 1  and max_periods = 10.   Then it means my drivers is capable
> of buffering up to 10 periods.
> 
> However what I notice is that the Alsa layer pcm_copy()  always supplies
> "period_bytes" after each call to period_elapsed()
> 
> This would imply that even my driver is able to buffer 10 periods, it never
> receives more data as one period, because I call period_elapsed()
> as soon as the data is consumed.


The ALSA core keeps track of how many bytes are available in your buffer. It
will supply your driver with as many bytes as there is space in the buffer.
So if you start playback you should see it supplying you more than one
period worth of bytes. Once the buffer is full you'll naturally only get one
new period of each period that has elapsed.

But as I said before if you don't do anything other then copying data to
your buffer in the copy callback, you should probably get rid of the copy
callback altogether and let ALSA take care of writing the data to your
buffer. This will also allow you to use for example mmap.

- Lars

      parent reply	other threads:[~2013-04-20 11:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-20  7:13 PCM buffering ussues ( or probably the lack of understanding ) marcelg
2013-04-20  7:52 ` Lars-Peter Clausen
2013-04-20  8:46   ` Clemens Ladisch
     [not found]   ` <5172750A.4030805@quicknet.nl>
2013-04-20 11:17     ` Lars-Peter Clausen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51727941.20003@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=marcelsbox@quicknet.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.