+/* $Id$
+
+This file is part of libmspal
+Copyright © 2008 Mikko Rasa, Mikkosoft Productions
+Diestributed under the LGPL
+*/
+
+#include "buffer.h"
+#include "source.h"
+
+using namespace std;
+
+namespace Msp {
+namespace AL {
+
+Source::Source()
+{
+ alGenSources(1, &id);
+}
+
+Source::~Source()
+{
+ alDeleteSources(1, &id);
+}
+
+void Source::attribute(ALenum attr, int v)
+{
+ alSourcei(id, attr, v);
+}
+
+void Source::attribute(ALenum attr, float v)
+{
+ alSourcef(id, attr, v);
+}
+
+void Source::attribute(ALenum attr, float v0, float v1, float v2)
+{
+ alSource3f(id, attr, v0, v1, v2);
+}
+
+void Source::attribute(ALenum attr, const float *v)
+{
+ alSourcefv(id, attr, v);
+}
+
+void Source::set_buffer(Buffer &buffer)
+{
+ attribute(AL_BUFFER, static_cast<int>(buffer.get_id()));
+}
+
+void Source::queue_buffers(const vector<Buffer *> &buffers)
+{
+ vector<uint> ids;
+ ids.reserve(buffers.size());
+ for(vector<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)
+{
+ uint bid=buffer.get_id();
+ alSourceQueueBuffers(id, 1, &bid);
+}
+
+} // namespace AL
+} // namespace Msp