X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsource.cpp;h=348b41e37cd6d98d12665a9cc6929b064a9db518;hb=abef5eab53c6c75cd602fdabdec94259d1523858;hp=e8f33c0d8be5e1014d9082879f5032ca81a12d77;hpb=8e69eba7dc53233c169152bdf654f032fcd0629f;p=libs%2Fal.git diff --git a/source/source.cpp b/source/source.cpp index e8f33c0..348b41e 100644 --- a/source/source.cpp +++ b/source/source.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of libmspal -Copyright © 2008 Mikko Rasa, Mikkosoft Productions +Copyright © 2008-2009 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -43,12 +43,12 @@ void Source::attribute(ALenum attr, const float *v) alSourcefv(id, attr, v); } -void Source::get_attr(ALenum attr, int *v) const +void Source::get_attribute(ALenum attr, int *v) const { alGetSourcei(id, attr, v); } -void Source::get_attr(ALenum attr, float *v) const +void Source::get_attribute(ALenum attr, float *v) const { alGetSourcef(id, attr, v); } @@ -56,7 +56,7 @@ void Source::get_attr(ALenum attr, float *v) const SourceState Source::get_state() const { int state; - get_attr(AL_SOURCE_STATE, &state); + get_attribute(AL_SOURCE_STATE, &state); return static_cast(state); } @@ -70,6 +70,16 @@ void Source::set_looping(bool l) attribute(AL_LOOPING, l); } +void Source::set_gain(float g) +{ + attribute(AL_GAIN, g); +} + +void Source::set_rolloff_factor(float f) +{ + attribute(AL_ROLLOFF_FACTOR, f); +} + void Source::set_buffer(const Buffer &buffer) { attribute(AL_BUFFER, static_cast(buffer.get_id())); @@ -90,6 +100,40 @@ void Source::queue_buffer(const Buffer &buffer) 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); +} + +unsigned Source::get_buffers_queued() const +{ + int n=0; + get_attribute(AL_BUFFERS_QUEUED, &n); + return n; +} + +unsigned Source::get_buffers_processed() const +{ + int n=0; + get_attribute(AL_BUFFERS_PROCESSED, &n); + return n; +} + void Source::play() { alSourcePlay(id);