Browse Source
Force 16-byte buffer alignment for SIMD
With build option USE_DYNSIMD, SSE SIMD instructions are enabled that require
16-byte aligned buffer data. Multiple buffers are allocated in one contiguous
block of memory, the buffer size is determined by the number of 4-byte float
samples (nframes) per buffer. If this number is not set to a multiple of 4, the
offset of subsequent buffers will be misaligned and jackd crashes with SIGBUS.
An example of this actually happening would be using 24 bit sample size in the
OSS backend, where the page sized system buffers may result in an odd number of
samples per buffer. See
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234574
for a detailed bug report.
This change effectively adds some padding by rounding up the allocated buffer
size to a multiple of 16 bytes, given that both:
a) SIMD instructions are enabled in the build.
b) The requested buffer size is not already a multiple of 16 bytes.
All other cases should be unaffected. The existing buffer handling, copy and
mix code seems to be well prepared for padded buffers, with the number of
samples (nframes) and buffer offsets kept separately.
pull/83/head