Game Development Community

Bug in audio.cc (alxPlay)

by J "hplus" W · in Torque Game Engine · 10/15/2006 (3:32 pm) · 1 replies

Code inspection finds a bug in audio.cc:

Inside alxPlay(), it attempts to find handles to play a sound. If it doesn't find the initial handle to play, it tries to cull an inactive looping sound, and then tries to cull an inactive streaming sound.

However, it turns out that the looping code will return an error, rather than move on to looking for a streaming sound, so inactive, streaming sounds will never be culled.

The fix appears to be to remove the
else
         return(NULL_AUDIOHANDLE);

on line 897.

here's a proposed diff:
C:\Torque\SDK\engine\audio>svn diff
Index: audio.cc
===================================================================
--- audio.cc    (revision 659)
+++ audio.cc    (working copy)
@@ -893,8 +893,6 @@
          alxLoopingUpdate();
          return(handle);
       }
-      else
-         return(NULL_AUDIOHANDLE);

       // move inactive streamers to the culled list, try to start the sound
       StreamingList::iterator itr2 = mStreamingInactiveList.findImage(handle);
@@ -912,11 +910,9 @@
          alxStreamingUpdate();
          return(handle);
       }
-      else
-         return(NULL_AUDIOHANDLE);
    }

-   return(handle);
+   return NULL_AUDIOHANDLE;
 }

 //--------------------------------------------------------------------------

#1
10/15/2006 (5:35 pm)
Yeah, I'm having endless problems with streaming audio. Some streamers endlessly repeat the last few seconds of the track, as reported way back in 2003 in this thread