|
@@ -153,55 +153,42 @@ namespace openal
|
|
|
alSourcei(source, AL_LOOPING, isLooping() ? AL_TRUE : AL_FALSE);
|
|
|
return !isStopped();
|
|
|
}
|
|
|
- else if (type == TYPE_STREAM)
|
|
|
+ else if (type == TYPE_STREAM && (isLooping() || !isFinished()))
|
|
|
{
|
|
|
- if (isLooping() || !isFinished())
|
|
|
- {
|
|
|
- // Number of processed buffers.
|
|
|
- ALint processed;
|
|
|
+ // Number of processed buffers.
|
|
|
+ ALint processed;
|
|
|
|
|
|
- alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
|
|
+ alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
|
|
|
|
|
|
- while(processed--)
|
|
|
- {
|
|
|
- ALuint buffer;
|
|
|
+ while(processed--)
|
|
|
+ {
|
|
|
+ ALuint buffer;
|
|
|
|
|
|
- float curOffsetSamples, curOffsetSecs;
|
|
|
+ float curOffsetSamples, curOffsetSecs;
|
|
|
|
|
|
- alGetSourcef(source, AL_SAMPLE_OFFSET, &curOffsetSamples);
|
|
|
+ alGetSourcef(source, AL_SAMPLE_OFFSET, &curOffsetSamples);
|
|
|
|
|
|
- ALint b;
|
|
|
- alGetSourcei(source, AL_BUFFER, &b);
|
|
|
- int freq;
|
|
|
- alGetBufferi(b, AL_FREQUENCY, &freq);
|
|
|
- curOffsetSecs = curOffsetSamples / freq;
|
|
|
+ ALint b;
|
|
|
+ alGetSourcei(source, AL_BUFFER, &b);
|
|
|
+ int freq;
|
|
|
+ alGetBufferi(b, AL_FREQUENCY, &freq);
|
|
|
+ curOffsetSecs = curOffsetSamples / freq;
|
|
|
|
|
|
- // Get a free buffer.
|
|
|
- alSourceUnqueueBuffers(source, 1, &buffer);
|
|
|
+ // Get a free buffer.
|
|
|
+ alSourceUnqueueBuffers(source, 1, &buffer);
|
|
|
|
|
|
- float newOffsetSamples, newOffsetSecs;
|
|
|
+ float newOffsetSamples, newOffsetSecs;
|
|
|
|
|
|
- alGetSourcef(source, AL_SAMPLE_OFFSET, &newOffsetSamples);
|
|
|
- newOffsetSecs = newOffsetSamples / freq;
|
|
|
+ alGetSourcef(source, AL_SAMPLE_OFFSET, &newOffsetSamples);
|
|
|
+ newOffsetSecs = newOffsetSamples / freq;
|
|
|
|
|
|
- offsetSamples += (curOffsetSamples - newOffsetSamples);
|
|
|
- offsetSeconds += (curOffsetSecs - newOffsetSecs);
|
|
|
+ offsetSamples += (curOffsetSamples - newOffsetSamples);
|
|
|
+ offsetSeconds += (curOffsetSecs - newOffsetSecs);
|
|
|
|
|
|
- streamAtomic(buffer, decoder);
|
|
|
- alSourceQueueBuffers(source, 1, &buffer);
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // Actually stop the source,
|
|
|
- // 'just running out' is bad
|
|
|
- // practice, and prevents
|
|
|
- // rewinds.
|
|
|
- stopAtomic();
|
|
|
- rewindAtomic();
|
|
|
- return false;
|
|
|
+ streamAtomic(buffer, decoder);
|
|
|
+ alSourceQueueBuffers(source, 1, &buffer);
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|