All of lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Radivoje Jovanovic <radivojejovanovic@gmail.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: ALSA throwing buffers away?
Date: Tue, 23 Nov 2010 18:40:06 +0100	[thread overview]
Message-ID: <4CEBFC76.80109@ladisch.de> (raw)
In-Reply-To: <AANLkTinShg1ZAnew63WL8h0BRZszsh5W0f4owp_OAkMA@mail.gmail.com>

Radivoje Jovanovic wrote:
> > Radivoje Jovanovic wrote:
> > > I am developing driver for a really simple hardware. Hardware has codec that
> > > supports mono/stereo and the amplifier that supports only one speaker so the
> > > driver has to be mono driver and the codec is setup to manage mono data. I
> > > have setup ALSA with following parameters:
> > >
> > > .info =            (SNDRV_PCM_INFO_NONINTERLEAVED |
> >
> > Better use SNDRV_PCM_INFO_INTERLEAVED; this is the format used by almost
> > all (stereo) sound cards, and so it is expected even for mono files
> > (where there actually isn't any difference).
> 
> I am worried about this approach since if I want to play stereo sound  I
> would have to increase .channels_max = 2,

No, ALSA can automatically convert the sample format.

> Here is my pointer callback:
> 
> offset=READ_REG16(AUDIO_CONFIG_DMA_CUR_ADDR_HIGH))<<16) | READ_REG16(AUDIO_CONFIG_DMA_CUR_ADDR_LOW);
> 
> offset = offset - substream->runtime->dma_addr;

This offset looks as if it is in bytes, but you have to return a value
measured in frames.  Use bytes_to_frames().

>     if (offset >= runtime->buffer_size)
>         offset = 0;

Remove this check; the ALSA framework already checks this and outputs
debugging info if this happens.


Regards,
Clemens

  reply	other threads:[~2010-11-23 17:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-23 16:36 ALSA throwing buffers away? Radivoje Jovanovic
2010-11-23 17:03 ` Clemens Ladisch
2010-11-23 17:25   ` Radivoje Jovanovic
2010-11-23 17:40     ` Clemens Ladisch [this message]
2010-11-23 17:51       ` Radivoje Jovanovic

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=4CEBFC76.80109@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=radivojejovanovic@gmail.com \
    /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.