From 1a5d70450f1de87224334e550706c67ad0cde6b8 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 13 Apr 2011 20:00:54 +0200 Subject: added "reimplemented menu music by teetow-the-great-teetow" by Choupom --- src/engine/client/sound.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/engine/client/sound.cpp') diff --git a/src/engine/client/sound.cpp b/src/engine/client/sound.cpp index 55ca2939..4678bb8a 100644 --- a/src/engine/client/sound.cpp +++ b/src/engine/client/sound.cpp @@ -157,8 +157,12 @@ static void Mix(short *pFinalOut, unsigned Frames) // free voice if not used any more if(v->m_Tick == v->m_pSample->m_NumFrames) - v->m_pSample = 0; - + { + if(v->m_Flags&ISound::FLAG_LOOP) + v->m_Tick = 0; + else + v->m_pSample = 0; + } } } @@ -410,7 +414,7 @@ void CSound::SetListenerPos(float x, float y) m_CenterX = (int)x; m_CenterY = (int)y; } - + void CSound::SetChannel(int ChannelID, float Vol, float Pan) { @@ -463,11 +467,16 @@ int CSound::Play(int ChannelID, int SampleID, int Flags) return Play(ChannelID, SampleID, Flags, 0, 0); } -void CSound::Stop(int VoiceID) +void CSound::Stop(int SampleID) { // TODO: a nice fade out lock_wait(m_SoundLock); - m_aVoices[VoiceID].m_pSample = 0; + CSample *pSample = &m_aSamples[SampleID]; + for(int i = 0; i < NUM_VOICES; i++) + { + if(m_aVoices[i].m_pSample == pSample) + m_aVoices[i].m_pSample = 0; + } lock_release(m_SoundLock); } -- cgit 1.4.1