[Scummvm-cvs-logs] CVS: scummvm/simon sound.cpp,1.21,1.22 sound.h,1.7,1.8
Max Horn
fingolfin at users.sourceforge.net
Sun Jun 15 04:49:02 CEST 2003
Update of /cvsroot/scummvm/scummvm/simon
In directory sc8-pr-cvs1:/tmp/cvs-serv16609
Modified Files:
sound.cpp sound.h
Log Message:
small reorg (keep private classes out of header files, if possible -> decreases compile times a bit); fixed a small memory leak for Simon2mac; don't delete _file twice in Sound subclasses
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- sound.cpp 15 Jun 2003 10:48:21 -0000 1.21
+++ sound.cpp 15 Jun 2003 11:48:04 -0000 1.22
@@ -22,6 +22,39 @@
#include "common/file.h"
#include "common/engine.h"
+class Sound {
+protected:
+ File *_file;
+ uint32 *_offsets;
+ SoundMixer *_mixer;
+
+public:
+ Sound(SoundMixer *mixer, File *file, uint32 base = 0);
+ Sound(SoundMixer *mixer, File *file, uint32 *offsets);
+ virtual ~Sound() { delete _file; }
+ virtual int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0) = 0;
+};
+
+class WavSound : public Sound {
+public:
+ WavSound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
+ WavSound(SoundMixer *mixer, File *file, uint32 *offsets) : Sound(mixer, file, offsets) {};
+ int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
+};
+
+class VocSound : public Sound {
+public:
+ VocSound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
+ int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
+};
+
+class MP3Sound : public Sound {
+public:
+ MP3Sound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
+ int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
+};
+
+
SimonSound::SimonSound(const byte game, const GameSpecificSettings *gss, const char *gameDataPath, SoundMixer *mixer) {
_game = game;
_gameDataPath = gameDataPath;
@@ -47,7 +80,6 @@
_ambient_playing = 0;
File *file = new File();
- File *file2 = new File();
const char *s;
#ifdef USE_MAD
@@ -59,6 +91,7 @@
file->open("voices.idx", gameDataPath);
if (file->isOpen() == false) {
warning("Can't open voice index file 'voices.idx'");
+ delete file;
} else {
file->seek(0, SEEK_END);
int end = file->pos();
@@ -99,6 +132,7 @@
#endif
if (_game == GAME_SIMON1TALKIE) {
+ File *file2 = new File();
#ifdef USE_MAD
file2->open(gss->mp3_effects_filename, gameDataPath);
if (file2->isOpen() == false) {
@@ -229,7 +263,7 @@
/******************************************************************************/
-SimonSound::Sound::Sound(SoundMixer *mixer, File *file, uint32 base) {
+Sound::Sound(SoundMixer *mixer, File *file, uint32 base) {
_mixer = mixer;
_file = file;
@@ -260,17 +294,12 @@
_offsets[res] = _file->pos();
}
-SimonSound::Sound::Sound(SoundMixer *mixer, File *file, uint32 *offsets) {
+Sound::Sound(SoundMixer *mixer, File *file, uint32 *offsets) {
_mixer = mixer;
_file = file;
_offsets = offsets;
}
-SimonSound::Sound::~Sound() { delete _file; }
-SimonSound::WavSound::~WavSound() { delete _file; }
-SimonSound::VocSound::~VocSound() { delete _file; }
-SimonSound::MP3Sound::~MP3Sound() { delete _file; }
-
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
@@ -311,7 +340,7 @@
#endif
#ifdef USE_MAD
-int SimonSound::MP3Sound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
+int MP3Sound::playSound(uint sound, PlayingSoundHandle *handle, byte flags)
{
if (_offsets == NULL)
return 0;
@@ -329,7 +358,7 @@
}
#endif
-int SimonSound::VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+int VocSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
if (_offsets == NULL)
return 0;
@@ -367,7 +396,7 @@
return _mixer->playRaw(handle, buffer, size, samples_per_sec, flags);
}
-int SimonSound::WavSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
+int WavSound::playSound(uint sound, PlayingSoundHandle *handle, byte flags) {
if (_offsets == NULL)
return 0;
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/sound.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sound.h 15 Jun 2003 09:55:10 -0000 1.7
+++ sound.h 15 Jun 2003 11:48:04 -0000 1.8
@@ -20,43 +20,10 @@
#include "sound/mixer.h"
#include "simon/intern.h"
+class Sound;
+
class SimonSound {
private:
- class Sound {
- protected:
- File *_file;
- uint32 *_offsets;
- SoundMixer *_mixer;
-
- public:
- Sound(SoundMixer *mixer, File *file, uint32 base = 0);
- Sound(SoundMixer *mixer, File *file, uint32 *offsets);
- virtual ~Sound();
- virtual int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0) = 0;
- };
-
- class WavSound : public Sound {
- public:
- WavSound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
- WavSound(SoundMixer *mixer, File *file, uint32 *offsets) : Sound(mixer, file, offsets) {};
- ~WavSound();
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
- };
-
- class VocSound : public Sound {
- public:
- VocSound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
- ~VocSound();
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
- };
-
- class MP3Sound : public Sound {
- public:
- MP3Sound(SoundMixer *mixer, File *file, uint32 base = 0) : Sound(mixer, file, base) {};
- ~MP3Sound();
- int playSound(uint sound, PlayingSoundHandle *handle, byte flags = 0);
- };
-
byte _game;
const char *_gameDataPath;
More information about the Scummvm-git-logs
mailing list