[alsa-devel] [RFC PATCH] cplay: Always write frag * fragment_size

Daniel Baluta daniel.baluta at gmail.com
Wed Nov 14 07:59:27 CET 2018


Hi Vinod,

Thanks a lot for having a look at this. Please check my comments inline:

<snip>
> > -     size = config.fragment_size;
> > -     buffer = malloc(size * config.fragments);
> > +     size = config.fragments * config.fragment_size;
> > +     buffer = malloc(size);
>
> net result of this change is no change. Leaving alone the variable names
> from this discussion, we allocate memory for size of config.fragments * config.fragment_size

Yes, you are right on this. There is no change here. But notice that we change
the value of size to config.fragments * config.fragment_size;

Now, please take a look at the inner loop at:

https://github.com/alsa-project/tinycompress/blob/master/src/utils/cplay.c#L382

num_read = fread(buffer, 1, size, file);

So, now instead of reading config.fragment_size we read
config.fragments * config.fragment_size
thus we fully utilize the buffer.

I'm pretty sure this is the correct fix. See also crecord fix from Charles:

http://git.alsa-project.org/?p=tinycompress.git;a=commit;h=e8e36567438c
16a5121943205a0cd8c63924d0d8

thanks,
daniel.


More information about the Alsa-devel mailing list