[Scummvm-cvs-logs] CVS: scummvm/simon sound.cpp,1.54,1.55 sound.h,1.14,1.15
Max Horn
fingolfin at users.sourceforge.net
Sat Dec 20 16:06:00 CET 2003
Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv15380
Modified Files:
sound.cpp sound.h
Log Message:
don't use sound/mixer index, rather use the sound handle!
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- sound.cpp 13 Dec 2003 01:54:53 -0000 1.54
+++ sound.cpp 21 Dec 2003 00:05:00 -0000 1.55
@@ -37,25 +37,25 @@
BaseSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false);
BaseSound(SoundMixer *mixer, File *file, uint32 *offsets, bool bigendian = false);
virtual ~BaseSound();
- virtual int playSound(uint sound, PlayingSoundHandle *handle, byte flags) = 0;
+ virtual void playSound(uint sound, PlayingSoundHandle *handle, byte flags) = 0;
};
class WavSound : public BaseSound {
public:
WavSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
WavSound(SoundMixer *mixer, File *file, uint32 *offsets) : BaseSound(mixer, file, offsets) {};
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
};
class VocSound : public BaseSound {
public:
VocSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
};
class RawSound : public BaseSound {
public:
RawSound(SoundMixer *mixer, File *file, uint32 base = 0, bool bigendian = false) : BaseSound(mixer, file, base, bigendian) {};
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
};
BaseSound::BaseSound(SoundMixer *mixer, File *file, uint32 base, bool bigendian) {
@@ -131,9 +131,9 @@
#pragma END_PACK_STRUCTS
#endif
-int WavSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+void WavSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
if (_offsets == NULL)
- return 0;
+ return;
WaveHeader wave_hdr;
uint32 data[2];
@@ -162,12 +162,12 @@
byte *buffer = (byte *)malloc(data[1]);
_file->read(buffer, data[1]);
- return _mixer->playRaw(handle, buffer, data[1], FROM_LE_32(wave_hdr.samples_per_sec), flags);
+ _mixer->playRaw(handle, buffer, data[1], FROM_LE_32(wave_hdr.samples_per_sec), flags);
}
-int VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+void VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
if (_offsets == NULL)
- return 0;
+ return;
VocHeader voc_hdr;
VocBlockHeader voc_block_hdr;
@@ -193,12 +193,12 @@
byte *buffer = (byte *)malloc(size);
_file->read(buffer, size);
- return _mixer->playRaw(handle, buffer, size, samples_per_sec, flags);
+ _mixer->playRaw(handle, buffer, size, samples_per_sec, flags);
}
-int RawSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+void RawSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
if (_offsets == NULL)
- return 0;
+ return;
flags |= SoundMixer::FLAG_AUTOFREE;
@@ -207,34 +207,31 @@
byte *buffer = (byte *)malloc(size);
_file->read(buffer, size);
- return _mixer->playRaw(handle, buffer, size, 22050, flags);
+ _mixer->playRaw(handle, buffer, size, 22050, flags);
}
#ifdef USE_MAD
class MP3Sound : public BaseSound {
public:
MP3Sound(SoundMixer *mixer, File *file, uint32 base = 0) : BaseSound(mixer, file, base) {};
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags);
+ void playSound(uint sound, PlayingSoundHandle *handle, byte flags);
};
-int MP3Sound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
+void MP3Sound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
{
if (_offsets == NULL)
- return 0;
+ return;
_file->seek(_offsets[sound], SEEK_SET);
uint32 size = _offsets[sound+1] - _offsets[sound];
- return _mixer->playMP3(handle, _file, size);
+ _mixer->playMP3(handle, _file, size);
}
#endif
SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const Common::String &gameDataPath, SoundMixer *mixer)
: _game(game), _gameDataPath(gameDataPath), _mixer(mixer) {
- _voice_index = 0;
- _ambient_index = 0;
-
_voice = 0;
_effects = 0;
@@ -420,10 +417,8 @@
if (!_voice)
return;
- if (_voice_handle)
- _mixer->stopChannel(_voice_index);
-
- _voice_index = _voice->playSound(sound, &_voice_handle, (_game == GAME_SIMON1CD32) ? 0 : SoundMixer::FLAG_UNSIGNED);
+ _mixer->stopHandle(_voice_handle);
+ _voice->playSound(sound, &_voice_handle, (_game == GAME_SIMON1CD32) ? 0 : SoundMixer::FLAG_UNSIGNED);
}
void SimonSound::playEffects(uint sound) {
@@ -448,10 +443,8 @@
if (_ambient_paused)
return;
- if (_ambient_handle)
- _mixer->stopChannel(_ambient_index);
-
- _ambient_index = _effects->playSound(sound, &_ambient_handle, SoundMixer::FLAG_LOOP|SoundMixer::FLAG_UNSIGNED);
+ _mixer->stopHandle(_ambient_handle);
+ _effects->playSound(sound, &_ambient_handle, SoundMixer::FLAG_LOOP|SoundMixer::FLAG_UNSIGNED);
}
bool SimonSound::hasVoice() {
@@ -459,7 +452,7 @@
}
void SimonSound::stopVoice() {
- _mixer->stopChannel(_voice_index);
+ _mixer->stopHandle(_voice_handle);
}
void SimonSound::stopAll() {
@@ -475,7 +468,7 @@
_ambient_paused = b;
if (_ambient_paused && _ambient_playing) {
- _mixer->stopChannel(_ambient_index);
+ _mixer->stopHandle(_ambient_handle);
} else if (_ambient_playing) {
uint tmp = _ambient_playing;
_ambient_playing = 0;
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sound.h 13 Dec 2003 01:54:17 -0000 1.14
+++ sound.h 21 Dec 2003 00:05:00 -0000 1.15
@@ -35,9 +35,6 @@
SoundMixer *_mixer;
- int _voice_index;
- int _ambient_index;
-
BaseSound *_voice;
BaseSound *_effects;
More information about the Scummvm-git-logs
mailing list