mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
Fixed love.audio.newSource(SoundData) variant.
This commit is contained in:
@@ -48,32 +48,35 @@ int w_newSource(lua_State *L)
|
|||||||
{
|
{
|
||||||
Source::Type stype = Source::TYPE_STREAM;
|
Source::Type stype = Source::TYPE_STREAM;
|
||||||
|
|
||||||
if (!luax_istype(L, 1, love::sound::SoundData::type) && !luax_istype(L, 1, love::sound::Decoder::type))
|
if (!luax_istype(L, 1, love::sound::SoundData::type))
|
||||||
{
|
{
|
||||||
const char *stypestr = luaL_checkstring(L, 2);
|
if (!luax_istype(L, 1, love::sound::Decoder::type))
|
||||||
if (stypestr && !Source::getConstant(stypestr, stype))
|
{
|
||||||
return luax_enumerror(L, "source type", Source::getConstants(stype), stypestr);
|
const char *stypestr = luaL_checkstring(L, 2);
|
||||||
|
if (stypestr && !Source::getConstant(stypestr, stype))
|
||||||
|
return luax_enumerror(L, "source type", Source::getConstants(stype), stypestr);
|
||||||
|
|
||||||
if (stype == Source::TYPE_QUEUE)
|
if (stype == Source::TYPE_QUEUE)
|
||||||
return luaL_error(L, "Cannot create queueable sources using newSource. Use newQueueableSource instead.");
|
return luaL_error(L, "Cannot create queueable sources using newSource. Use newQueueableSource instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (love::filesystem::luax_cangetdata(L, 1))
|
if (love::filesystem::luax_cangetdata(L, 1))
|
||||||
{
|
{
|
||||||
// stream type
|
// stream type
|
||||||
if (stype == Source::TYPE_STATIC)
|
if (stype == Source::TYPE_STATIC)
|
||||||
lua_pushstring(L, "memory");
|
lua_pushstring(L, "memory");
|
||||||
else if (!lua_isnone(L, 3))
|
else if (!lua_isnone(L, 3))
|
||||||
lua_pushvalue(L, 3);
|
lua_pushvalue(L, 3);
|
||||||
else
|
else
|
||||||
|
lua_pushnil(L);
|
||||||
|
|
||||||
|
// buffer size
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
|
||||||
// buffer size
|
// (file, buffer size, stream type)
|
||||||
lua_pushnil(L);
|
int idxs[] = { 1, lua_gettop(L), lua_gettop(L) - 1 };
|
||||||
|
luax_convobj(L, idxs, 3, "sound", "newDecoder");
|
||||||
// (file, buffer size, stream type)
|
}
|
||||||
int idxs[] = { 1, lua_gettop(L), lua_gettop(L) - 1 };
|
|
||||||
luax_convobj(L, idxs, 3, "sound", "newDecoder");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stype == Source::TYPE_STATIC && luax_istype(L, 1, love::sound::Decoder::type))
|
if (stype == Source::TYPE_STATIC && luax_istype(L, 1, love::sound::Decoder::type))
|
||||||
|
|||||||
Reference in New Issue
Block a user