[alsa-devel] Boundary calculation

Clemens Ladisch clemens at ladisch.de
Tue Jul 17 08:43:27 CEST 2018


Ricardo Biehl Pasquali wrote:
> The current calculation for boundary is:
>
> 	boundary = buffer_size;
> 	while (boundary * 2 <= LONG_MAX - buffer_size)
> 		boundary *= 2;
>
> Why isn't a simpler calculation used instead? e.g.:
>
> 	/* closest multiple of buffer size less or equal LONG_MAX */
> 	boundary = LONG_MAX - LONG_MAX % buffer_size;

To ensure that the factor is a power of two.

Originally, that was not really necessary, but the algorithm is
now part of the kernel/userspace interface.


Regards,
Clemens


More information about the Alsa-devel mailing list