From: <Ven...@us...> - 2009-03-25 06:53:17
|
Revision: 3305 http://planeshift.svn.sourceforge.net/planeshift/?rev=3305&view=rev Author: Vengeance2001 Date: 2009-03-25 06:53:07 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Step 1 of supporting multiple voicing files for one response is to allow queueing and sequencing of the files. This commit does that and demos it by playing any voice file twice in a row. This commit along with a CS fix also should fix the memory leaks for sounds, where sound streams were constantly being added but never removed in the OpenAL renderer. Modified Paths: -------------- trunk/src/client/modehandler.cpp trunk/src/client/sound/pssoundmngr.cpp trunk/src/client/sound/pssoundmngr.h Modified: trunk/src/client/modehandler.cpp =================================================================== --- trunk/src/client/modehandler.cpp 2009-03-25 00:40:29 UTC (rev 3304) +++ trunk/src/client/modehandler.cpp 2009-03-25 06:53:07 UTC (rev 3305) @@ -2155,7 +2155,8 @@ else // does exist, and we're done { printf("Yes, it is cached already. Playing immediately.\n"); - soundmanager->StartVoiceSound(fname.GetData()); + soundmanager->StartVoiceSound(fname.GetData()); + soundmanager->StartVoiceSound(fname.GetData()); } } else @@ -2168,7 +2169,8 @@ return; } // Play sound file - soundmanager->StartVoiceSound(fname.GetData()); + soundmanager->StartVoiceSound(fname.GetData()); + soundmanager->StartVoiceSound(fname.GetData()); } } } Modified: trunk/src/client/sound/pssoundmngr.cpp =================================================================== --- trunk/src/client/sound/pssoundmngr.cpp 2009-03-25 00:40:29 UTC (rev 3304) +++ trunk/src/client/sound/pssoundmngr.cpp 2009-03-25 06:53:07 UTC (rev 3305) @@ -156,7 +156,18 @@ void psSoundManager::SourceRemoveNotification(iSndSysSource *pSource) { - printf("SourceAdd Notification\n"); + printf("SourceRemove Notification\n"); + if (currentVoiceSource && currentVoiceSource == pSource) + { + printf("Voice file ended. Checking for another.\n"); + voicingQueue.DeleteIndex(0); + + if (voicingQueue.GetSize() > 0) + { + printf("Playing next voice file.\n"); + currentVoiceSource = StartSound(voicingQueue.Get(0),voicesVolume,false); + } + } } @@ -259,7 +270,7 @@ csRef<iSndSysSource> psSoundManager::StartMusicSound(const char* name,bool loop) { - if(musicEnabled) + if (musicEnabled) return StartSound(name,musicVolume,loop); else return NULL; @@ -267,7 +278,7 @@ csRef<iSndSysSource> psSoundManager::StartAmbientSound(const char* name,bool loop) { - if(ambientEnabled) + if (ambientEnabled) return StartSound(name,ambientVolume,loop); else return NULL; @@ -275,7 +286,7 @@ csRef<iSndSysSource> psSoundManager::StartGUISound(const char* name,bool loop) { - if(guiEnabled) + if (guiEnabled) return StartSound(name,guiVolume,loop); else return NULL; @@ -283,10 +294,20 @@ csRef<iSndSysSource> psSoundManager::StartVoiceSound(const char* name,bool loop) { - if(voicesEnabled) - return StartSound(name,voicesVolume,loop); - else - return NULL; + if (!voicesEnabled) + return NULL; + + voicingQueue.Push(name); + + if (voicingQueue.GetSize() == 1) // this is the only voice file + { + currentVoiceSource = StartSound(name,voicesVolume,loop); + return currentVoiceSource; + } + else + { + return NULL; + } } csRef<iSndSysSource> psSoundManager::StartActionsSound(const char* name,bool loop) Modified: trunk/src/client/sound/pssoundmngr.h =================================================================== --- trunk/src/client/sound/pssoundmngr.h 2009-03-25 00:40:29 UTC (rev 3304) +++ trunk/src/client/sound/pssoundmngr.h 2009-03-25 06:53:07 UTC (rev 3305) @@ -28,6 +28,7 @@ #include <csutil/sysfunc.h> #include <csutil/ref.h> #include <csutil/parray.h> +#include <csutil/stringarray.h> #include <iutil/comp.h> #include "util/prb.h" #include "csutil/hash.h" @@ -218,8 +219,14 @@ private: csRef<iConfigManager> cfgmgr; + /// This array holds the currently playing voice file, plus any in queue, in order. + csStringArray voicingQueue; - bool soundEnabled; + /// This reference holds the current source, so the callback can know when to play the next voice + /// while other sounds are playing. + csRef<iSndSysSource> currentVoiceSource; + + bool soundEnabled; bool musicEnabled; bool ambientEnabled; bool actionsEnabled; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |