2014-09-14 22:54:04 +08:00
|
|
|
/****************************************************************************
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2014-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2014-09-14 22:54:04 +08:00
|
|
|
|
2022-07-09 22:23:34 +08:00
|
|
|
https://axis-project.github.io/
|
2014-09-14 22:54:04 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
2022-07-12 21:31:54 +08:00
|
|
|
#include "scripting/lua-bindings/manual/audioengine/lua_axis_audioengine_manual.h"
|
|
|
|
#include "scripting/lua-bindings/auto/lua_axis_audioengine_auto.hpp"
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "scripting/lua-bindings/manual/tolua_fix.h"
|
|
|
|
#include "scripting/lua-bindings/manual/LuaBasicConversions.h"
|
|
|
|
#include "scripting/lua-bindings/manual/CCLuaEngine.h"
|
2022-01-03 11:34:58 +08:00
|
|
|
#include "audio/AudioEngine.h"
|
2014-09-14 22:54:04 +08:00
|
|
|
|
|
|
|
static int lua_get_AudioProfile_name(lua_State* L)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AudioProfile* self = nullptr;
|
2014-09-14 22:54:04 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.AudioProfile", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-14 22:54:04 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AudioProfile* self = nullptr;
|
2014-09-14 22:54:04 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.AudioProfile", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-14 22:54:04 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lua_get_AudioProfile_maxInstances(lua_State* L)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AudioProfile* self = nullptr;
|
2014-09-14 22:54:04 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.AudioProfile", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-14 22:54:04 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AudioProfile* self = nullptr;
|
2014-09-14 22:54:04 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.AudioProfile", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-14 22:54:04 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static int lua_get_AudioProfile_minDelay(lua_State* L)
|
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AudioProfile* self = nullptr;
|
2014-09-14 22:54:04 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.AudioProfile", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-14 22:54:04 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AudioProfile* self = nullptr;
|
2014-09-14 22:54:04 +08:00
|
|
|
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertype(L, 1, "ax.AudioProfile", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-14 22:54:04 +08:00
|
|
|
#endif
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
self = (axis::AudioProfile*)tolua_tousertype(L, 1, 0);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +08:00
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
int lua_axis_audioengine_AudioEngine_setFinishCallback(lua_State* tolua_S)
|
2014-09-14 22:54:04 +08:00
|
|
|
{
|
|
|
|
int argc = 0;
|
|
|
|
bool ok = true;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_Error tolua_err;
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +08:00
|
|
|
#if COCOS2D_DEBUG >= 1
|
2022-07-12 21:31:54 +08:00
|
|
|
if (!tolua_isusertable(tolua_S, 1, "ax.AudioEngine", 0, &tolua_err))
|
2021-12-25 10:04:45 +08:00
|
|
|
goto tolua_lerror;
|
2014-09-14 22:54:04 +08:00
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +08:00
|
|
|
argc = lua_gettop(tolua_S) - 1;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +08:00
|
|
|
if (argc == 2)
|
|
|
|
{
|
|
|
|
int arg0;
|
2022-07-12 21:31:54 +08:00
|
|
|
ok &= luaval_to_int32(tolua_S, 2, (int*)&arg0, "ax.AudioEngine:setFinishCallback");
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +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))
|
2014-09-14 22:54:04 +08:00
|
|
|
{
|
|
|
|
goto tolua_lerror;
|
|
|
|
}
|
|
|
|
#endif
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
LUA_FUNCTION handler = (toluafix_ref_function(tolua_S, 3, 0));
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::AudioEngine::setFinishCallback(arg0, [=](int audioID, std::string_view filePath) {
|
2014-09-14 22:54:04 +08:00
|
|
|
LuaStack* stack = LuaEngine::getInstance()->getLuaStack();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +08:00
|
|
|
stack->pushInt(audioID);
|
2021-12-28 11:05:34 +08:00
|
|
|
stack->pushString(filePath);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +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);
|
2014-09-14 22:54:04 +08:00
|
|
|
});
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2022-07-12 21:31:54 +08:00
|
|
|
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ax.AudioEngine:setFinishCallback",
|
2021-12-25 10:04:45 +08:00
|
|
|
argc, 2);
|
2014-09-14 22:54:04 +08:00
|
|
|
return 0;
|
|
|
|
#if COCOS2D_DEBUG >= 1
|
|
|
|
tolua_lerror:
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_error(tolua_S, "#ferror in function 'lua_axis_audioengine_AudioEngine_setFinishCallback'.", &tolua_err);
|
2014-09-14 22:54:04 +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,
|
2014-09-14 22:54:04 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
register_all_axis_audioengine(L);
|
2014-09-14 22:54:04 +08:00
|
|
|
if (L)
|
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "ax.AudioProfile");
|
2014-09-14 22:54:04 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-09-14 22:54:04 +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
|
|
|
|
2022-07-12 21:31:54 +08:00
|
|
|
lua_pushstring(L, "ax.AudioEngine");
|
2014-09-14 22:54:04 +08:00
|
|
|
lua_rawget(L, LUA_REGISTRYINDEX);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (lua_istable(L, -1))
|
2014-09-14 22:54:04 +08:00
|
|
|
{
|
2022-07-12 21:31:54 +08:00
|
|
|
tolua_function(L, "setFinishCallback", lua_axis_audioengine_AudioEngine_setFinishCallback);
|
2014-09-14 22:54:04 +08:00
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2014-09-14 22:54:04 +08:00
|
|
|
return 1;
|
|
|
|
}
|