mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-02 12:33:52 +00:00
Fix Sound:setFrames;
This commit is contained in:
parent
6f6e7eea1b
commit
69b5c51388
|
@ -221,20 +221,20 @@ static int l_lovrSoundSetFrames(lua_State* L) {
|
||||||
if (format == SAMPLE_I16) {
|
if (format == SAMPLE_I16) {
|
||||||
short* shorts = (short*) buffer;
|
short* shorts = (short*) buffer;
|
||||||
for (uint32_t i = 0; i < samples; i++) {
|
for (uint32_t i = 0; i < samples; i++) {
|
||||||
lua_rawgeti(L, 2, dstOffset + frames + i);
|
lua_rawgeti(L, 2, srcOffset + frames + i);
|
||||||
*shorts++ = lua_tointeger(L, -1);
|
*shorts++ = lua_tointeger(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
} else if (format == SAMPLE_F32) {
|
} else if (format == SAMPLE_F32) {
|
||||||
float* floats = (float*) buffer;
|
float* floats = (float*) buffer;
|
||||||
for (uint32_t i = 0; i < samples; i++) {
|
for (uint32_t i = 0; i < samples; i++) {
|
||||||
lua_rawgeti(L, 2, dstOffset + frames + i);
|
lua_rawgeti(L, 2, srcOffset + frames + i);
|
||||||
*floats++ = lua_tonumber(L, -1);
|
*floats++ = lua_tonumber(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t written = lovrSoundWrite(sound, srcOffset + frames, chunk, buffer);
|
uint32_t written = lovrSoundWrite(sound, dstOffset + frames, chunk, buffer);
|
||||||
if (written == 0) break;
|
if (written == 0) break;
|
||||||
frames += written;
|
frames += written;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue