[Scummvm-cvs-logs] CVS: scummvm/gob game.cpp,1.18,1.19 sound.cpp,1.7,1.8 sound.h,1.5,1.6
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Sat Apr 30 04:32:52 CEST 2005
Update of /cvsroot/scummvm/scummvm/gob
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27526
Modified Files:
game.cpp sound.cpp sound.h
Log Message:
Support for looping sounds.
Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/game.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- game.cpp 21 Apr 2005 06:53:15 -0000 1.18
+++ game.cpp 30 Apr 2005 11:32:18 -0000 1.19
@@ -678,11 +678,12 @@
}
}
}
-
}
if (handleMouse != 0)
draw_animateCursor(-1);
+
+ snd_loopSounds();
}
}
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/sound.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sound.cpp 29 Apr 2005 15:13:21 -0000 1.7
+++ sound.cpp 30 Apr 2005 11:32:18 -0000 1.8
@@ -24,7 +24,25 @@
#include "gob/sound.h"
namespace Gob {
-SoundHandle soundHandle;
+Snd_SoundDesc *snd_loopingSounds[5]; // Should be enough
+
+void snd_initSound(void) {
+ for (int i = 0; i < ARRAYSIZE(snd_loopingSounds); i++)
+ snd_loopingSounds[i] = NULL;
+}
+
+void snd_loopSounds(void) {
+ for (int i = 0; i < ARRAYSIZE(snd_loopingSounds); i++) {
+ Snd_SoundDesc *snd = snd_loopingSounds[i];
+ if (snd && !_vm->_mixer->isSoundHandleActive(snd->handle)) {
+ if (snd->repCount-- > 0) {
+ _vm->_mixer->playRaw(&snd->handle, snd->data, snd->size, snd->frequency, 0);
+ } else {
+ snd_loopingSounds[i] = NULL;
+ }
+ }
+ }
+}
int16 snd_checkProAudio(void) {return 0;}
int16 snd_checkAdlib(void) {return 0;}
@@ -44,14 +62,27 @@
// a simple signed/unsigned issue.
void snd_playSample(Snd_SoundDesc *sndDesc, int16 repCount, int16 frequency) {
- if (repCount != 1)
- warning("snd_playSample: repCount = %d - not implemented", repCount);
if (frequency < 0) {
warning("snd_playSample: frequency = %d - this is weird", frequency);
return;
}
- _vm->_mixer->playRaw(&soundHandle, sndDesc->data, sndDesc->size, frequency, 0);
+ if (!_vm->_mixer->isSoundHandleActive(sndDesc->handle)) {
+ _vm->_mixer->playRaw(&sndDesc->handle, sndDesc->data, sndDesc->size, frequency, 0);
+ }
+
+ sndDesc->repCount = repCount - 1;
+ sndDesc->frequency = frequency;
+
+ if (repCount > 1) {
+ for (int i = 0; i < ARRAYSIZE(snd_loopingSounds); i++) {
+ if (!snd_loopingSounds[i]) {
+ snd_loopingSounds[i] = sndDesc;
+ return;
+ }
+ }
+ warning("Looping sounds list is full");
+ }
}
void snd_cleanupFuncCallback() {;}
@@ -78,6 +109,13 @@
}
void snd_freeSoundData(Snd_SoundDesc *sndDesc) {
+ _vm->_mixer->stopHandle(sndDesc->handle);
+
+ for (int i = 0; i < ARRAYSIZE(snd_loopingSounds); i++) {
+ if (snd_loopingSounds[i] == sndDesc)
+ snd_loopingSounds[i] = NULL;
+ }
+
free(sndDesc->data);
free(sndDesc);
}
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/sound.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sound.h 29 Apr 2005 10:07:00 -0000 1.5
+++ sound.h 30 Apr 2005 11:32:18 -0000 1.6
@@ -24,6 +24,8 @@
namespace Gob {
+void snd_initSound(void);
+void snd_loopSounds(void);
int16 snd_checkProAudio(void);
int16 snd_checkAdlib(void);
int16 snd_checkBlaster(void);
@@ -42,8 +44,10 @@
void snd_writeAdlib(int16 port, int16 data);
typedef struct Snd_SoundDesc {
+ SoundHandle handle;
char *data;
int32 size;
+ int16 repCount;
int16 timerTicks;
int16 inClocks;
int16 frequency;
More information about the Scummvm-git-logs
mailing list