[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.323,1.324 sound.h,1.63,1.64
Max Horn
fingolfin at users.sourceforge.net
Fri Apr 9 17:23:11 CEST 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.62,1.63 dimuse_sndmgr.cpp,1.31,1.32 dimuse_sndmgr.h,1.22,1.23
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.63,1.64 dimuse_sndmgr.cpp,1.32,1.33 dimuse_track.cpp,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16337
Modified Files:
sound.cpp sound.h
Log Message:
Cleanup Sound constructor; change search order of SFX files
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.323
retrieving revision 1.324
diff -u -d -r1.323 -r1.324
--- sound.cpp 3 Apr 2004 00:56:54 -0000 1.323
+++ sound.cpp 10 Apr 2004 00:07:58 -0000 1.324
@@ -50,13 +50,31 @@
};
-Sound::Sound(ScummEngine *parent) {
- memset(this,0,sizeof(Sound)); // palmos
+Sound::Sound(ScummEngine *parent)
+ :
+ _vm(parent),
+ _soundQuePos(0),
+ _soundQue2Pos(0),
+ _sfxFile(0),
+ _offsetTable(0),
+ _numSoundEffects(0),
+ _soundMode(kVOCMode),
+ _talk_sound_a1(0),
+ _talk_sound_a2(0),
+ _talk_sound_b1(0),
+ _talk_sound_b2(0),
+ _talk_sound_mode(0),
+ _talk_sound_frame(0),
+ _mouthSyncMode(false),
+ _endOfMouthSync(false),
+ _curSoundPos(0),
+ _currentCDSound(0),
+ _soundsPaused(false),
+ _sfxMode(0) {
- _vm = parent;
- _currentCDSound = 0;
-
- _sfxFile = 0;
+ memset(_soundQue, 0, sizeof(_soundQue));
+ memset(_soundQue2, 0, sizeof(_soundQue2));
+ memset(_mouthSyncTimes, 0, sizeof(_mouthSyncTimes));
}
Sound::~Sound() {
@@ -553,11 +571,11 @@
num = (b - 8) >> 1;
}
- if (offset_table != NULL) {
+ if (_offsetTable != NULL) {
MP3OffsetTable *result = NULL, key;
key.org_offset = offset;
- result = (MP3OffsetTable *)bsearch(&key, offset_table, num_sound_effects,
+ result = (MP3OffsetTable *)bsearch(&key, _offsetTable, _numSoundEffects,
sizeof(MP3OffsetTable), compareMP3OffsetTable);
if (result == NULL) {
@@ -834,25 +852,23 @@
AudioStream *input = NULL;
- if (file_size > 0) {
- switch (_sound_mode) {
- case kMP3Mode:
+ switch (_soundMode) {
+ case kMP3Mode:
#ifdef USE_MAD
- input = makeMP3Stream(file, file_size);
+ input = makeMP3Stream(file, file_size);
#endif
- break;
- case kVorbisMode:
+ break;
+ case kVorbisMode:
#ifdef USE_VORBIS
- input = makeVorbisStream(file, file_size);
+ input = makeVorbisStream(file, file_size);
#endif
- break;
- case kFlacMode:
+ break;
+ case kFlacMode:
#ifdef USE_FLAC
- input = makeFlacStream(file, file_size);
+ input = makeFlacStream(file, file_size);
#endif
- break;
- }
- } else {
+ break;
+ default:
input = makeVOCStream(_sfxFile);
}
@@ -872,43 +888,51 @@
File *Sound::openSfxFile() {
char buf[256];
File *file = new File();
-
- /* Try opening the file <_gameName>.sou first, eg tentacle.sou.
- * That way, you can keep .sou files for multiple games in the
- * same directory */
- offset_table = NULL;
-
+ _offsetTable = NULL;
+
+ struct SoundFileExtensions {
+ const char *ext;
+ SoundMode mode;
+ };
+
+ const SoundFileExtensions extensions[] = {
#ifdef USE_FLAC
- if (!file->isOpen()) {
- sprintf(buf, "%s.sof", _vm->getGameName());
- if (!file->open(buf))
- file->open("monster.sof");
- if (file->isOpen())
- _sound_mode = kFlacMode;
- }
+ { "sof", kFlacMode },
#endif
-
#ifdef USE_MAD
- if (!file->isOpen()) {
- sprintf(buf, "%s.so3", _vm->getGameName());
- if (!file->open(buf))
- file->open("monster.so3");
- if (file->isOpen())
- _sound_mode = kMP3Mode;
- }
+ { "so3", kMP3Mode },
#endif
-
#ifdef USE_VORBIS
- if (!file->isOpen()) {
- sprintf(buf, "%s.sog", _vm->getGameName());
- if (!file->open(buf))
- file->open("monster.sog");
- if (file->isOpen())
- _sound_mode = kVorbisMode;
- }
+ { "sog", kVorbisMode },
#endif
+ { "sou", kVOCMode },
+ { 0, kVOCMode }
+ };
- if (file->isOpen()) {
+ /* Try opening the file <_gameName>.sou first, eg tentacle.sou.
+ * That way, you can keep .sou files for multiple games in the
+ * same directory */
+
+ int i, j;
+ const char *basename[3] = { 0, 0, 0 };
+ basename[0] = _vm->getGameName();
+ basename[1] = "monster";
+
+ for (j = 0; basename[j] && !file->isOpen(); ++j) {
+ for (i = 0; extensions[i].ext; ++i) {
+ sprintf(buf, "%s.%s", basename[j], extensions[i].ext);
+ if (file->open(buf)) {
+ _soundMode = extensions[i].mode;
+ break;
+ }
+ }
+ }
+
+ if (!file->isOpen()) {
+ sprintf(buf, "%s.tlk", _vm->getGameName());
+ file->open(buf, _vm->getGameDataPath(), File::kFileReadMode, 0x69);
+ _soundMode = kVOCMode;
+ } else if (_soundMode != kVOCMode) {
/* Now load the 'offset' index in memory to be able to find the MP3 data
The format of the .SO3 file is easy :
@@ -926,11 +950,11 @@
int size, compressed_offset;
MP3OffsetTable *cur;
compressed_offset = file->readUint32BE();
- offset_table = (MP3OffsetTable *) malloc(compressed_offset);
- num_sound_effects = compressed_offset / 16;
+ _offsetTable = (MP3OffsetTable *) malloc(compressed_offset);
+ _numSoundEffects = compressed_offset / 16;
size = compressed_offset;
- cur = offset_table;
+ cur = _offsetTable;
while (size > 0) {
cur[0].org_offset = file->readUint32BE();
cur[0].new_offset = file->readUint32BE() + compressed_offset + 4; /* The + 4 is to take into accound the 'size' field */
@@ -939,18 +963,8 @@
size -= 4 * 4;
cur++;
}
- return file;
}
- sprintf(buf, "%s.sou", _vm->getGameName());
- if (!file->open(buf)) {
- file->open("monster.sou");
- }
-
- if (!file->isOpen()) {
- sprintf(buf, "%s.tlk", _vm->getGameName());
- file->open(buf, _vm->getGameDataPath(), File::kFileReadMode, 0x69);
- }
return file;
}
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- sound.h 22 Feb 2004 14:11:14 -0000 1.63
+++ sound.h 10 Apr 2004 00:07:58 -0000 1.64
@@ -38,10 +38,23 @@
class Sound {
protected:
+ enum SoundMode {
+ kVOCMode,
+ kMP3Mode,
+ kVorbisMode,
+ kFlacMode
+ };
+
+ ScummEngine *_vm;
+
int16 _soundQuePos, _soundQue[0x100];
int16 _soundQue2Pos, _soundQue2[10];
File *_sfxFile;
+ SoundMode _soundMode;
+ MP3OffsetTable *_offsetTable; // For compressed audio
+ int _numSoundEffects; // For compressed audio
+
uint32 _talk_sound_a1, _talk_sound_a2, _talk_sound_b1, _talk_sound_b2;
byte _talk_sound_mode;
int _talk_sound_frame;
@@ -50,14 +63,7 @@
uint16 _mouthSyncTimes[64];
uint _curSoundPos;
- MP3OffsetTable *offset_table; // SO3 MP3 compressed audio
- int num_sound_effects; // SO3 MP3 compressed audio
- enum { kMP3Mode, kVorbisMode, kFlacMode } _sound_mode;
-
int _currentCDSound;
-
- ScummEngine *_vm;
-
public:
PlayingSoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
bool _soundsPaused;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.62,1.63 dimuse_sndmgr.cpp,1.31,1.32 dimuse_sndmgr.h,1.22,1.23
- Next message: [Scummvm-cvs-logs] CVS: scummvm/scumm/imuse_digi dimuse.cpp,1.63,1.64 dimuse_sndmgr.cpp,1.32,1.33 dimuse_track.cpp,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list