Added a member function loadSoundFile to Sound which accepts a filename string instead of a filename list id.

svn-id: r33527
This commit is contained in:
Johannes Schickel
2008-08-02 15:05:19 +00:00
parent 6e9bbd7348
commit 64fe71fed3
4 changed files with 42 additions and 20 deletions
+1 -9
View File
@@ -559,15 +559,7 @@ int TIMInterpreter::cmd_playVocFile(const uint16 *param) {
int TIMInterpreter::cmd_loadSoundFile(const uint16 *param) {
const char *file = (const char *)(_currentTim->text + READ_LE_UINT16(_currentTim->text + (param[0]<<1)));
static char * fileList[] = { 0 };
fileList[0] = _audioFilename;
static AudioDataStruct audioList = { fileList, 1, 0, 0 };
strncpy(_audioFilename, file, sizeof(_audioFilename));
_vm->sound()->setSoundList(&audioList);
_vm->sound()->loadSoundFile(0);
_vm->sound()->loadSoundFile(file);
return 1;
}
+11 -1
View File
@@ -328,7 +328,17 @@ struct DeleterArray {
void SoundMidiPC::loadSoundFile(uint file) {
Common::StackLock lock(_mutex);
Common::String filename = fileListEntry(file);
internalLoadFile(fileListEntry(file));
}
void SoundMidiPC::loadSoundFile(Common::String file) {
Common::StackLock lock(_mutex);
internalLoadFile(file);
}
void SoundMidiPC::internalLoadFile(Common::String file) {
Common::String filename = file;
filename += ".";
filename += _useC55 ? "C55" : "XMI";
+17 -3
View File
@@ -119,6 +119,12 @@ public:
*/
virtual void loadSoundFile(uint file) = 0;
/**
* Load a sound file for playing music
* and sound effects from.
*/
virtual void loadSoundFile(Common::String file) = 0;
/**
* Plays the specified track.
*
@@ -215,8 +221,6 @@ protected:
int _musicEnabled;
bool _sfxEnabled;
int _currentTheme;
KyraEngine_v1 *_vm;
Audio::Mixer *_mixer;
@@ -260,6 +264,7 @@ public:
void process();
void loadSoundFile(uint file);
void loadSoundFile(Common::String file);
void playTrack(uint8 track);
void haltTrack();
@@ -269,6 +274,8 @@ public:
void beginFadeOut();
private:
void internalLoadFile(Common::String file);
void play(uint8 track);
void unk1();
@@ -280,7 +287,8 @@ private:
uint8 _trackEntries[500];
uint8 *_soundDataPtr;
int _sfxPlayingSound;
uint _soundFileLoaded;
Common::String _soundFileLoaded;
uint8 _sfxPriority;
uint8 _sfxFourthByteOfSong;
@@ -316,6 +324,7 @@ public:
void updateVolumeSettings();
void loadSoundFile(uint file);
void loadSoundFile(Common::String file);
void playTrack(uint8 track);
void haltTrack();
@@ -343,6 +352,7 @@ public:
bool isMT32() const { return _nativeMT32; }
private:
void internalLoadFile(Common::String file);
void updateChannelVolume(uint8 vol);
static void onTimer(void *data);
@@ -397,6 +407,7 @@ public:
void process();
void loadSoundFile(uint file);
void loadSoundFile(Common::String) {}
void playTrack(uint8 track);
void haltTrack();
@@ -454,6 +465,7 @@ public:
void process() {}
void loadSoundFile(uint file) {}
void loadSoundFile(Common::String) {}
void playTrack(uint8 track);
void haltTrack();
@@ -480,6 +492,7 @@ public:
void process();
void loadSoundFile(uint file) {}
void loadSoundFile(Common::String) {}
void playTrack(uint8 track);
void haltTrack();
@@ -513,6 +526,7 @@ public:
void setSoundList(const AudioDataStruct * list) { _music->setSoundList(list); _sfx->setSoundList(list); }
bool hasSoundFile(uint file) const { return _music->hasSoundFile(file) && _sfx->hasSoundFile(file); }
void loadSoundFile(uint file) { _music->loadSoundFile(file); _sfx->loadSoundFile(file); }
void loadSoundFile(Common::String file) { _music->loadSoundFile(file); _sfx->loadSoundFile(file); }
void playTrack(uint8 track) { _music->playTrack(track); }
void haltTrack() { _music->haltTrack(); }
+13 -7
View File
@@ -2225,7 +2225,7 @@ SoundAdlibPC::SoundAdlibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer)
assert(_driver);
_sfxPlayingSound = -1;
_soundFileLoaded = (uint)-1;
_soundFileLoaded.clear();
if (_v2) {
// TODO: Figure out if Kyra 2 uses sound triggers at all.
@@ -2269,7 +2269,7 @@ void SoundAdlibPC::playTrack(uint8 track) {
// sync for each loop. To avoid that, we declare that all four
// of the song channels have to jump "in sync".
if (track == 4 && scumm_stricmp(fileListEntry(_soundFileLoaded), "KYRA1B") == 0)
if (track == 4 && _soundFileLoaded.equalsIgnoreCase("KYRA1B.ADL"))
_driver->setSyncJumpMask(0x000F);
else
_driver->setSyncJumpMask(0);
@@ -2348,6 +2348,15 @@ void SoundAdlibPC::beginFadeOut() {
}
void SoundAdlibPC::loadSoundFile(uint file) {
internalLoadFile(fileListEntry(file));
}
void SoundAdlibPC::loadSoundFile(Common::String file) {
internalLoadFile(file);
}
void SoundAdlibPC::internalLoadFile(Common::String file) {
file += ".ADL";
if (_soundFileLoaded == file)
return;
@@ -2356,12 +2365,9 @@ void SoundAdlibPC::loadSoundFile(uint file) {
uint8 *file_data = 0; uint32 file_size = 0;
char filename[25];
sprintf(filename, "%s.ADL", fileListEntry(file));
file_data = _vm->resource()->fileData(filename, &file_size);
file_data = _vm->resource()->fileData(file.c_str(), &file_size);
if (!file_data) {
warning("Couldn't find music file: '%s'", filename);
warning("Couldn't find music file: '%s'", file.c_str());
return;
}