Some more work on the new music code

svn-id: r46569
This commit is contained in:
Filippos Karapetis 2009-12-26 00:50:09 +00:00
parent a88e4df7a0
commit 12b6d4ab03
5 changed files with 18 additions and 7 deletions

View File

@ -33,12 +33,13 @@
#include "sci/engine/state.h"
#include "sci/engine/kernel.h"
#include "sci/engine/kernel_types.h"
#include "sci/gui/gui.h"
#include "sci/engine/message.h"
#include "sci/gui/gui.h"
#ifdef INCLUDE_OLDGFX
#include "sci/gfx/gfx_state_internal.h" // required for GfxPort, GfxVisual
#include "sci/gfx/menubar.h"
#endif
#include "sci/sfx/music.h"
namespace Sci {
@ -291,17 +292,17 @@ static void _free_graphics_input(EngineState *s) {
}
#endif
int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion) {
#ifdef USE_OLD_MUSIC_FUNCTIONS
int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion) {
if (getSciVersion() > SCI_VERSION_0_LATE)
sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
s->sfx_init_flags = sound_flags;
s->_sound.sfx_init(s->resMan, sound_flags, soundVersion);
#endif
return 0;
}
#endif
// Architectural stuff: Init/Unintialize engine
int script_init_engine(EngineState *s) {
@ -433,13 +434,16 @@ int game_init(EngineState *s) {
int game_exit(EngineState *s) {
s->_executionStack.clear();
#ifdef USE_OLD_MUSIC_FUNCTIONS
if (!s->successor) {
#ifdef USE_OLD_MUSIC_FUNCTIONS
s->_sound.sfx_exit();
// Reinit because some other code depends on having a valid state
game_init_sound(s, SFX_STATE_FLAG_NOSOUND, s->detectDoSoundType());
}
#else
s->_audio->stopAllAudio();
s->_soundCmd->_music->stopAll();
#endif
}
// Note: It's a bad idea to delete the segment manager here
// when loading a game.

View File

@ -148,6 +148,7 @@ static void syncSong(Common::Serializer &s, MusicEntry *song) {
// pMidiParser and pStreamAud will be initialized when the
// sound list is reconstructed in gamestate_restore()
if (s.isLoading()) {
song->soundRes = 0;
song->pMidiParser = 0;
song->pStreamAud = 0;
}

View File

@ -486,6 +486,7 @@ int game_init(EngineState *s);
int game_init_graphics(EngineState *s);
#endif
#ifdef USE_OLD_MUSIC_FUNCTIONS
/**
* Initializes the sound part of an SCI game
* This function may only be called if game_init() did not initialize
@ -496,6 +497,7 @@ int game_init_graphics(EngineState *s);
* @return 0 on success, 1 if an error occured
*/
int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion);
#endif
/**
* Runs an SCI game

View File

@ -200,10 +200,12 @@ Common::Error SciEngine::run() {
}
#endif
#ifdef USE_OLD_MUSIC_FUNCTIONS
if (game_init_sound(_gamestate, 0, soundVersion)) {
warning("Game initialization failed: Error in sound subsystem. Aborting...");
return Common::kUnknownError;
}
#endif
_gamestate->_gui->init(_gamestate->usesOldGfxFunctions());

View File

@ -130,11 +130,12 @@ bool SciMusic::restoreState(Common::InSaveFile *pFile){
void SciMusic::stopAll() {
_mutex.lock();
_pMixer->stopAll();
//audioStop();
for(uint i = 0; i < _playList.size(); i++){
for (uint i = 0; i < _playList.size(); i++){
soundStop(_playList[i]);
soundKill(_playList[i]);
}
_mutex.unlock();
}
//----------------------------------------
@ -469,6 +470,7 @@ void SciMusic::soundKill(MusicEntry *pSnd) {
for (i = 0; i < sz; i++) {
if (_playList[i] == pSnd) {
delete _playList[i]->soundRes;
_playList[i]->soundRes = 0;
_playList.remove_at(i);
break;
}