mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Fix love.audio.newSource(decoder) and love.audio.newSource(sounddata) to no longer require a Source type argument.
--HG-- branch : minor
This commit is contained in:
@@ -44,19 +44,22 @@ int w_getSourceCount(lua_State *L)
|
|||||||
|
|
||||||
int w_newSource(lua_State *L)
|
int w_newSource(lua_State *L)
|
||||||
{
|
{
|
||||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
|
|
||||||
luax_convobj(L, 1, "sound", "newDecoder");
|
|
||||||
|
|
||||||
Source::Type stype = Source::TYPE_STREAM;
|
Source::Type stype = Source::TYPE_STREAM;
|
||||||
|
|
||||||
const char *stypestr = luaL_checkstring(L, 2);
|
if (!luax_istype(L, 1, SOUND_SOUND_DATA_ID) && !luax_istype(L, 1, SOUND_DECODER_ID))
|
||||||
if (stypestr && !Source::getConstant(stypestr, stype))
|
{
|
||||||
return luaL_error(L, "Invalid source type: %s", stypestr);
|
const char *stypestr = luaL_checkstring(L, 2);
|
||||||
|
if (stypestr && !Source::getConstant(stypestr, stype))
|
||||||
|
return luaL_error(L, "Invalid source type: %s", stypestr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_ID) || luax_istype(L, 1, FILESYSTEM_FILE_DATA_ID))
|
||||||
|
luax_convobj(L, 1, "sound", "newDecoder");
|
||||||
|
|
||||||
if (stype == Source::TYPE_STATIC && luax_istype(L, 1, SOUND_DECODER_ID))
|
if (stype == Source::TYPE_STATIC && luax_istype(L, 1, SOUND_DECODER_ID))
|
||||||
luax_convobj(L, 1, "sound", "newSoundData");
|
luax_convobj(L, 1, "sound", "newSoundData");
|
||||||
|
|
||||||
Source *t = 0;
|
Source *t = nullptr;
|
||||||
|
|
||||||
luax_catchexcept(L, [&]() {
|
luax_catchexcept(L, [&]() {
|
||||||
if (luax_istype(L, 1, SOUND_SOUND_DATA_ID))
|
if (luax_istype(L, 1, SOUND_SOUND_DATA_ID))
|
||||||
@@ -65,7 +68,7 @@ int w_newSource(lua_State *L)
|
|||||||
t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, SOUND_DECODER_ID));
|
t = instance()->newSource(luax_totype<love::sound::Decoder>(L, 1, SOUND_DECODER_ID));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (t)
|
if (t != nullptr)
|
||||||
{
|
{
|
||||||
luax_pushtype(L, AUDIO_SOURCE_ID, t);
|
luax_pushtype(L, AUDIO_SOURCE_ID, t);
|
||||||
t->release();
|
t->release();
|
||||||
|
|||||||
Reference in New Issue
Block a user