X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsource.cpp;h=e8f33c0d8be5e1014d9082879f5032ca81a12d77;hb=8e69eba7dc53233c169152bdf654f032fcd0629f;hp=fec965c5d8ede45e6487b8a2f0e70a03ab233624;hpb=35ea5cc8d1eb8c806885d27441548f630e7b1266;p=libs%2Fal.git diff --git a/source/source.cpp b/source/source.cpp index fec965c..e8f33c0 100644 --- a/source/source.cpp +++ b/source/source.cpp @@ -2,7 +2,7 @@ This file is part of libmspal Copyright © 2008 Mikko Rasa, Mikkosoft Productions -Diestributed under the LGPL +Distributed under the LGPL */ #include "buffer.h" @@ -43,25 +43,72 @@ void Source::attribute(ALenum attr, const float *v) alSourcefv(id, attr, v); } -void Source::set_buffer(Buffer &buffer) +void Source::get_attr(ALenum attr, int *v) const +{ + alGetSourcei(id, attr, v); +} + +void Source::get_attr(ALenum attr, float *v) const +{ + alGetSourcef(id, attr, v); +} + +SourceState Source::get_state() const +{ + int state; + get_attr(AL_SOURCE_STATE, &state); + return static_cast(state); +} + +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(buffer.get_id())); } -void Source::queue_buffers(const vector &buffers) +void Source::queue_buffers(const vector &buffers) { vector ids; ids.reserve(buffers.size()); - for(vector::const_iterator i=buffers.begin(); i!=buffers.end(); ++i) + for(vector::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::play() +{ + alSourcePlay(id); +} + +void Source::pause() +{ + alSourcePause(id); +} + +void Source::stop() +{ + alSourceStop(id); +} + +void Source::rewind() +{ + alSourceRewind(id); +} + } // namespace AL } // namespace Msp