Prevent overlapping sounds when looking at intel information.
fixes ticket:60 2.3: r11147 trunk: r11148 git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/branches/qt-trunk@11149 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
677554af85
commit
ad55de1e7e
|
@ -956,6 +956,30 @@ AUDIO_STREAM* sound_PlayStreamWithBuf(PHYSFS_file* fileHandle, float volume, voi
|
|||
#endif
|
||||
}
|
||||
|
||||
/** Checks if the stream is playing.
|
||||
* \param stream the stream to check
|
||||
* \post true if playing, false otherwise.
|
||||
*
|
||||
*/
|
||||
BOOL sound_isStreamPlaying(AUDIO_STREAM *stream)
|
||||
{
|
||||
#if !defined(WZ_NOSOUND)
|
||||
ALint state;
|
||||
|
||||
if (stream)
|
||||
{
|
||||
alGetSourcei(stream->source, AL_SOURCE_STATE, &state);
|
||||
sound_GetError();
|
||||
if (state == AL_PLAYING)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Stops the current stream from playing.
|
||||
* \param stream the stream to stop
|
||||
* \post The stopped stream will be destroyed on the next invocation of
|
||||
|
|
|
@ -130,6 +130,7 @@ void sound_SetStoppedCallback( AUDIO_CALLBACK pStopTrackCallback );
|
|||
UDWORD sound_GetTrackTimeLastFinished( SDWORD iTrack );
|
||||
void sound_SetTrackTimeLastFinished( SDWORD iTrack, UDWORD iTime );
|
||||
|
||||
extern BOOL sound_isStreamPlaying(AUDIO_STREAM *stream);
|
||||
extern void sound_StopStream(AUDIO_STREAM* stream);
|
||||
extern void sound_PauseStream(AUDIO_STREAM* stream);
|
||||
extern void sound_ResumeStream(AUDIO_STREAM* stream);
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "multiplay.h"
|
||||
#include "lib/sound/cdaudio.h"
|
||||
#include "lib/sequence/sequence.h"
|
||||
#include "lib/sound/track.h"
|
||||
|
||||
#include "scriptextern.h"
|
||||
|
||||
|
@ -968,32 +969,39 @@ void intIntelButtonPressed(BOOL proxMsg, UDWORD id)
|
|||
if (psResearch != NULL)
|
||||
{
|
||||
static const float maxVolume = 1.f;
|
||||
static AUDIO_STREAM *playing = NULL;
|
||||
|
||||
// only play the sample once, otherwise, they tend to overlap each other
|
||||
if (sound_isStreamPlaying(playing))
|
||||
{
|
||||
sound_StopStream(playing);
|
||||
}
|
||||
|
||||
switch(psResearch->iconID)
|
||||
{
|
||||
case IMAGE_RES_DROIDTECH:
|
||||
audio_PlayStream("sequenceaudio/res_droid.ogg", maxVolume, NULL, NULL);
|
||||
playing = audio_PlayStream("sequenceaudio/res_droid.ogg", maxVolume, NULL, NULL);
|
||||
break;
|
||||
case IMAGE_RES_WEAPONTECH:
|
||||
audio_PlayStream("sequenceaudio/res_weapons.ogg", maxVolume, NULL, NULL);
|
||||
playing = audio_PlayStream("sequenceaudio/res_weapons.ogg", maxVolume, NULL, NULL);
|
||||
break;
|
||||
case IMAGE_RES_COMPUTERTECH:
|
||||
audio_PlayStream("sequenceaudio/res_com.ogg", maxVolume, NULL, NULL);
|
||||
playing = audio_PlayStream("sequenceaudio/res_com.ogg", maxVolume, NULL, NULL);
|
||||
break;
|
||||
case IMAGE_RES_POWERTECH:
|
||||
audio_PlayStream("sequenceaudio/res_pow.ogg", maxVolume, NULL, NULL);
|
||||
playing = audio_PlayStream("sequenceaudio/res_pow.ogg", maxVolume, NULL, NULL);
|
||||
break;
|
||||
case IMAGE_RES_SYSTEMTECH:
|
||||
audio_PlayStream("sequenceaudio/res_systech.ogg", maxVolume, NULL, NULL);
|
||||
playing = audio_PlayStream("sequenceaudio/res_systech.ogg", maxVolume, NULL, NULL);
|
||||
break;
|
||||
case IMAGE_RES_STRUCTURETECH:
|
||||
audio_PlayStream("sequenceaudio/res_strutech.ogg", maxVolume, NULL, NULL);
|
||||
playing = audio_PlayStream("sequenceaudio/res_strutech.ogg", maxVolume, NULL, NULL);
|
||||
break;
|
||||
case IMAGE_RES_CYBORGTECH:
|
||||
audio_PlayStream("sequenceaudio/res_droid.ogg", maxVolume, NULL, NULL);
|
||||
playing = audio_PlayStream("sequenceaudio/res_droid.ogg", maxVolume, NULL, NULL);
|
||||
break;
|
||||
case IMAGE_RES_DEFENCE:
|
||||
audio_PlayStream("sequenceaudio/res_strutech.ogg", maxVolume, NULL, NULL);
|
||||
playing = audio_PlayStream("sequenceaudio/res_strutech.ogg", maxVolume, NULL, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue