[alsa-devel] [PATCH v2] ALSA: usb-audio: Fix max packet size calculation for USB audio

Ricard Wanderlof ricard.wanderlof at axis.com
Sat Oct 10 20:12:33 CEST 2015


On Sat, 10 Oct 2015, Ricard Wanderlof wrote:

> > That code was intended to round correctly, but it's obviously wrong
> > because the result is not an integer multiple of the frame size.
> 
> If that is the case we need to do something like
> 
> maxsize = (((freqn + 0xffff) & 0xffff0000) * frame_size) >> 16

Or, much simpler, I realized later:

maxsize = ((freqn + 0xffff) >> 16) * frame_size

i.e. we make the conversion from Q16.16 to integer before multiplying with 
the frame size to automatically get the rounding as intended.

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30


More information about the Alsa-devel mailing list