Fix using MAD -without- Vorbis, and remove COMPRESSED_SOUND_FILE define.

Please keep in mind that if you put an 'else' statement in an if clause, keep in mind that if the code it's supposed to
'else' is in another define.... and that isn't set... the NEXT statement of code will be used as the 'if..else'
condition.

svn-id: r5344
This commit is contained in:
James Brown 2002-10-28 12:56:42 +00:00
parent 0e0701ade4
commit 63ee97b1ee
6 changed files with 20 additions and 53 deletions

View File

@ -24,8 +24,8 @@
#include "scummsys.h"
#include "system.h"
#define SCUMMVM_VERSION "0.2.2 CVS"
#define SCUMMVM_CVS "2002-09-06"
#define SCUMMVM_VERSION "0.2.7 CVS"
#define SCUMMVM_CVS "2002-10-28+"
class SoundMixer;
class GameDetector;

View File

@ -325,9 +325,7 @@ void Scumm::scummInit()
getGraphicsPerformance();
#ifdef COMPRESSED_SOUND_FILE
_sound->_current_cache = 0;
#endif
_timer->installProcedure(&autosave, 5 * 60 * 1000);
}

View File

@ -453,13 +453,11 @@ void Sound::processSfxQueues() {
}
}
#ifdef COMPRESSED_SOUND_FILE
static int compar(const void *a, const void *b)
{
return ((MP3OffsetTable *) a)->org_offset -
((MP3OffsetTable *) b)->org_offset;
}
#endif
int Sound::startTalkSound(uint32 offset, uint32 b, int mode) {
int num = 0, i;
@ -491,7 +489,7 @@ int Sound::startTalkSound(uint32 offset, uint32 b, int mode) {
if (b > 8) {
num = (b - 8) >> 1;
}
#ifdef COMPRESSED_SOUND_FILE
if (offset_table != NULL) {
MP3OffsetTable *result = NULL, key;
@ -510,9 +508,7 @@ int Sound::startTalkSound(uint32 offset, uint32 b, int mode) {
}
offset = result->new_offset;
size = result->compressed_size;
} else
#endif
{
} else {
offset += 8;
size = -1;
}
@ -738,11 +734,10 @@ int Sound::startSfxSound(File *file, int file_size) {
int rate, comp;
byte *data;
#ifdef COMPRESSED_SOUND_FILE
if (file_size > 0) {
int alloc_size = file_size;
#ifdef USE_MAD
if (! _vorbis_mode)
if (!_vorbis_mode)
alloc_size += MAD_BUFFER_GUARD;
#endif
data = (byte *)calloc(alloc_size, 1);
@ -757,7 +752,7 @@ int Sound::startSfxSound(File *file, int file_size) {
else
return playSfxSound_MP3(data, file_size);
}
#endif
if (file->read(ident, 8) != 8)
goto invalid;
@ -810,7 +805,6 @@ File * Sound::openSfxFile() {
/* Try opening the file <_exe_name>.sou first, eg tentacle.sou.
* That way, you can keep .sou files for multiple games in the
* same directory */
#ifdef COMPRESSED_SOUND_FILE
offset_table = NULL;
#ifdef USE_MAD
@ -820,19 +814,19 @@ File * Sound::openSfxFile() {
}
if (file->isOpen())
_vorbis_mode = false;
else
#endif
#ifdef USE_VORBIS
{
sprintf(buf, "%s.sog", _scumm->_exe_name);
if (!file->open(buf, _scumm->getGameDataPath()))
file->open("monster.sog", _scumm->getGameDataPath());
if (file->isOpen())
_vorbis_mode = true;
}
#endif
if (file->isOpen() == true) {
#ifdef USE_VORBIS
if (!file->isOpen()) {
sprintf(buf, "%s.sog", _scumm->_exe_name);
if (!file->open(buf, _scumm->getGameDataPath()))
file->open("monster.sog", _scumm->getGameDataPath());
if (file->isOpen())
_vorbis_mode = true;
}
#endif
if (file->isOpen()) {
/* Now load the 'offset' index in memory to be able to find the MP3 data
The format of the .SO3 file is easy :
@ -849,7 +843,6 @@ File * Sound::openSfxFile() {
*/
int size, compressed_offset;
MP3OffsetTable *cur;
compressed_offset = file->readUint32BE();
offset_table = (MP3OffsetTable *) malloc(compressed_offset);
num_sound_effects = compressed_offset / 16;
@ -866,7 +859,7 @@ File * Sound::openSfxFile() {
}
return file;
}
#endif
sprintf(buf, "%s.sou", _scumm->_exe_name);
if (!file->open(buf, _scumm->getGameDataPath())) {
file->open("monster.sou", _scumm->getGameDataPath());
@ -1286,9 +1279,7 @@ void Sound::stopCDTimer()
void Sound::playCDTrack(int track, int num_loops, int start, int delay)
{
#ifdef COMPRESSED_SOUND_FILE
if (playMP3CDTrack(track, num_loops, start, delay) == -1)
#endif
_scumm->_system->play_cdrom(track, num_loops, start, delay);
// Start the timer after starting the track. Starting an MP3 track is
@ -1301,31 +1292,24 @@ void Sound::playCDTrack(int track, int num_loops, int start, int delay)
void Sound::stopCD()
{
stopCDTimer();
#ifdef COMPRESSED_SOUND_FILE
if (stopMP3CD() == -1)
#endif
_scumm->_system->stop_cdrom();
}
int Sound::pollCD()
{
#ifdef COMPRESSED_SOUND_FILE
if (pollMP3CD())
return 1;
#endif
return _scumm->_system->poll_cdrom();
}
void Sound::updateCD()
{
#ifdef COMPRESSED_SOUND_FILE
if (updateMP3CD() == -1)
#endif
_scumm->_system->update_cdrom();
}
#ifdef COMPRESSED_SOUND_FILE
int Sound::getCachedTrack(int track) {
int i;
char track_name[1024];
@ -1381,7 +1365,7 @@ int Sound::getCachedTrack(int track) {
}
#endif
debug(1, "Track %d not available in compressed format", track);
debug(2, "Track %d not available in compressed format", track);
return -1;
}
@ -1651,5 +1635,3 @@ Sound::VorbisTrackInfo::~VorbisTrackInfo() {
}
#endif
#endif

View File

@ -65,7 +65,6 @@ enum {
uint16 _mouthSyncTimes[52];
uint _curSoundPos;
#ifdef COMPRESSED_SOUND_FILE
MP3OffsetTable *offset_table; // SO3 MP3 compressed audio
int num_sound_effects; // SO3 MP3 compressed audio
bool _vorbis_mode; // true if using SOG, false if using SO3
@ -120,20 +119,14 @@ enum {
bool error() { return _error_flag; }
int play(SoundMixer *mixer, int start, int delay);
};
#endif
#endif
Scumm * _scumm;
public:
#ifdef COMPRESSED_SOUND_FILE
int _current_cache;
#endif
int _talkChannel; /* Mixer channel actor is talking on */
int _cd_timer_value;
bool _soundsPaused;
@ -184,13 +177,11 @@ public:
void updateCD();
protected:
#ifdef COMPRESSED_SOUND_FILE
int getCachedTrack(int track);
int playMP3CDTrack(int track, int num_loops, int start, int delay);
int stopMP3CD();
int pollMP3CD();
int updateMP3CD();
#endif
};
#endif

View File

@ -262,12 +262,10 @@ void SoundMixer::setMusicVolume(int volume) {
_musicVolume = volume;
}
#ifdef COMPRESSED_SOUND_FILE
bool SoundMixer::Channel::soundFinished() {
warning("sound_finished should never be called on a non-MP3 mixer ");
return false;
}
#endif
void SoundMixer::Channel::append(void * sound, uint32 size) {
error("append method should never be called on something else than a _STREAM mixer ");

View File

@ -52,9 +52,7 @@ private:
}
virtual void realDestroy() = 0;
virtual void append(void *sound, uint32 size);
#ifdef COMPRESSED_SOUND_FILE
virtual bool soundFinished();
#endif
};
class ChannelRaw : public Channel {