From 69c47675b95126de63937d59fa151c0bdb6233a7 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 7 Apr 2019 15:47:00 -0300 Subject: [PATCH] Add Decoder:clone. Resolves issue #1479. --- src/modules/sound/wrap_Decoder.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/modules/sound/wrap_Decoder.cpp b/src/modules/sound/wrap_Decoder.cpp index 2e2985c8d..da37b84f0 100644 --- a/src/modules/sound/wrap_Decoder.cpp +++ b/src/modules/sound/wrap_Decoder.cpp @@ -34,6 +34,16 @@ Decoder *luax_checkdecoder(lua_State *L, int idx) return luax_checktype(L, idx); } +int w_Decoder_clone(lua_State *L) +{ + Decoder *t = luax_checkdecoder(L, 1); + Decoder *c = nullptr; + luax_catchexcept(L, [&]() { c = t->clone(); }); + luax_pushtype(L, c); + c->release(); + return 1; +} + int w_Decoder_getChannelCount(lua_State *L) { Decoder *t = luax_checkdecoder(L, 1); @@ -104,6 +114,7 @@ int w_Decoder_getChannels(lua_State *L) static const luaL_Reg w_Decoder_functions[] = { + { "clone", w_Decoder_clone }, { "getChannelCount", w_Decoder_getChannelCount }, { "getBitDepth", w_Decoder_getBitDepth }, { "getSampleRate", w_Decoder_getSampleRate },