From 8585c92b7d0744a1f1a39c872cf5096621161b6c Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 16 Aug 2018 14:21:56 +0800 Subject: *update --- src/lua/audio/luaopen_Source.cpp | 46 +++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'src/lua/audio/luaopen_Source.cpp') diff --git a/src/lua/audio/luaopen_Source.cpp b/src/lua/audio/luaopen_Source.cpp index 8881620..b5db88f 100644 --- a/src/lua/audio/luaopen_Source.cpp +++ b/src/lua/audio/luaopen_Source.cpp @@ -1,86 +1,84 @@ #include "lua/luax.h" #include "../luaopen_types.h" -#include "Source.h" +#include "libjin/jin.h" namespace jin { namespace lua { - using audio::Source; + using namespace jin::audio; - static inline Source* checkSource(lua_State* L) + static inline Ref& checkSource(lua_State* L) { Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_AUDIO_SOURCE); - if (proxy != 0 && proxy != nullptr) - return (Source*)proxy->object; - return nullptr; + return proxy->getRef(); } static int l_play(lua_State* L) { - Source* src = checkSource(L); - src->play(); + Ref& ref = checkSource(L); + (*ref).play(); return 0; } static int l_stop(lua_State* L) { - Source* src = checkSource(L); - src->stop(); + Ref& ref = checkSource(L); + (*ref).stop(); return 0; } static int l_pause(lua_State* L) { - Source* src = checkSource(L); - src->pause(); + Ref& ref = checkSource(L); + (*ref).pause(); return 0; } static int l_rewind(lua_State* L) { - Source* src = checkSource(L); - src->rewind(); + Ref& ref = checkSource(L); + (*ref).rewind(); return 0; } static int l_resume(lua_State* L) { - Source* src = checkSource(L); - src->resume(); + Ref& ref = checkSource(L); + (*ref).resume(); return 0; } static int l_isStop(lua_State* L) { - Source* src = checkSource(L); - bool isStop = src->isStopped(); + Ref& ref = checkSource(L); + bool isStop = (*ref).isStopped(); luax_pushboolean(L, isStop); return 1; } static int l_isPaused(lua_State* L) { - Source* src = checkSource(L); - bool isPaused = src->isPaused(); + Ref& ref = checkSource(L); + bool isPaused = (*ref).isPaused(); luax_pushboolean(L, isPaused); return 1; } static int l_setVolume(lua_State* L) { - Source* src = checkSource(L); + Ref& ref = checkSource(L); float volume = luax_checknumber(L, 2); - src->setVolume(volume); + (*ref).setVolume(volume); return 0; } static int l_setLoop(lua_State* L) { - Source* src = checkSource(L); + Ref& ref = checkSource(L); bool loop = luax_checkbool(L, 2); - src->setLoop(loop); + (*ref).setLoop(loop); return 0; } -- cgit v1.1-26-g67d0