diff options
author | Max Horn | 2003-12-24 17:42:22 +0000 |
---|---|---|
committer | Max Horn | 2003-12-24 17:42:22 +0000 |
commit | 859a9c01290dc6022f99c7fd99ff91d62a3153dc (patch) | |
tree | 34a40bd53ce6c75e3685ec837c4da4c0a38d01f7 | |
parent | 5665d137f6bae488ac19539acdcfe441f514a9d6 (diff) | |
download | scummvm-rg350-859a9c01290dc6022f99c7fd99ff91d62a3153dc.tar.gz scummvm-rg350-859a9c01290dc6022f99c7fd99ff91d62a3153dc.tar.bz2 scummvm-rg350-859a9c01290dc6022f99c7fd99ff91d62a3153dc.zip |
o Added SoundMixer::isReady()
o Removed SoundMixer::bindToSystem()
o In scumm, replaced _silentMixer, _silentDigitalImuse and _noDigitalSamples by SoundMixer::isReady()
svn-id: r11893
-rw-r--r-- | queen/queen.cpp | 2 | ||||
-rw-r--r-- | scumm/imuse_digi.cpp | 6 | ||||
-rw-r--r-- | scumm/scumm.h | 2 | ||||
-rw-r--r-- | scumm/scummvm.cpp | 7 | ||||
-rw-r--r-- | scumm/smush/smush_mixer.cpp | 2 | ||||
-rw-r--r-- | scumm/smush/smush_mixer.h | 1 | ||||
-rw-r--r-- | scumm/smush/smush_player.cpp | 1 | ||||
-rw-r--r-- | scumm/sound.cpp | 2 | ||||
-rw-r--r-- | simon/simon.cpp | 2 | ||||
-rw-r--r-- | sky/sky.cpp | 2 | ||||
-rw-r--r-- | sound/audiostream.cpp | 2 | ||||
-rw-r--r-- | sound/mixer.cpp | 24 | ||||
-rw-r--r-- | sound/mixer.h | 15 | ||||
-rw-r--r-- | sword1/sword1.cpp | 2 | ||||
-rw-r--r-- | sword2/sword2.cpp | 2 |
15 files changed, 31 insertions, 41 deletions
diff --git a/queen/queen.cpp b/queen/queen.cpp index 235ecafabe..160b7fd92b 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -89,7 +89,7 @@ namespace Queen { QueenEngine::QueenEngine(GameDetector *detector, OSystem *syst) : Engine(syst) { - if (!_mixer->bindToSystem(syst)) + if (!_mixer->isReady()) warning("Sound initialisation failed."); _mixer->setVolume(ConfMan.getInt("sfx_volume")); diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp index 5cc84e2a75..6ec5293762 100644 --- a/scumm/imuse_digi.cpp +++ b/scumm/imuse_digi.cpp @@ -800,7 +800,7 @@ void IMuseDigital::mixerCallback() { memcpy(buf, _channel[l].data + _channel[l].offset, mixer_size); _channel[l].offset += mixer_size; - if (_scumm->_silentDigitalImuse == false) { + if (_scumm->_mixer->isReady()) { if (!_channel[l].handle.isActive()) _scumm->_mixer->newStream(&_channel[l].handle, _channel[l].freq, _channel[l].mixerFlags, 100000); @@ -1243,7 +1243,7 @@ void IMuseDigital::music_handler(void *refCon) { } void IMuseDigital::playBundleMusic(const char *song) { - if (_scumm->_silentDigitalImuse) { + if (!_scumm->_mixer->isReady()) { return; } @@ -1430,7 +1430,7 @@ void IMuseDigital::playBundleSound(const char *sound, PlayingSoundHandle *handle byte *final; bool result; - if (_scumm->_noDigitalSamples) + if (!_scumm->_mixer->isReady()) return; if (_scumm->_gameId == GID_CMI) { diff --git a/scumm/scumm.h b/scumm/scumm.h index 854de56181..0ae14807e6 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -969,8 +969,6 @@ protected: bool _copyProtection; bool _demoMode; bool _confirmExit; -public: - bool _silentDigitalImuse, _noDigitalSamples; #ifdef INSANE public: diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 2efb368831..9c13d60174 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -459,8 +459,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS _defaultTalkDelay = 0; _midiDriver = MD_NULL; tempMusic = 0; - _silentDigitalImuse = 0; - _noDigitalSamples = 0; _saveSound = 0; memset(_extraBoxFlags, 0, sizeof(_extraBoxFlags)); memset(_scaleSlots, 0, sizeof(_scaleSlots)); @@ -707,8 +705,7 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS #ifndef __GP32__ //ph0x FIXME, "quick dirty hack" /* Bind the mixer to the system => mixer will be invoked * automatically when samples need to be generated */ - _silentDigitalImuse = false; - if (!_mixer->bindToSystem(syst)) { + if (!_mixer->isReady()) { warning("Sound mixer initialization failed"); if (_midiDriver == MD_ADLIB || _midiDriver == MD_PCSPK || @@ -716,8 +713,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS _midiDriver = MD_NULL; warning("MIDI driver depends on sound mixer, switching to null MIDI driver"); } - _silentDigitalImuse = true; - _noDigitalSamples = true; } _mixer->setVolume(ConfMan.getInt("sfx_volume") * ConfMan.getInt("master_volume") / 255); _mixer->setMusicVolume(ConfMan.getInt("music_volume")); diff --git a/scumm/smush/smush_mixer.cpp b/scumm/smush/smush_mixer.cpp index 3c9b831d78..69d85c6a22 100644 --- a/scumm/smush/smush_mixer.cpp +++ b/scumm/smush/smush_mixer.cpp @@ -118,7 +118,7 @@ bool SmushMixer::handleFrame() { flags |= SoundMixer::FLAG_UNSIGNED; } - if (_silentMixer == false) { + if (_mixer->isReady()) { if (!_channels[i].handle.isActive()) _mixer->newStream(&_channels[i].handle, rate, flags, 500000); _mixer->appendStream(_channels[i].handle, data, size); diff --git a/scumm/smush/smush_mixer.h b/scumm/smush/smush_mixer.h index 74daa1091d..c0eacd809b 100644 --- a/scumm/smush/smush_mixer.h +++ b/scumm/smush/smush_mixer.h @@ -53,7 +53,6 @@ public: bool handleFrame(); bool stop(); bool update(); - bool _silentMixer; }; } // End of namespace Scumm diff --git a/scumm/smush/smush_player.cpp b/scumm/smush/smush_player.cpp index aa23b1f15e..9491f1e44c 100644 --- a/scumm/smush/smush_player.cpp +++ b/scumm/smush/smush_player.cpp @@ -252,7 +252,6 @@ void SmushPlayer::init() { _smixer = new SmushMixer(_scumm->_mixer); _scumm->setDirtyColors(0, 255); - _smixer->_silentMixer = _scumm->_silentDigitalImuse; _dst = _scumm->virtscr[0].screenPtr + _scumm->virtscr[0].xstart; g_timer->installTimerProc(&timerCallback, _speed, this); diff --git a/scumm/sound.cpp b/scumm/sound.cpp index a8d94d2ba0..3184674765 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -825,7 +825,7 @@ void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, int rate, comp; byte *data; - if (_soundsPaused || _scumm->_noDigitalSamples) + if (_soundsPaused || !_scumm->_mixer->isReady()) return; if (file_size > 0) { diff --git a/simon/simon.cpp b/simon/simon.cpp index a53c49e6a0..a53224d95a 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -530,7 +530,7 @@ SimonEngine::SimonEngine(GameDetector *detector, OSystem *syst) // Setup mixer - if (!_mixer->bindToSystem(syst)) + if (!_mixer->isReady()) warning("Sound initialization failed. " "Features of the game that depend on sound synchronization will most likely break"); set_volume(ConfMan.getInt("sfx_volume")); diff --git a/sky/sky.cpp b/sky/sky.cpp index c82675a498..e4160f97e9 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -115,7 +115,7 @@ SystemVars SkyEngine::_systemVars = {0, 0, 0, 0, 4316, 0, 0, false, false }; SkyEngine::SkyEngine(GameDetector *detector, OSystem *syst) : Engine(syst) { - if (!_mixer->bindToSystem(syst)) + if (!_mixer->isReady()) warning("Sound initialisation failed."); _mixer->setVolume(ConfMan.getInt("sfx_volume")); //unnecessary? diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index 8ac57481ee..f3bf3552f9 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -218,7 +218,7 @@ void WrappedMemoryStream<stereo, is16Bit, isUnsigned>::append(const byte *data, else if (is16Bit || stereo) assert((len & 1) == 0); - // Verify the stream has not been finalized (by a call to finish()) yet + // Verify that the stream has not yet been finalized (by a call to finish()) assert(!_finalized); if (_end + len > _bufferEnd) { diff --git a/sound/mixer.cpp b/sound/mixer.cpp index 1d0e13a0c1..1549424720 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -101,22 +101,27 @@ public: SoundMixer::SoundMixer() { - _syst = 0; - _mutex = 0; + _syst = OSystem::instance(); + _mutex = _syst->create_mutex(); _premixParam = 0; _premixProc = 0; int i = 0; - _outputRate = 0; + _outputRate = (uint) _syst->property(OSystem::PROP_GET_SAMPLE_RATE, 0); + + if (_outputRate == 0) + error("OSystem returned invalid sample rate"); _globalVolume = 0; _musicVolume = 0; _paused = false; - + for (i = 0; i != NUM_CHANNELS; i++) _channels[i] = 0; + + _mixerReady = _syst->set_sound_proc(mixCallback, this, OSystem::SOUND_16BIT); } SoundMixer::~SoundMixer() { @@ -127,17 +132,6 @@ SoundMixer::~SoundMixer() { _syst->delete_mutex(_mutex); } -bool SoundMixer::bindToSystem(OSystem *syst) { - _syst = syst; - _mutex = _syst->create_mutex(); - _outputRate = (uint) syst->property(OSystem::PROP_GET_SAMPLE_RATE, 0); - - if (_outputRate == 0) - error("OSystem returned invalid sample rate"); - - return syst->set_sound_proc(mixCallback, this, OSystem::SOUND_16BIT); -} - void SoundMixer::setupPremix(PremixProc *proc, void *param) { Common::StackLock lock(_mutex); _premixParam = param; diff --git a/sound/mixer.h b/sound/mixer.h index d1bd379408..9001245e0e 100644 --- a/sound/mixer.h +++ b/sound/mixer.h @@ -82,17 +82,22 @@ private: int _musicVolume; bool _paused; - + Channel *_channels[NUM_CHANNELS]; + bool _mixerReady; + public: SoundMixer(); ~SoundMixer(); - /** bind to the OSystem object => mixer will be - * invoked automatically when samples need - * to be generated */ - bool bindToSystem(OSystem *syst); + /** + * Is the mixer ready and setup? This may not be the case on systems which + * don't support digital sound output. In that case, the mixer proc may + * never be called. That in turn can cause breakage in games which use the + * premix callback for syncing. In particular, the Adlib MIDI emulation... + */ + bool isReady() const { return _mixerReady; }; /** * Set the premix procedure. This is mainly used for the adlib music, but diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp index 783ecf7558..36d7522edd 100644 --- a/sword1/sword1.cpp +++ b/sword1/sword1.cpp @@ -89,7 +89,7 @@ SwordEngine::SwordEngine(GameDetector *detector, OSystem *syst) _system = syst; _debugLevel = ConfMan.getInt("debuglevel"); - if (!_mixer->bindToSystem(syst)) + if (!_mixer->isReady()) warning("Sound initialization failed"); } diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index b976592cea..bf33cf186a 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -107,7 +107,7 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) _debugLevel = ConfMan.getInt("debuglevel"); // Setup mixer - if (!_mixer->bindToSystem(syst)) + if (!_mixer->isReady()) warning("Sound initialization failed"); // We have our own volume settings panel, so don't let ScummVM's mixer |