11 #include "../../Source.h"
12 #include "../../Listener.h"
35 alGenSources(1,&alSource);
40 alDeleteSources(1,&alSource);
46 if (!isPlayingImpl()) {
47 SharedPtr<Sound> sound = getSource()->getSound();
49 assert(sound->isStreaming() &&
"OpenALRenderableStreamingSource can only handle streaming sounds");
51 if (!sound->isLoaded())
66 ALuint als = getALSource();
77 alSourceStop(alSource);
84 alGetSourcei(
getALSource(), AL_SOURCE_STATE, &state);
85 return (state == AL_PLAYING);
115 Source *source = getSource();
120 if (shouldBePlaying() && !isPlayingImpl()) {
125 SharedPtr<Sound> sound = source->
getSound();
127 if (!sound->isLoaded())
137 ALuint als = getALSource();
147 if (flags & UPDATE_ATTRIBUTES) {
150 alSourcef(als, AL_REFERENCE_DISTANCE, source->
getRadius());
151 alSourcef(als, AL_ROLLOFF_FACTOR, 1.
f / source->
getRadius());
153 alSourcef(als, AL_ROLLOFF_FACTOR, 0.
f);
158 alSourcef(als, AL_CONE_INNER_ANGLE,
float(angleRange.
min) *
M_1_PI * 360.f);
159 alSourcef(als, AL_CONE_OUTER_ANGLE,
float(angleRange.
max) *
M_1_PI * 360.f);
160 alSourcef(als, AL_CONE_OUTER_GAIN , 0.
f);
163 alSourcei(als, AL_SOURCE_RELATIVE, source->
isRelative() ? AL_TRUE : AL_FALSE);
165 alSourcei(als, AL_LOOPING, source->
isLooping() ? AL_TRUE : AL_FALSE);
167 if (flags & UPDATE_GAIN) {
169 alSourcef(als, AL_GAIN, source->
getGain());
171 if (flags & UPDATE_LOCATION) {
178 source->
getPosition() - sceneListener.getPosition() );
180 sceneListener.toLocalDirection(
181 source->
getVelocity() - sceneListener.getVelocity()
184 sceneListener.toLocalDirection(
198 if (!sound->isLoaded())
201 assert(sound->isStreaming() &&
"OpenALRenderableStreamingSource can only handle streaming sounds");
208 ALint buffersProcessed = 0;
212 alGetSourcei(als, AL_BUFFERS_PROCESSED, &buffersProcessed);
214 while (buffersProcessed > 0) {
216 ALsizei nbuffers = (buffersProcessed > 2) ? 2 : (ALsizei)buffersProcessed;
217 alSourceUnqueueBuffers(als, nbuffers, buffers);
219 for (ALsizei
i=0;
i<nbuffers; ++
i)
222 buffersProcessed -= nbuffers;
234 streamingSound->
seek(0);
242 alSourceQueueBuffers(als, 1, &buffer);