X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsource.cpp;h=3619b1d61205c9128d0ffb87d7e66909acf738f2;hb=58dc1e7c15f928d0f861a20c46f2be4112bf5baf;hp=fec965c5d8ede45e6487b8a2f0e70a03ab233624;hpb=35ea5cc8d1eb8c806885d27441548f630e7b1266;p=libs%2Fal.git diff --git a/source/source.cpp b/source/source.cpp index fec965c..3619b1d 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,106 @@ void Source::attribute(ALenum attr, const float *v) 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(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(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::unqueue_buffers(const vector &buffers) +{ + vector ids; + ids.reserve(buffers.size()); + for(vector::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