Skip to content

Commit c883134

Browse files
Timo Wischergregkh
authored andcommitted
ALSA: pcm: Fix snd_interval_refine first/last with open min/max
[ Upstream commit ff2d6ac ] 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: Timo Wischer <twischer@de.adit-jv.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8be9576 commit c883134

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

sound/core/pcm_lib.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,27 +629,33 @@ EXPORT_SYMBOL(snd_interval_refine);
629629

630630
static int snd_interval_refine_first(struct snd_interval *i)
631631
{
632+
const unsigned int last_max = i->max;
633+
632634
if (snd_BUG_ON(snd_interval_empty(i)))
633635
return -EINVAL;
634636
if (snd_interval_single(i))
635637
return 0;
636638
i->max = i->min;
637-
i->openmax = i->openmin;
638-
if (i->openmax)
639+
if (i->openmin)
639640
i->max++;
641+
/* only exclude max value if also excluded before refine */
642+
i->openmax = (i->openmax && i->max >= last_max);
640643
return 1;
641644
}
642645

643646
static int snd_interval_refine_last(struct snd_interval *i)
644647
{
648+
const unsigned int last_min = i->min;
649+
645650
if (snd_BUG_ON(snd_interval_empty(i)))
646651
return -EINVAL;
647652
if (snd_interval_single(i))
648653
return 0;
649654
i->min = i->max;
650-
i->openmin = i->openmax;
651-
if (i->openmin)
655+
if (i->openmax)
652656
i->min--;
657+
/* only exclude min value if also excluded before refine */
658+
i->openmin = (i->openmin && i->min <= last_min);
653659
return 1;
654660
}
655661

0 commit comments

Comments
 (0)