From 61763ee07d5e246c96e692fabf47c248c3efd752 Mon Sep 17 00:00:00 2001 From: Buginator Date: Sat, 22 Aug 2009 03:45:28 +0000 Subject: [PATCH] When a "looped" sample has finished playing, we reset iAudioID, so the game adds the sample again into the queue. This is the way most other "looped" samples are currently handled by the game. (oil/power/factory steam, and so on) see:770 fixes:770 git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8031 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/sound/track.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/sound/track.c b/lib/sound/track.c index 88f54ce73..6db8ce5a2 100644 --- a/lib/sound/track.c +++ b/lib/sound/track.c @@ -22,6 +22,7 @@ #include "lib/framework/frame.h" #include "lib/framework/frameresource.h" #include "audio_id.h" +#include "src/droid.h" //* // @@ -32,7 +33,7 @@ // // static global variables // array of pointers to sound effects -static TRACK *g_apTrack[MAX_TRACKS]; +static TRACK *g_apTrack[MAX_TRACKS]; // number of tracks loaded static SDWORD g_iCurTracks = 0; @@ -358,6 +359,13 @@ void sound_FinishedCallback( AUDIO_SAMPLE *psSample ) if ( psSample->pCallback != NULL ) { psSample->pCallback(psSample->psObj); + // NOTE: we must invalidate the iAudioID (iTrack) so the game knows to add the + // sample back into the queue. This is a bit of a hacky way to handle "looped" samples, + // since currently, the game don't have a decent way to handle this. + if (psSample->psObj) + { + droidAudioTrackStopped((void *)psSample->psObj); + } } // set finished flag