mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Major developments to love.audio/love.sound. Music and Sound are gone. There are only Sources now, which is much cleaner.
The audio module was not really stable in 0.6.0, it takes very little messing around to cause OpenAL to do horrible things. It should now be much more stable, and you *should* be able to play/stop/pause/resume/rewind/loop like a madman without disasters. Seek and tell, however, are still not tested and verified for all decoders, but that's less important. Also, all objects now have object:type() and object:typeOf(), which returns the type name of the object, and checks whether an object is of a certain type, respectively.
This commit is contained in:
@@ -24,47 +24,32 @@ namespace love
|
||||
{
|
||||
namespace audio
|
||||
{
|
||||
Source::Source()
|
||||
: audible(0), looping(false)
|
||||
Source::Source(Type type)
|
||||
: type(type)
|
||||
{
|
||||
}
|
||||
|
||||
Source::~Source()
|
||||
{
|
||||
if(audible != 0)
|
||||
{
|
||||
audible->stop(this);
|
||||
audible->release();
|
||||
}
|
||||
}
|
||||
|
||||
void Source::setAudible(Audible * audible)
|
||||
{
|
||||
// If this source already has an audible, remove it.
|
||||
if(this->audible != 0)
|
||||
{
|
||||
this->audible->stop(this);
|
||||
this->audible->release();
|
||||
}
|
||||
|
||||
this->audible = audible;
|
||||
audible->retain();
|
||||
}
|
||||
|
||||
Audible * Source::getAudible() const
|
||||
{
|
||||
return audible;
|
||||
}
|
||||
|
||||
void Source::setLooping(bool looping)
|
||||
bool Source::getConstant(const char * in, Type & out)
|
||||
{
|
||||
this->looping = looping;
|
||||
return types.find(in, out);
|
||||
}
|
||||
|
||||
bool Source::isLooping() const
|
||||
{
|
||||
return looping;
|
||||
bool Source::getConstant(Type in, const char *& out)
|
||||
{
|
||||
return types.find(in, out);
|
||||
}
|
||||
|
||||
StringMap<Source::Type, Source::TYPE_MAX_ENUM>::Entry Source::typeEntries[] =
|
||||
{
|
||||
{"static", Source::TYPE_STATIC},
|
||||
{"stream", Source::TYPE_STREAM},
|
||||
};
|
||||
|
||||
StringMap<Source::Type, Source::TYPE_MAX_ENUM> Source::types(Source::typeEntries, sizeof(Source::typeEntries));
|
||||
|
||||
} // audio
|
||||
} // love
|
||||
|
||||
Reference in New Issue
Block a user