SoundData stream lua API

This commit is contained in:
Nevyn Bengtsson 2020-12-09 21:59:05 +01:00 committed by Bjorn
parent 7b58561c03
commit d1f6e27437
1 changed files with 6 additions and 1 deletions

View File

@ -78,7 +78,12 @@ static int l_lovrDataNewSoundData(lua_State* L) {
uint32_t sampleRate = luaL_optinteger(L, 3, 44100);
SampleFormat format = luax_checkenum(L, 4, SampleFormat, "i16");
Blob* blob = luax_totype(L, 5, Blob);
SoundData* soundData = lovrSoundDataCreateRaw(frames, channels, sampleRate, format, blob);
SoundData* soundData;
if(blob) {
soundData = lovrSoundDataCreateRaw(frames, channels, sampleRate, format, blob);
} else {
soundData = lovrSoundDataCreateStream(frames, channels, sampleRate, format);
}
luax_pushtype(L, SoundData, soundData);
lovrRelease(SoundData, soundData);
return 1;