Commit efdf15d8 authored by Timo Wischer's avatar Timo Wischer Committed by Kleber Sacilotto de Souza

ALSA: pcm: Fix snd_interval_refine first/last with open min/max

BugLink: https://bugs.launchpad.net/bugs/1798587

[ Upstream commit ff2d6acd ]

Without this commit the following intervals [x y), (x y) were be
replaced to (y-1 y) by snd_interval_refine_last(). This was also done
if y-1 is part of the previous interval.
With this changes it will be replaced with [y-1 y) in case of y-1 is
part of the previous interval. A similar behavior will be used for
snd_interval_refine_first().

This commit adapts the changes for alsa-lib of commit
9bb985c ("pcm: snd_interval_refine_first/last: exclude value only if
also excluded before")
Signed-off-by: default avatarTimo Wischer <twischer@de.adit-jv.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 04240ed5
...@@ -648,27 +648,33 @@ EXPORT_SYMBOL(snd_interval_refine); ...@@ -648,27 +648,33 @@ EXPORT_SYMBOL(snd_interval_refine);
static int snd_interval_refine_first(struct snd_interval *i) static int snd_interval_refine_first(struct snd_interval *i)
{ {
const unsigned int last_max = i->max;
if (snd_BUG_ON(snd_interval_empty(i))) if (snd_BUG_ON(snd_interval_empty(i)))
return -EINVAL; return -EINVAL;
if (snd_interval_single(i)) if (snd_interval_single(i))
return 0; return 0;
i->max = i->min; i->max = i->min;
i->openmax = i->openmin; if (i->openmin)
if (i->openmax)
i->max++; i->max++;
/* only exclude max value if also excluded before refine */
i->openmax = (i->openmax && i->max >= last_max);
return 1; return 1;
} }
static int snd_interval_refine_last(struct snd_interval *i) static int snd_interval_refine_last(struct snd_interval *i)
{ {
const unsigned int last_min = i->min;
if (snd_BUG_ON(snd_interval_empty(i))) if (snd_BUG_ON(snd_interval_empty(i)))
return -EINVAL; return -EINVAL;
if (snd_interval_single(i)) if (snd_interval_single(i))
return 0; return 0;
i->min = i->max; i->min = i->max;
i->openmin = i->openmax; if (i->openmax)
if (i->openmin)
i->min--; i->min--;
/* only exclude min value if also excluded before refine */
i->openmin = (i->openmin && i->min <= last_min);
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment