This file is part of libmspal
Copyright © 2008 Mikko Rasa, Mikkosoft Productions
-Diestributed under the LGPL
+Distributed under the LGPL
*/
#include "buffer.h"
alSourcefv(id, attr, v);
}
-void Source::set_buffer(Buffer &buffer)
+void Source::get_attribute(ALenum attr, int *v) const
+{
+ alGetSourcei(id, attr, v);
+}
+
+void Source::get_attribute(ALenum attr, float *v) const
+{
+ alGetSourcef(id, attr, v);
+}
+
+SourceState Source::get_state() const
+{
+ int state;
+ get_attribute(AL_SOURCE_STATE, &state);
+ return static_cast<SourceState>(state);
+}
+
+unsigned Source::get_buffers_queued() const
+{
+ int n;
+ get_attribute(AL_BUFFERS_QUEUED, &n);
+ return n;
+}
+
+unsigned Source::get_buffers_processed() const
+{
+ int n;
+ get_attribute(AL_BUFFERS_PROCESSED, &n);
+ return n;
+}
+
+void Source::set_position(float x, float y, float z)
+{
+ attribute(AL_POSITION, x, y, z);
+}
+
+void Source::set_looping(bool l)
+{
+ attribute(AL_LOOPING, l);
+}
+
+void Source::set_buffer(const Buffer &buffer)
{
attribute(AL_BUFFER, static_cast<int>(buffer.get_id()));
}
-void Source::queue_buffers(const vector<Buffer *> &buffers)
+void Source::queue_buffers(const vector<const Buffer *> &buffers)
{
vector<uint> ids;
ids.reserve(buffers.size());
- for(vector<Buffer *>::const_iterator i=buffers.begin(); i!=buffers.end(); ++i)
+ for(vector<const Buffer *>::const_iterator i=buffers.begin(); i!=buffers.end(); ++i)
ids.push_back((*i)->get_id());
alSourceQueueBuffers(id, ids.size(), &ids.front());
}
-void Source::queue_buffer(Buffer &buffer)
+void Source::queue_buffer(const Buffer &buffer)
{
uint bid=buffer.get_id();
alSourceQueueBuffers(id, 1, &bid);
}
+void Source::unqueue_buffers(const vector<const Buffer *> &buffers)
+{
+ vector<uint> ids;
+ ids.reserve(buffers.size());
+ for(vector<const Buffer *>::const_iterator i=buffers.begin(); i!=buffers.end(); ++i)
+ ids.push_back((*i)->get_id());
+ alSourceUnqueueBuffers(id, ids.size(), &ids.front());
+}
+
+void Source::unqueue_buffer(const Buffer &buffer)
+{
+ uint bid=buffer.get_id();
+ alSourceUnqueueBuffers(id, 1, &bid);
+}
+
+void Source::clear_buffers()
+{
+ attribute(AL_BUFFER, AL_NONE);
+}
+
+void Source::play()
+{
+ alSourcePlay(id);
+}
+
+void Source::pause()
+{
+ alSourcePause(id);
+}
+
+void Source::stop()
+{
+ alSourceStop(id);
+}
+
+void Source::rewind()
+{
+ alSourceRewind(id);
+}
+
} // namespace AL
} // namespace Msp