All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Joshua Haberman <joshua@haberman.com>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: PCM API questions
Date: Mon, 24 Jun 2002 14:39:07 +0200	[thread overview]
Message-ID: <s5hr8iw97h0.wl@alsa2.suse.de> (raw)
In-Reply-To: <20020623034119.GE26642@reverberate.org>

Hi Josh,

At Sat, 22 Jun 2002 20:41:20 -0700,
Joshua Haberman wrote:
> 
> Hello all!
> 
> I am writing a PortAudio implementation for ALSA.  PortAudio is designed
> to present a single API that cross-platform applications can use on many
> different platforms.
> 
> I have some questions I hope you can answer for me.
> 
> 1.  Is there any reason to choose anything other than mmap mode for
> transfer?  Are there some cards that don't support it?
 
yes.  some devices don't support.
however you can specify the mmap-emulation mode on asoundrc, hence
mmap mode will be able to work on every device.


> 2.  How is device selection designed to work with ALSA?  My experience
> with ALSA has been very confusing in this regard.  I recall reading at
> least once that ALSA is not designed to have applications enumerate all
> the devices; that the correct way is to use ~/.asoundrc to define a
> hardware device and then supply that name to applications.  But is there
> anything more sophisticated an application can do than to just present
> the user with a text box?

the pcm name really depends on the driver implementation.
usually, device #0 is provided for general use.  but, for example, the
implementation of 4-channel sound is driver speicific.
some driver implements using a control switch and other combines
multiple pcm streams, etc.

however, there are standard names, too:
default, front, rear, center_lfe, surround40, surround51, spdif and
iec958 (identical with spdif).
it would be nice if users can choose one of them from a list, and
additionally have an input text field (well, not sophisticated,
though).


> 3.  I'm not sure how to approach the latency-related software and
> hardware parameters.  PortAudio will soon be able to run in either
> callback mode or blocking mode, and it is intended that the user be able
> to provide hints to the implementation about what kind of latency it
> wants.
> 
> The mechanism for setting latency in PortAudio is in a state of flux, but
> at the moment the PortAudio implementation is provided with these
> parameters:
> 
>     framesPerCallback -- max number of frames to pass to the user callback,
>         when running in callback mode
>     numberOfBuffers
>     latencyInFrames
> 
> These are only guidelines to the driver, not commands, but I'd still like
> to do the best possible approximation.  I'm thinking of doing something
> like this:
> 
>     snd_pcm_hw_params_set_period_time( MIN(latencyInFrames, framesPerCallback) )
>     snd_pcm_hw_params_set_periods( numberOfBuffers )
>     /* buffer size is implicit from the above two */

this should work, although snd_pcm_hw_params_set_period_time_near()
would be better to ensure the driver works.  the available
period/buffer size is dependent on the chip.  *_near() function probes
the nearest possibility.  you then need to reconfirm the approved
period/buffer sizes.  the similar thing will be necessary for sample
rates.
also, don't forget to set channels and format :)

just a question - is it necessary to provide both latencyInFrames and
framesPerCallback?

>     snd_pcm_sw_params_set_avail_min( MIN(latencyInFrames, framesPerCallback) )
> 
> As you can probably tell, I'm murky on the interaction between the
> avail_min software parameter and the period_time hardware parameter.
> Clarifications welcome.  :-)

the value you set is the default.  so you don't have to set it
explicitly.


ciao,

Takashi


-------------------------------------------------------
Sponsored by:
ThinkGeek at http://www.ThinkGeek.com/

  reply	other threads:[~2002-06-24 12:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-23  3:41 PCM API questions Joshua Haberman
2002-06-24 12:39 ` Takashi Iwai [this message]
2002-06-24 12:49   ` Paul Davis
2002-06-24 13:01     ` Takashi Iwai
2002-06-24 14:17       ` Paul Davis
2002-06-24 15:18         ` Fred Gleason
2002-06-24 16:13         ` Takashi Iwai
2002-06-24 16:57         ` Joshua Haberman
2002-06-24 21:14           ` Paul Davis
2002-06-25  1:12             ` Jaroslav Kysela
2002-06-25  6:04               ` Joshua Haberman
2002-06-25 13:53                 ` Jaroslav Kysela
2002-06-25  7:11   ` Joshua Haberman
2002-06-25 10:36     ` Takashi Iwai

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=s5hr8iw97h0.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=joshua@haberman.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.