mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Added Source:clone() and love.audio.newSource(source): creates a new (stopped) Source which has all of the settable state of the original.
Static sources don’t duplicate their OpenAL data buffer when cloned (resolves issue #319). Cloned streaming sources also clone the original Decoder.
This commit is contained in:
@@ -30,6 +30,15 @@ Source *luax_checksource(lua_State *L, int idx)
|
||||
return luax_checktype<Source>(L, idx, "Source", AUDIO_SOURCE_T);
|
||||
}
|
||||
|
||||
int w_Source_clone(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
Source *clone = nullptr;
|
||||
EXCEPT_GUARD(clone = t->clone();)
|
||||
luax_pushtype(L, "Source", AUDIO_SOURCE_T, clone);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_play(lua_State *L)
|
||||
{
|
||||
Source *t = luax_checksource(L, 1);
|
||||
@@ -333,6 +342,8 @@ int w_Source_getChannels(lua_State *L)
|
||||
|
||||
static const luaL_Reg functions[] =
|
||||
{
|
||||
{ "clone", w_Source_clone },
|
||||
|
||||
{ "play", w_Source_play },
|
||||
{ "stop", w_Source_stop },
|
||||
{ "pause", w_Source_pause },
|
||||
|
||||
Reference in New Issue
Block a user