mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +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:
@@ -47,14 +47,35 @@ namespace openal
|
||||
class Audio;
|
||||
class Pool;
|
||||
|
||||
// Basically just a reference-counted non-streaming OpenAL buffer object.
|
||||
class StaticDataBuffer : public love::Object
|
||||
{
|
||||
public:
|
||||
|
||||
StaticDataBuffer(ALenum format, const ALvoid *data, ALsizei size, ALsizei freq);
|
||||
virtual ~StaticDataBuffer();
|
||||
|
||||
inline ALuint getBuffer() const
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
ALuint buffer;
|
||||
|
||||
}; // StaticDataBuffer
|
||||
|
||||
class Source : public love::audio::Source
|
||||
{
|
||||
public:
|
||||
|
||||
Source(Pool *pool, love::sound::SoundData *soundData);
|
||||
Source(Pool *pool, love::sound::Decoder *decoder);
|
||||
Source(Source *s);
|
||||
virtual ~Source();
|
||||
|
||||
virtual love::audio::Source *copy();
|
||||
virtual love::audio::Source *clone();
|
||||
virtual void play();
|
||||
virtual void stop();
|
||||
virtual void pause();
|
||||
@@ -123,8 +144,11 @@ private:
|
||||
Pool *pool;
|
||||
ALuint source;
|
||||
bool valid;
|
||||
|
||||
static const unsigned int MAX_BUFFERS = 32;
|
||||
ALuint buffers[MAX_BUFFERS];
|
||||
ALuint streamBuffers[MAX_BUFFERS];
|
||||
|
||||
StaticDataBuffer *staticBuffer;
|
||||
|
||||
float pitch;
|
||||
float volume;
|
||||
|
||||
Reference in New Issue
Block a user