arecord is failing with -V stereo

sujith kumar reddy sujithreddy6192 at gmail.com
Mon Aug 23 20:44:00 CEST 2021


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