However, as per /usr/include/SDL2/SDL_rwops.h, the C API for SDL is different: it expects the C callback to use input arguments in reverse order:
ops - the RWops object
dst - output buffer
size - size of each entry
num - number of entries to read
and it expects a different return:
the number of items read
When size is different than 1, the number of items and bytes don't match. This causes problems when trying to use mixer.loadWAV_RW, which does perform calls with size greater than 1.
This commits fixes the behavior of the callback created via Lua.
Since this operation only ever worked correctly when size was 1, reversing the argument order declaration to match the C library is not a compatibility issue -- this just reflects correctly how the function really works.
As per https://github.com/Tangent128/luasdl2/wiki/Sdl-RWCreate, The Lua API for LuaSDL expects the Lua callback to have as inputs:
num
- number of entries to readsize
- size of each entryand it expects two returns
However, as per
/usr/include/SDL2/SDL_rwops.h
, the C API for SDL is different: it expects the C callback to use input arguments in reverse order:ops
- the RWops objectdst
- output buffersize
- size of each entrynum
- number of entries to readand it expects a different return:
When
size
is different than 1, the number of items and bytes don't match. This causes problems when trying to usemixer.loadWAV_RW
, which does perform calls withsize
greater than 1.This commits fixes the behavior of the callback created via Lua.
Since this operation only ever worked correctly when size was 1, reversing the argument order declaration to match the C library is not a compatibility issue -- this just reflects correctly how the function really works.