LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.67k stars 631 forks source link

opus_decode_float binding is incorrect #785

Closed unascribed closed 1 year ago

unascribed commented 1 year ago

Version

3.3.2 (nightly), 3.3.1

Platform

Linux x64

JDK

Arch OpenJDK 17.0.4

Module

Opus

Bug description

The opus_decode_float binding is incorrect, taking a ShortBuffer with a claimed native type of opus_int16* instead of a FloatBuffer (formatting mine):

public static int opus_decode_float(
    @NativeType("OpusDecoder *") long st,
    @Nullable @NativeType("unsigned char const *") ByteBuffer data,
    @NativeType("opus_int16 *") ShortBuffer pcm,
    int frame_size,
    int decode_fec
) {

The equivalent native header:

OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float(
    OpusDecoder *st,
    const unsigned char *data,
    opus_int32 len,
    float *pcm,
    int frame_size,
    int decode_fec
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4);

pcm is clearly a float* and should be bound as a FloatBuffer.

This makes the "safe" API unusable due to the mismatch between the size of a short and a float.

Workaround for now is to use nopus_decode_float directly.

Stacktrace or crash log output

No response

Spasi commented 1 year ago

Thank you @unascribed!