From alsa-devel-owner@alsa.jcu.cz  Wed Nov 11 06:50:25 1998
Received: from mail.alphalink.com.au (mail.alphalink.com.au [203.24.205.7])
	by marvin.jcu.cz (8.9.1a/8.9.1) with ESMTP id GAA29381
	for <alsa-devel@jcu.cz>; Wed, 11 Nov 1998 06:50:14 +0100
Received: from alphalink.com.au (andrew@ppp07-5-Melbourne.alphalink.com.au [203.62.181.198]) by mail.alphalink.com.au (8.8.8/8.6.9) with ESMTP id QAA01533 for <alsa-devel@jcu.cz>; Wed, 11 Nov 1998 16:50:09 +1100
Message-ID: <364925B4.BBB2DE63@alphalink.com.au>
Date: Wed, 11 Nov 1998 16:50:44 +1100
From: Andrew Clausen <clausen@alphalink.com.au>
MIME-Version: 1.0
To: alsa-devel@jcu.cz
Subject: Re: having trouble getting the hang of alsalib
References: <Pine.LNX.3.96.981110222811.3036B-100000@noc.cinternet.net>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list

Hello,

Soren Harward wrote:

> I've tried some work with basic soundcard control with alsalib, and have
> gotten it to work fairly well expect that no matter what I do, the program
> segfaults and dumps core at the end.  Even something this simple:
>
> main() {
>   void *handle;
>   int value;
>
>   value = snd_ctl_open( &handle, 0 );
>   printf("%i\n",value);
>
>   value = snd_ctl_close( handle );
>   printf("%i\n",value);
>
>   return 0;
> }

ALSA does give nice error messages.  Try:

if (value != 0)
    printf ("%s\n", snd_strerror (value));


Error -22 means "Invalid argument".  This probably means that handle hasn't
been initialised properly by snd_ctl_open.  What does it return?  It is
possible that card 0 doesn't exist (it might be card 1).  I haven't looked at
the internal ALSA code, so I'm not sure.  The recommended way of doing things
is:

int card;
int card_map = snd_cards_mask;

for (card=0; card<sizeof(int) * 8;  card++)
    if (card_map & (1<<card)) {
        < try and initialise card number "card" >
    }


> dumps core, and snd_ctl_close() returns a value of -22 (which the printf
> gets).  What am I doing wrong?  I thought I was reading the docs right.
> Sorry for the really basic question, but I'm not very experieced with C.

Where does it dump the core?

You're into sound & gnome, aren't you?  Feel like coming to the atech list?
(It's low volume...)

Andrew Clausen



