mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Add source:isPaused() (enhancement #141)
This commit is contained in:
@@ -55,6 +55,7 @@ namespace audio
|
||||
virtual void resume() = 0;
|
||||
virtual void rewind() = 0;
|
||||
virtual bool isStopped() const = 0;
|
||||
virtual bool isPaused() const = 0;
|
||||
virtual bool isFinished() const = 0;
|
||||
virtual void update() = 0;
|
||||
|
||||
|
||||
@@ -67,6 +67,11 @@ namespace null
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Source::isPaused() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Source::isFinished() const
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace null
|
||||
virtual void resume();
|
||||
virtual void rewind();
|
||||
virtual bool isStopped() const;
|
||||
virtual bool isPaused() const;
|
||||
virtual bool isFinished() const;
|
||||
virtual void update();
|
||||
virtual void setPitch(float pitch);
|
||||
|
||||
@@ -112,6 +112,18 @@ namespace openal
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Source::isPaused() const
|
||||
{
|
||||
if(valid)
|
||||
{
|
||||
ALenum state;
|
||||
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||
return (state == AL_PAUSED);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Source::isFinished() const
|
||||
{
|
||||
return type == TYPE_STATIC ? isStopped() : isStopped() && !isLooping() && decoder->isFinished();
|
||||
|
||||
@@ -76,7 +76,8 @@ namespace openal
|
||||
virtual void pause();
|
||||
virtual void resume();
|
||||
virtual void rewind();
|
||||
virtual bool isStopped() const;
|
||||
virtual bool isStopped() const;
|
||||
virtual bool isPaused() const;
|
||||
virtual bool isFinished() const;
|
||||
virtual void update();
|
||||
virtual void setPitch(float pitch);
|
||||
|
||||
@@ -181,6 +181,13 @@ namespace audio
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_isPaused(lua_State * L)
|
||||
{
|
||||
Source * t = luax_checksource(L, 1);
|
||||
luax_pushboolean(L, t->isPaused());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Source_isStatic(lua_State * L)
|
||||
{
|
||||
Source * t= luax_checksource(L, 1);
|
||||
@@ -205,10 +212,11 @@ namespace audio
|
||||
{ "getVelocity", w_Source_getVelocity },
|
||||
{ "setDirection", w_Source_setDirection },
|
||||
{ "getDirection", w_Source_getDirection },
|
||||
|
||||
|
||||
{ "setLooping", w_Source_setLooping },
|
||||
{ "isLooping", w_Source_isLooping },
|
||||
{ "isStopped", w_Source_isStopped },
|
||||
{ "isPaused", w_Source_isPaused },
|
||||
{ "isStatic", w_Source_isStatic },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace audio
|
||||
int w_Source_setLooping(lua_State * L);
|
||||
int w_Source_isLooping(lua_State * L);
|
||||
int w_Source_isStopped(lua_State * L);
|
||||
int w_Source_isPaused(lua_State * L);
|
||||
int w_Source_isStatic(lua_State * L);
|
||||
int luaopen_source(lua_State * L);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user