2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2014-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
#include "scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.h"
|
|
|
|
#include "scripting/lua-bindings/auto/lua_cocos2dx_audioengine_auto.hpp"
|
|
|
|
#include "scripting/lua-bindings/manual/tolua_fix.h"
|
|
|
|
#include "scripting/lua-bindings/manual/LuaBasicConversions.h"
|
|
|
|
#include "scripting/lua-bindings/manual/CCLuaEngine.h"
|
|
|
|
#include "audio/include/AudioEngine.h"
|
|
|
|
|
|
|
|
static int lua_get_AudioProfile_name(lua_State* L)
|
|
|
|
{
|
|
|
|
cocos2d::AudioProfile* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "cc.AudioProfile", 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = (cocos2d::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_get_AudioProfile_name'\n", nullptr);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
lua_pushstring(L, self->name.c_str());
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_get_AudioProfile_name'.", &tolua_err);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lua_set_AudioProfile_name(lua_State* L)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2019-11-23 20:27:39 +08:00
|
|
|
cocos2d::AudioProfile* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "cc.AudioProfile", 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = (cocos2d::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_set_AudioProfile_name'\n", nullptr);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isstring(L, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
self->name = tolua_tostring(L, 2, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_set_AudioProfile_name'.", &tolua_err);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lua_get_AudioProfile_maxInstances(lua_State* L)
|
|
|
|
{
|
|
|
|
cocos2d::AudioProfile* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "cc.AudioProfile", 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = (cocos2d::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_get_AudioProfile_maxInstances'\n", nullptr);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tolua_pushnumber(L, (lua_Number)self->maxInstances);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_get_AudioProfile_maxInstances'.", &tolua_err);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lua_set_AudioProfile_maxInstances(lua_State* L)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2019-11-23 20:27:39 +08:00
|
|
|
cocos2d::AudioProfile* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "cc.AudioProfile", 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = (cocos2d::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_set_AudioProfile_maxInstances'\n", nullptr);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isnumber(L, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
self->maxInstances = (unsigned)tolua_tonumber(L, 2, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_set_AudioProfile_maxInstances'.", &tolua_err);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lua_get_AudioProfile_minDelay(lua_State* L)
|
|
|
|
{
|
|
|
|
cocos2d::AudioProfile* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "cc.AudioProfile", 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = (cocos2d::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_get_AudioProfile_minDelay'\n", nullptr);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
tolua_pushnumber(L, (lua_Number)self->minDelay);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_get_AudioProfile_minDelay'.", &tolua_err);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lua_set_AudioProfile_minDelay(lua_State* L)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
int argc = 0;
|
2019-11-23 20:27:39 +08:00
|
|
|
cocos2d::AudioProfile* self = nullptr;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "cc.AudioProfile", 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
self = (cocos2d::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (nullptr == self)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "invalid 'self' in function 'lua_set_AudioProfile_minDelay'\n", nullptr);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
argc = lua_gettop(L) - 1;
|
|
|
|
|
|
|
|
if (1 == argc)
|
|
|
|
{
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
if (!tolua_isnumber(L, 2, 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
|
|
|
#endif
|
|
|
|
self->minDelay = tolua_tonumber(L, 2, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(L, "#ferror in function 'lua_set_AudioProfile_minDelay'.", &tolua_err);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int lua_cocos2dx_audioengine_AudioEngine_setFinishCallback(lua_State* tolua_S)
|
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "cc.AudioEngine", 0, &tolua_err))
|
|
|
|
goto tolua_lerror;
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
int arg0;
|
2021-12-25 10:04:45 +08:00
|
|
|
ok &= luaval_to_int32(tolua_S, 2, (int*)&arg0, "cc.AudioEngine:setFinishCallback");
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2021-12-25 10:04:45 +08:00
|
|
|
if (!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(tolua_S, 3, 0));
|
|
|
|
|
2021-12-31 11:00:35 +08:00
|
|
|
cocos2d::AudioEngine::setFinishCallback(arg0, [=](int audioID, std::string filePath) {
|
2019-11-23 20:27:39 +08:00
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
stack->pushInt(audioID);
|
2021-12-31 11:00:35 +08:00
|
|
|
stack->pushString(filePath.c_str());
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
stack->executeFunctionByHandler(handler, 2);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2021-11-15 19:05:08 +08:00
|
|
|
toluafix_remove_function_by_refid(tolua_S, handler);
|
2019-11-23 20:27:39 +08:00
|
|
|
});
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AudioEngine:setFinishCallback",
|
|
|
|
argc, 2);
|
2019-11-23 20:27:39 +08:00
|
|
|
return 0;
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2021-12-25 10:04:45 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_cocos2dx_audioengine_AudioEngine_setFinishCallback'.", &tolua_err);
|
2019-11-23 20:27:39 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int register_audioengine_module(lua_State* L)
|
|
|
|
{
|
|
|
|
lua_getglobal(L, "_G");
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1)) // stack:...,_G,
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
register_all_cocos2dx_audioengine(L);
|
|
|
|
if (L)
|
|
|
|
{
|
|
|
|
lua_pushstring(L, "cc.AudioProfile");
|
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
tolua_variable(L, "name", lua_get_AudioProfile_name, lua_set_AudioProfile_name);
|
|
|
|
tolua_variable(L, "maxInstances", lua_get_AudioProfile_maxInstances, lua_set_AudioProfile_maxInstances);
|
|
|
|
tolua_variable(L, "minDelay", lua_get_AudioProfile_minDelay, lua_set_AudioProfile_minDelay);
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
lua_pushstring(L, "cc.AudioEngine");
|
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
tolua_function(L, "setFinishCallback", lua_cocos2dx_audioengine_AudioEngine_setFinishCallback);
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
return 1;
|
|
|
|
}
|