Linux.com

api

Posted by: Administrator on August 14, 2004 07:10 PM

Compilation must be done with "-lasound" to link the binary to alsa-lib. For example:
gcc test.c -o test -lasound

I tried all the devices in<nobr> <wbr></nobr>/dev/snd/,<nobr> <wbr></nobr>/dev/dsp, etc.

That way of describing devices in the "everything is a file" way is only used by OSS !! ALSA uses such a notation: type:snd_card,device with:
  • type which can be hw or plughw,
  • snd_card: number of the card
  • device: device number

    ex: plughw:0,0. See the <A HREF="http://www.suse.de/~mana/alsa090_howto.html" title="www.suse.de">ALSA Howto for more informations.</a www.suse.de>

    This article wasn't meant as an introduction to ALSA: such things are general ALSA knowledge and the goal of this article wasn't to present ALSA or its concepts but to give an overview of APIs for programmers to be able to choose the best solution. What's more, I think I gave enough links for newbies to understand what's going on (the ALSA Howto you say you've found was the first documentation given in the "ALSA's website" link of this article<nobr> <wbr></nobr>:-/) and for others to learn more.


    Last thing, your code modifications are right, BUT verify your sources before qualifying articles of being poor and saying code hasn't been checked !! Paul Davis is nothing less than one of the most active sound developers of the community, works on ALSA and has created the entire LAAGA project as well as JACK (for which he got an <A HREF="http://builder.com.com/5100-6375-5136755.html?tag=tt" title="com.com">Open Source Award this year</a com.com>). The point is that ALSA is still under heavy development and that its API changes a lot, and that's what happened for the snd_pcm_hw_params_set_rate_near function which prototype changed as you can verify on this <A HREF="http://www.music.columbia.edu/pipermail/linux-audio-dev/2003-December/005779.html" title="columbia.edu">linux-audio-dev message</a columbia.edu>. This change provocated the segfault of many programs using ALSA (IceCast, aplay, etc AFAIK). So I checked my code and Paul Davis did too, and google will reveal you that most docs/examples on the net are still using the old prototype (those include the howto you cite yourself !!). What's more, those pieces of code are skeletons, just to show what the API looks like, and not real practical examples (else I wouldn't have put those (...) everywhere). There are API references and tutorials to give more up-to-date and exhaustive explanations if you wish to write a real program. However, I'll consider your comments and I'd like to thank you for your interest in my article, hoping it helped you a bit.

    #

  • Return to An introduction to Linux sound systems and APIs