[Pkg-alsa-devel] Bug#663329: has_capture_channel() returns wrong value

Ulrich Eckhardt doomster at knuut.de
Sat Mar 10 09:43:01 UTC 2012


Package: libasound2
Version: 1.0.25-2

snd_mixer_selem_has_capture_channel() should return 0 or 1, depending on 
whether the element has a capture channel. However, it also regularly returns 
-22 (-EINVAL) here for mixers that are output-only. This not only differs from 
the documentation, but also from the complementary 
snd_mixer_selem_has_playback_channel(), which never does this, even for input-
only channels.

Looking at the sources (slightly reformatted to fit into a mail), the problem 
seems obvious:

int
snd_mixer_selem_has_capture_channel(
    snd_mixer_elem_t *elem,
    snd_mixer_selem_channel_id_t channel)
{
  CHECK_BASIC(elem);
  CHECK_DIR(elem, SM_CAP_CVOLUME|SM_CAP_CSWITCH);
  return sm_selem_ops(elem)->is(
    elem, SM_CAPT, SM_OPS_IS_CHANNEL, channel);
}

int
snd_mixer_selem_has_playback_channel(
    snd_mixer_elem_t *elem,
    snd_mixer_selem_channel_id_t channel)
{
  CHECK_BASIC(elem);
  return sm_selem_ops(elem)->is(
    elem, SM_PLAY, SM_OPS_IS_CHANNEL, (int)channel);
}

The difference is that has_capture_channel() has an additional CHECK_DIR()
which contains a "return -EINVAL" when the element doesn't have either the 
CVOLUME or the CSWITCH capability. My gut feeling is that the CHECK_DIR() 
needs to be removed, but I haven't tried that and leave the to people that 
fully understand the API.


Cheers!

Uli






More information about the Pkg-alsa-devel mailing list