Skip to contentSkip to conversation

small dummy driver bug ?

DISCUSSION Andreas Mohr 2 participants 2 messages Sep 8, 2002 – Sep 9, 2002

lore
Share & tools
lore
#0 lore raw

Hi all,

while looking at the dummy driver to find usable parts for my driver, I found:

static int snd_dummy_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t
* ucontrol)

{
        snd_card_dummy_t *dummy = _snd_kcontrol_chip(kcontrol);
        unsigned long flags;
        int change, addr = kcontrol->private_value;
        int left, right;

        left = ucontrol->value.integer.value[0] % 101;
        right = ucontrol->value.integer.value[1] % 101;
        spin_lock_irqsave(&dummy->mixer_lock, flags);
        change = dummy->mixer_volume[addr][0] != left &&
                 dummy->mixer_volume[addr][1] != right;
        dummy->mixer_volume[addr][0] = left;
        dummy->mixer_volume[addr][1] = right;
        spin_unlock_irqrestore(&dummy->mixer_lock, flags);
        return change;
}

Shouldn't it be

        change = dummy->mixer_volume[addr][0] != left ||
                 dummy->mixer_volume[addr][1] != right;
instead of
        change = dummy->mixer_volume[addr][0] != left &&
                 dummy->mixer_volume[addr][1] != right;

??

Why only signal a change if *both* channels' values are changed ? Or is the meaning of the API's "change" return value actually rather mysterious to me ?

Signature · 8 lines
The Declaration of Software Freedom:
http://freedevelopers.net/freedomdec/index.php


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
#1 lore raw

At Sun, 8 Sep 2002 15:29:53 +0200,

Quoted 9 lines · Andreas Mohr

Shouldn't it be

        change = dummy->mixer_volume[addr][0] != left ||
                 dummy->mixer_volume[addr][1] != right;
instead of
        change = dummy->mixer_volume[addr][0] != left &&
                 dummy->mixer_volume[addr][1] != right;

??

yes. it's obviously a typo.
fixed on cvs now.

thanks.

Takashi

-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390