Game Development Community

Issues with VorbisStreamSource

by Drew Parker · in Torque Game Engine · 10/31/2005 (11:56 am) · 1 replies

Hi all,

I'm working with the vorbisStreamSource class to learn how to do streaming audio in OpenAL, so I can eventually write my own custom streaming classes.

Right now, I'm hitting some strange issues using the vorbisSteamSource class. When I setup a sound profile as streaming, and play it with the alxPlay() command from the console, the streaming sound will get stuck and stutter at the end of the file. I found there were two problems in the code. One was, the var that keeps track of how many buffers were left in the queue wasn't being initialized, so the "stop" condition was never met. The other was, once the stop condition was met, another place in the code kept forcing it to keep playing.

I worked on this a bit in the code, and found it can be (sort of) fixed like this:

In vorbisStreamSource.cc:
in bool VorbisStreamSource::initStream():

right after
// Queue the buffers on the source
		alSourceQueueBuffers(mSource, NUMBUFFERS, mBufferList);
		if ((error = alGetError()) != AL_NO_ERROR)
			return false;

add

// Store how many buffers we have so we can stop the sound!  --drew
      buffersinqueue = NUMBUFFERS - 1;


Then, in bool VorbisStreamSource::updateBuffers(), find:

if (state == AL_STOPPED)

and replace it with

// Stop restarting the sound after it has finished playing.  --drew
	if (state == AL_STOPPED && !bFinishedPlaying)


These changes will let the file play to the end, and it will not endlessly stutter. However, it will stutter about once. Then, if you run alxPlay() again on the sound, it will not play all the way through. So those are the 2 problems I'm having right now. Has anyone else hit these problems? It would be nice to have this working a bit better.

Thanks!
Drew

#1
01/18/2010 (2:14 am)
Has there been any work done to this problem? When I play ogg files I get stuttering towards the end of the file.

I'm currently attempting to stream ogg files so that I can use the alxGetStreamDuration() function to get the play time. I've tried alxGetWaveLen() and alxGetStreamDuration() for both wav and ogg files with no luck. There another way of obtaining the file length in seconds without ogg stuttering or a way of obtaining the file length for some other format?