All of lore.kernel.org
 help / color / mirror / Atom feed
* alsa-lib: Error code 1 from snd_mixer_selem_set_capture_switch_all()
@ 2003-11-12 12:03 Christian Esken
  2003-11-15 10:24 ` Bug in alsa-lib (Was: alsa-lib: Error code 1 from snd_mixer_selem_set_capture_switch_all() ) Christian Esken
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Esken @ 2003-11-12 12:03 UTC (permalink / raw)
  To: alsa-devel

Hello,

I have a problem with snd_mixer_selem_set_capture_switch_all() from alsa-lib.
The documentation states:

/**
 * \brief Set value of capture switch control for all channels of a mixer 
simple element
 * \param elem Mixer simple element handle
 * \param value control value
 * \return 0 on success otherwise a negative error code
 */
int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int value)

So I should receive either 0 or a negative value. But I receive a return value 
of 1. Does anybody know what this means?!? Any help is appreciated greatly.

Greetings,
           Chris


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Bug in alsa-lib (Was: alsa-lib: Error code 1 from snd_mixer_selem_set_capture_switch_all() )
  2003-11-12 12:03 alsa-lib: Error code 1 from snd_mixer_selem_set_capture_switch_all() Christian Esken
@ 2003-11-15 10:24 ` Christian Esken
  2003-11-19 15:38   ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Esken @ 2003-11-15 10:24 UTC (permalink / raw)
  To: alsa-devel

On Wednesday 12 November 2003 13:03, Christian Esken wrote:
> Hello,
>
> I have a problem with snd_mixer_selem_set_capture_switch_all() from
> alsa-lib. The documentation states:
>
> /**
>  * \brief Set value of capture switch control for all channels of a mixer
> simple element
>  * \param elem Mixer simple element handle
>  * \param value control value
>  * \return 0 on success otherwise a negative error code
>  */
> int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int
> value)
>
> So I should receive either 0 or a negative value. But I receive a return
> value of 1. Does anybody know what this means?!? Any help is appreciated
> greatly.

I have investigated and found a possible bug in alsa-lib.
The documentation of snd_mixer_selem_set_capture_switch_all() only mentions 
return codes 0 and <0. As I said 1 is returned in my case - I now found a 
place where this could happen in the alsa-lib source code. The code is from 
src/mixer/simple.c , revision .59.

snd_mixer_selem_set_capture_switch_all() calls selem_write, which calls 
selem_read(). At the end of selem_read(), you find the following code 
snippet:


        if (memcmp(pvol, s->str[PLAY].vol, sizeof(pvol)) ||
            psw != s->str[PLAY].sw ||
            memcmp(cvol, s->str[CAPT].vol, sizeof(cvol)) ||
            csw != s->str[CAPT].sw)
                return 1;


This is where 1 is returned. But I do not understand the code. Can anybody 
explain to me. It looks a bit like I am passing "bad" parameters, but then I 
would expect to be returned an error code like EINVAL.



Greetings,
           Chris


-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug in alsa-lib (Was: alsa-lib: Error code 1 from snd_mixer_selem_set_capture_switch_all() )
  2003-11-15 10:24 ` Bug in alsa-lib (Was: alsa-lib: Error code 1 from snd_mixer_selem_set_capture_switch_all() ) Christian Esken
@ 2003-11-19 15:38   ` Takashi Iwai
  0 siblings, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2003-11-19 15:38 UTC (permalink / raw)
  To: Christian Esken; +Cc: alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1985 bytes --]

At Sat, 15 Nov 2003 11:24:10 +0100,
Christian Esken wrote:
> 
> On Wednesday 12 November 2003 13:03, Christian Esken wrote:
> > Hello,
> >
> > I have a problem with snd_mixer_selem_set_capture_switch_all() from
> > alsa-lib. The documentation states:
> >
> > /**
> >  * \brief Set value of capture switch control for all channels of a mixer
> > simple element
> >  * \param elem Mixer simple element handle
> >  * \param value control value
> >  * \return 0 on success otherwise a negative error code
> >  */
> > int snd_mixer_selem_set_capture_switch_all(snd_mixer_elem_t *elem, int
> > value)
> >
> > So I should receive either 0 or a negative value. But I receive a return
> > value of 1. Does anybody know what this means?!? Any help is appreciated
> > greatly.
> 
> I have investigated and found a possible bug in alsa-lib.
> The documentation of snd_mixer_selem_set_capture_switch_all() only mentions 
> return codes 0 and <0. As I said 1 is returned in my case - I now found a 
> place where this could happen in the alsa-lib source code. The code is from 
> src/mixer/simple.c , revision .59.

yes, you're right.  it's a bug.


> snd_mixer_selem_set_capture_switch_all() calls selem_write, which calls 
> selem_read(). At the end of selem_read(), you find the following code 
> snippet:
> 
> 
>         if (memcmp(pvol, s->str[PLAY].vol, sizeof(pvol)) ||
>             psw != s->str[PLAY].sw ||
>             memcmp(cvol, s->str[CAPT].vol, sizeof(cvol)) ||
>             csw != s->str[CAPT].sw)
>                 return 1;
> 
> 
> This is where 1 is returned. But I do not understand the code. Can anybody 
> explain to me. It looks a bit like I am passing "bad" parameters, but then I 
> would expect to be returned an error code like EINVAL.

the return value of selem_read() is evaluated to throw the event after
read internally (i.e. if positive value is returned).

the attached patch should fix the positive return-value problem.
i change this on cvs.


thanks,

Takashi

[-- Attachment #2: mixer-retval-fix.dif --]
[-- Type: application/octet-stream, Size: 575 bytes --]

Index: alsa-lib/src/mixer/simple.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-lib/src/mixer/simple.c,v
retrieving revision 1.40
diff -u -r1.40 simple.c
--- alsa-lib/src/mixer/simple.c	16 Sep 2002 15:50:21 -0000	1.40
+++ alsa-lib/src/mixer/simple.c	19 Nov 2003 15:30:57 -0000
@@ -597,7 +597,9 @@
 		if ((err = snd_hctl_elem_write(c->elem, &ctl)) < 0)
 			return err;
 		/* update the element, don't remove */
-		return selem_read(elem);
+		err = selem_read(elem);
+		if (err < 0)
+			return err;
 	}
 	return 0;
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-11-19 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-12 12:03 alsa-lib: Error code 1 from snd_mixer_selem_set_capture_switch_all() Christian Esken
2003-11-15 10:24 ` Bug in alsa-lib (Was: alsa-lib: Error code 1 from snd_mixer_selem_set_capture_switch_all() ) Christian Esken
2003-11-19 15:38   ` Takashi Iwai

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.