arecord is failing with -V stereo

folkert folkert at vanheusden.com
Mon Aug 23 20:47:27 CEST 2021


Ah same bug.
Please try this.
The idea is that in both cases the extra '-1' breaks it.

diff --git a/aplay/aplay.c b/aplay/aplay.c
index cc51dcb..47db7e7 100644
--- a/aplay/aplay.c
+++ b/aplay/aplay.c
@@ -1753,8 +1753,8 @@ static void print_vu_meter_stereo(int *perc, int *maxperc)
 	for (c = 0; c < 2; c++) {
 		int p = perc[c] * bar_length / 100;
 		char tmp[4];
-		if (p > bar_length)
-			p = bar_length;
+		if (p >= bar_length)
+			p = bar_length - 1;
 		if (c)
 			memset(line + bar_length + 6 + 1, '#', p);
 		else


On Tue, Aug 24, 2021 at 12:14:00AM +0530, sujith kumar reddy wrote:
> Tried with the above code.This is also getting p value negative.
> 
> snippet code:
> 
>    fprintf(stderr, _(" %s sujith %d \n"), __func__,p);
>                 if (p > bar_length)
>                         p = bar_length;
>                 if (c)
>                         memset(line + bar_length + 6 + 1, '#', p);
>                 else
>                         memset(line + bar_length - p - 1, '#', p);
> 
> 
> logs....
> //  c=0 case
> 
> print_vu_meter_stereo sujith 35  ///value of p is 35
> c =1 case
> 
>  print_vu_meter_stereo sujith -9227433 ///value is negative//
> 
> On Mon, Aug 23, 2021 at 10:33 PM folkert <folkert at vanheusden.com> wrote:
> 
> > >         const int bar_length = 35;
> > >         char line[80];
> > ...
> > >                 if (p > bar_length)
> > >                         p = bar_length;
> > >                 if (c)
> > >                         memset(line + bar_length + 6 + 1, '#', p);
> > > ----------------//this is the line where it is crashing.here p value is
> > > becoming negative at c=1.As we see if we change the p value to bar_length
> > > it works fine ..As it is a player issue not a driver issue.
> >
> > This is puzzling.
> > bar_length + 6 + 1 + p and thus 35 + 6 + 1 + 35 is max 77, that fits
> > easlity in 80.
> >
> > But wait:
> >
> >                         line[bar_length - p - 1] = '+';
> >
> > p is max bar_length, so we would end up putting '+' in line[-1]
> >
> > Can you try this?
> >
> >
> > diff --git a/aplay/aplay.c b/aplay/aplay.c
> > index cc51dcb..9cfd52c 100644
> > --- a/aplay/aplay.c
> > +++ b/aplay/aplay.c
> > @@ -1764,7 +1764,7 @@ static void print_vu_meter_stereo(int *perc, int
> > *maxperc)
> >                         p = bar_length;
> >                 if (c)
> >                         line[bar_length + 6 + 1 + p] = '+';
> > -               else
> > +               else if (p < bar_length)
> >                         line[bar_length - p - 1] = '+';
> >                 if (ABS(maxperc[c]) > 99)
> >                         sprintf(tmp, "MAX");
> >


More information about the Alsa-devel mailing list