lua API for SoundData:append

This commit is contained in:
Nevyn Bengtsson 2020-12-10 13:29:42 +01:00 committed by Bjorn
parent 2a875b129b
commit 8c1aa5a8ef
1 changed files with 16 additions and 0 deletions

View File

@ -9,7 +9,23 @@ static int l_lovrSoundDataGetBlob(lua_State* L) {
return 1;
}
static int l_lovrSoundDataAppend(lua_State* L) {
SoundData* soundData = luax_checktype(L, 1, SoundData);
Blob* blob = luax_totype(L, 2, Blob);
SoundData* sound = luax_totype(L, 2, SoundData);
lovrAssert(blob || sound, "Invalid blob appended");
size_t appendedSamples = false;
if (sound) {
appendedSamples = lovrSoundDataStreamAppendSound(soundData, sound);
} else if (blob) {
appendedSamples = lovrSoundDataStreamAppendBlob(soundData, blob);
}
lua_pushinteger(L, appendedSamples);
return 1;
}
const luaL_Reg lovrSoundData[] = {
{ "getBlob", l_lovrSoundDataGetBlob },
{ "append", l_lovrSoundDataAppend },
{ NULL, NULL }
};