From: Clemens Ladisch Date: Mon, 12 Nov 2007 07:50:08 +0000 (+0100) Subject: simple mixer: fix calculation of control range X-Git-Tag: v1.0.16rc1~52 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=7b51f627326569c38e85af224de21be36cb6562b;p=alsa-lib.git simple mixer: fix calculation of control range When calculating the value range of a control, the variables cannot be initialized with zero because this would prevent the minimum from having a value above zero or the maximum from having a value below zero. --- diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c index 6b015af1..b490e1c1 100644 --- a/src/mixer/simple_none.c +++ b/src/mixer/simple_none.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "mixer_simple.h" @@ -672,9 +673,11 @@ static int simple_update(snd_mixer_elem_t *melem) caps = 0; pchannels = 0; - pmin = pmax = 0; + pmin = LONG_MAX; + pmax = LONG_MIN; cchannels = 0; - cmin = cmax = 0; + cmin = LONG_MAX; + cmax = LONG_MIN; assert(snd_mixer_elem_get_type(melem) == SND_MIXER_ELEM_SIMPLE); simple = snd_mixer_elem_get_private(melem); name = snd_mixer_selem_get_name(melem); @@ -868,13 +871,13 @@ static int simple_update(snd_mixer_elem_t *melem) simple->selem.caps = caps; simple->str[SM_PLAY].channels = pchannels; if (!simple->str[SM_PLAY].range) { - simple->str[SM_PLAY].min = pmin; - simple->str[SM_PLAY].max = pmax; + simple->str[SM_PLAY].min = pmin != LONG_MAX ? pmin : 0; + simple->str[SM_PLAY].max = pmax != LONG_MIN ? pmax : 0; } simple->str[SM_CAPT].channels = cchannels; if (!simple->str[SM_CAPT].range) { - simple->str[SM_CAPT].min = cmin; - simple->str[SM_CAPT].max = cmax; + simple->str[SM_CAPT].min = cmin != LONG_MAX ? cmin : 0; + simple->str[SM_CAPT].max = cmax != LONG_MIN ? cmax : 0; } return 0; }