Game Development Community

Streaming audio stop after program freeze a while

by Samme Ng · in Torque Game Engine · 03/13/2007 (12:20 am) · 0 replies

Do anyone encounter the same suitation?

I am using the streaming OGG for long music playback, it is working good, however, if the program have a long loop ( > 2~3seconds), the audio will be out of music volume control.

It is easy to simulate the same effect by dragging the game's window a while, until the music stop (because of queued data used up), after that, if you change the volume control, it should be out of control.

After checking the codes, I found the problem will be the following:
void alxCloseHandles()
{
   for(U32 i = 0; i < mNumSources; i++)
   {
      if(mHandle[i] & AUDIOHANDLE_LOADING_BIT)
         continue;

      if(mHandle[i] == NULL_AUDIOHANDLE)
         continue;

      ALint state = 0;
      alGetSourcei(mSource[i], AL_SOURCE_STATE, &state);
      if(state == AL_PLAYING)
         continue;

Since after the streaming music stop, the first two IF will pass except the third, since it is no longer in playing, it then causing mHandle[i] become zero.

It seems the codes later on working to rebuild the stream, however, it actually doesn't work.

I have change the codes above to the following to fix the problem:
if(state == AL_PLAYING [b]|| mHandle[i] & AUDIOHANDLE_STREAMING_BIT[/b])
         continue;

Do anyone know about the problem and solution? Do anyone think the above fix will cause other problem?

Samme