mirror of https://github.com/bjornbytes/lovr.git
Separate SoundData and SoundDataStrema constructors
they take the same arguments so we can't overload the function parameterically. also I find it pretty confusing that lovr uses overloads so much in the api, so I really don't mind having a separate constructor :S
This commit is contained in:
parent
35ac33f184
commit
3e003d55b9
|
@ -78,12 +78,7 @@ static int l_lovrDataNewSoundData(lua_State* L) {
|
||||||
uint32_t sampleRate = luaL_optinteger(L, 3, 44100);
|
uint32_t sampleRate = luaL_optinteger(L, 3, 44100);
|
||||||
SampleFormat format = luax_checkenum(L, 4, SampleFormat, "i16");
|
SampleFormat format = luax_checkenum(L, 4, SampleFormat, "i16");
|
||||||
Blob* blob = luax_totype(L, 5, Blob);
|
Blob* blob = luax_totype(L, 5, Blob);
|
||||||
SoundData* soundData;
|
SoundData* soundData = lovrSoundDataCreateRaw(frames, channels, sampleRate, format, blob);
|
||||||
if(blob) {
|
|
||||||
soundData = lovrSoundDataCreateRaw(frames, channels, sampleRate, format, blob);
|
|
||||||
} else {
|
|
||||||
soundData = lovrSoundDataCreateStream(frames, channels, sampleRate, format);
|
|
||||||
}
|
|
||||||
luax_pushtype(L, SoundData, soundData);
|
luax_pushtype(L, SoundData, soundData);
|
||||||
lovrRelease(SoundData, soundData);
|
lovrRelease(SoundData, soundData);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -98,6 +93,17 @@ static int l_lovrDataNewSoundData(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_lovrDataNewSoundDataStream(lua_State* L) {
|
||||||
|
uint64_t frames = luaL_checkinteger(L, 1);
|
||||||
|
uint32_t channels = luaL_optinteger(L, 2, 2);
|
||||||
|
uint32_t sampleRate = luaL_optinteger(L, 3, 44100);
|
||||||
|
SampleFormat format = luax_checkenum(L, 4, SampleFormat, "i16");
|
||||||
|
SoundData* soundData = lovrSoundDataCreateStream(frames, channels, sampleRate, format);
|
||||||
|
luax_pushtype(L, SoundData, soundData);
|
||||||
|
lovrRelease(SoundData, soundData);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_lovrDataNewTextureData(lua_State* L) {
|
static int l_lovrDataNewTextureData(lua_State* L) {
|
||||||
TextureData* textureData = NULL;
|
TextureData* textureData = NULL;
|
||||||
if (lua_type(L, 1) == LUA_TNUMBER) {
|
if (lua_type(L, 1) == LUA_TNUMBER) {
|
||||||
|
@ -128,6 +134,7 @@ static const luaL_Reg lovrData[] = {
|
||||||
{ "newModelData", l_lovrDataNewModelData },
|
{ "newModelData", l_lovrDataNewModelData },
|
||||||
{ "newRasterizer", l_lovrDataNewRasterizer },
|
{ "newRasterizer", l_lovrDataNewRasterizer },
|
||||||
{ "newSoundData", l_lovrDataNewSoundData },
|
{ "newSoundData", l_lovrDataNewSoundData },
|
||||||
|
{ "newSoundDataStream", l_lovrDataNewSoundDataStream },
|
||||||
{ "newTextureData", l_lovrDataNewTextureData },
|
{ "newTextureData", l_lovrDataNewTextureData },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue