Added source:isStatic()

This commit is contained in:
bart@bartbes.ath.cx
2010-03-28 17:52:22 +02:00
parent 2d7e50e503
commit a91be8936f
8 changed files with 68 additions and 46 deletions
+4 -4
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -43,7 +43,7 @@ namespace audio
return types.find(in, out);
}
StringMap<Source::Type, Source::TYPE_MAX_ENUM>::Entry Source::typeEntries[] =
StringMap<Source::Type, Source::TYPE_MAX_ENUM>::Entry Source::typeEntries[] =
{
{"static", Source::TYPE_STATIC},
{"stream", Source::TYPE_STREAM},
+7 -6
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -48,7 +48,7 @@ namespace audio
virtual ~Source();
virtual Source * copy() = 0;
virtual void play() = 0;
virtual void stop() = 0;
virtual void pause() = 0;
@@ -71,9 +71,10 @@ namespace audio
virtual void getVelocity(float * v) const = 0;
virtual void setDirection(float * v) = 0;
virtual void getDirection(float * v) const = 0;
virtual void setLooping(bool looping) = 0;
virtual bool isLooping() const = 0;
virtual bool isStatic() const = 0;
static bool getConstant(const char * in, Type & out);
static bool getConstant(Type in, const char *& out);
@@ -88,4 +89,4 @@ namespace audio
} // audio
} // love
#endif // LOVE_AUDIO_SOURCE_H
#endif // LOVE_AUDIO_SOURCE_H
+10 -5
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -64,12 +64,12 @@ namespace null
bool Source::isStopped() const
{
return true;
return true;
}
bool Source::isFinished() const
{
return true;
return true;
}
void Source::update()
@@ -130,6 +130,11 @@ namespace null
return looping;
}
bool Source::isStatic() const
{
return (type == TYPE_STATIC);
}
} // null
} // audio
} // love
+7 -6
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -42,8 +42,8 @@ namespace null
public:
Source();
virtual ~Source();
virtual love::audio::Source * copy();
virtual love::audio::Source * copy();
virtual void play();
virtual void stop();
virtual void pause();
@@ -64,6 +64,7 @@ namespace null
virtual void getDirection(float * v) const;
void setLooping(bool looping);
bool isLooping() const;
bool isStatic() const;
}; // Source
@@ -71,4 +72,4 @@ namespace null
} // audio
} // love
#endif // LOVE_AUDIO_NULL_SOURCE_H
#endif // LOVE_AUDIO_NULL_SOURCE_H
+10 -5
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -34,7 +34,7 @@ namespace openal
Source::Source(Pool * pool, love::sound::SoundData * soundData)
: love::audio::Source(Source::TYPE_STATIC), pool(pool), valid(false),
pitch(1.0f), volume(1.0f), looping(false), decoder(0)
pitch(1.0f), volume(1.0f), looping(false), decoder(0)
{
alGenBuffers(1, buffers);
ALenum fmt = getFormat(soundData->getChannels(), soundData->getBits());
@@ -48,7 +48,7 @@ namespace openal
}
Source::Source(Pool * pool, love::sound::Decoder * decoder)
: love::audio::Source(Source::TYPE_STREAM), pool(pool), valid(false),
: love::audio::Source(Source::TYPE_STREAM), pool(pool), valid(false),
pitch(1.0f), volume(1.0f), looping(false), decoder(decoder)
{
decoder->retain();
@@ -381,6 +381,11 @@ namespace openal
return decoded;
}
bool Source::isStatic() const
{
return (type == TYPE_STATIC);
}
} // openal
} // audio
} // love
+8 -7
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -69,8 +69,8 @@ namespace openal
Source(Pool * pool, love::sound::SoundData * soundData);
Source(Pool * pool, love::sound::Decoder * decoder);
virtual ~Source();
virtual love::audio::Source * copy();
virtual love::audio::Source * copy();
virtual void play();
virtual void stop();
virtual void pause();
@@ -91,6 +91,7 @@ namespace openal
virtual void getDirection(float * v) const;
void setLooping(bool looping);
bool isLooping() const;
bool isStatic() const;
void playAtomic();
void stopAtomic();
@@ -107,7 +108,7 @@ namespace openal
/**
* Gets the OpenAL format identifier based on number of
* channels and bits.
* @param channels Either 1 (mono) or 2 (stereo).
* @param channels Either 1 (mono) or 2 (stereo).
* @param bits Either 8-bit samples, or 16-bit samples.
* @return One of AL_FORMAT_*, or 0 if unsupported format.
**/
@@ -121,4 +122,4 @@ namespace openal
} // audio
} // love
#endif // LOVE_AUDIO_OPENAL_SOURCE_H
#endif // LOVE_AUDIO_OPENAL_SOURCE_H
+17 -9
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -28,35 +28,35 @@ namespace audio
{
return luax_checktype<Source>(L, idx, "Source", AUDIO_SOURCE_T);
}
int w_Source_play(lua_State * L)
{
Source * t = luax_checksource(L, 1);
t->play();
return 0;
}
int w_Source_stop(lua_State * L)
{
Source * t = luax_checksource(L, 1);
t->stop();
return 0;
}
int w_Source_pause(lua_State * L)
{
Source * t = luax_checksource(L, 1);
t->pause();
return 0;
}
int w_Source_resume(lua_State * L)
{
Source * t = luax_checksource(L, 1);
t->resume();
return 0;
}
int w_Source_rewind(lua_State * L)
{
Source * t = luax_checksource(L, 1);
@@ -181,13 +181,20 @@ namespace audio
return 1;
}
int w_Source_isStatic(lua_State * L)
{
Source * t= luax_checksource(L, 1);
luax_pushboolean(L, t->isStatic());
return 1;
}
static const luaL_Reg functions[] = {
{ "play", w_Source_play },
{ "stop", w_Source_stop },
{ "pause", w_Source_pause },
{ "resume", w_Source_resume },
{ "rewind", w_Source_rewind },
{ "setPitch", w_Source_setPitch },
{ "getPitch", w_Source_getPitch },
{ "setVolume", w_Source_setVolume },
@@ -195,6 +202,7 @@ namespace audio
{ "setLooping", w_Source_setLooping },
{ "isLooping", w_Source_isLooping },
{ "isStopped", w_Source_isStopped },
{ "isStatic", w_Source_isStatic },
{ 0, 0 }
};
+5 -4
View File
@@ -1,14 +1,14 @@
/**
* Copyright (c) 2006-2010 LOVE Development Team
*
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
@@ -47,9 +47,10 @@ 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_isStatic(lua_State * L);
int luaopen_source(lua_State * L);
} // audio
} // love
#endif // LOVE_AUDIO_WRAP_SOURCE_H
#endif // LOVE_AUDIO_WRAP_SOURCE_H