svn-id: r24407
This commit is contained in:
Max Horn 2006-10-21 12:44:10 +00:00
parent 86d3f30347
commit 9edf1e6a1a
32 changed files with 136 additions and 124 deletions

View file

@ -546,8 +546,8 @@ void Interface::textInputRepeatCallback(void *refCon) {
void Interface::textInputStartRepeat(uint16 ascii) { void Interface::textInputStartRepeat(uint16 ascii) {
if (!_textInputRepeatPhase) { if (!_textInputRepeatPhase) {
_textInputRepeatPhase = 1; _textInputRepeatPhase = 1;
Common::g_timer->removeTimerProc(&textInputRepeatCallback); _vm->_timer->removeTimerProc(&textInputRepeatCallback);
Common::g_timer->installTimerProc(&textInputRepeatCallback, KEYBOARD_REPEAT_DELAY1, this); _vm->_timer->installTimerProc(&textInputRepeatCallback, KEYBOARD_REPEAT_DELAY1, this);
} }
_textInputRepeatChar = ascii; _textInputRepeatChar = ascii;
@ -556,8 +556,8 @@ void Interface::textInputStartRepeat(uint16 ascii) {
void Interface::textInputRepeat() { void Interface::textInputRepeat() {
if (_textInputRepeatPhase == 1) { if (_textInputRepeatPhase == 1) {
_textInputRepeatPhase = 2; _textInputRepeatPhase = 2;
Common::g_timer->removeTimerProc(&textInputRepeatCallback); _vm->_timer->removeTimerProc(&textInputRepeatCallback);
Common::g_timer->installTimerProc(&textInputRepeatCallback, KEYBOARD_REPEAT_DELAY2, this); _vm->_timer->installTimerProc(&textInputRepeatCallback, KEYBOARD_REPEAT_DELAY2, this);
} else if (_textInputRepeatPhase == 2) { } else if (_textInputRepeatPhase == 2) {
processAscii(_textInputRepeatChar, true); processAscii(_textInputRepeatChar, true);
} }
@ -565,7 +565,7 @@ void Interface::textInputRepeat() {
void Interface::processKeyUp(uint16 ascii) { void Interface::processKeyUp(uint16 ascii) {
if (_textInputRepeatPhase) { if (_textInputRepeatPhase) {
Common::g_timer->removeTimerProc(&textInputRepeatCallback); _vm->_timer->removeTimerProc(&textInputRepeatCallback);
_textInputRepeatPhase = 0; _textInputRepeatPhase = 0;
} }
} }

View file

@ -346,7 +346,7 @@ void Music::musicVolumeGauge() {
_player->setVolume(volume); _player->setVolume(volume);
if (_currentVolumePercent == 100) { if (_currentVolumePercent == 100) {
Common::g_timer->removeTimerProc(&musicVolumeGaugeCallback); _vm->_timer->removeTimerProc(&musicVolumeGaugeCallback);
_currentVolume = _targetVolume; _currentVolume = _targetVolume;
} }
} }
@ -361,12 +361,12 @@ void Music::setVolume(int volume, int time) {
if (time == 1) { if (time == 1) {
_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, volume);
_player->setVolume(volume); _player->setVolume(volume);
Common::g_timer->removeTimerProc(&musicVolumeGaugeCallback); _vm->_timer->removeTimerProc(&musicVolumeGaugeCallback);
_currentVolume = volume; _currentVolume = volume;
return; return;
} }
Common::g_timer->installTimerProc(&musicVolumeGaugeCallback, time * 100L, this); _vm->_timer->installTimerProc(&musicVolumeGaugeCallback, time * 100L, this);
} }
bool Music::isPlaying() { bool Music::isPlaying() {

View file

@ -119,7 +119,7 @@ void Puzzle::initPieceInfo(int i, int16 curX, int16 curY, byte offX, byte offY,
void Puzzle::execute(void) { void Puzzle::execute(void) {
_active = true; _active = true;
Common::g_timer->installTimerProc(&hintTimerCallback, kPuzzleHintTime, this); _vm->_timer->installTimerProc(&hintTimerCallback, kPuzzleHintTime, this);
initPieces(); initPieces();
@ -134,7 +134,7 @@ void Puzzle::execute(void) {
void Puzzle::exitPuzzle(void) { void Puzzle::exitPuzzle(void) {
_active = false; _active = false;
Common::g_timer->removeTimerProc(&hintTimerCallback); _vm->_timer->removeTimerProc(&hintTimerCallback);
_vm->_scene->changeScene(ITE_SCENE_LODGE, 0, kTransitionNoFade); _vm->_scene->changeScene(ITE_SCENE_LODGE, 0, kTransitionNoFade);
_vm->_interface->setMode(kPanelMain); _vm->_interface->setMode(kPanelMain);
@ -383,17 +383,17 @@ void Puzzle::solicitHint(void) {
_vm->_actor->setSpeechColor(1, kITEColorBlack); _vm->_actor->setSpeechColor(1, kITEColorBlack);
Common::g_timer->removeTimerProc(&hintTimerCallback); _vm->_timer->removeTimerProc(&hintTimerCallback);
switch (_hintRqState) { switch (_hintRqState) {
case kRQSpeaking: case kRQSpeaking:
if (_vm->_actor->isSpeaking()) { if (_vm->_actor->isSpeaking()) {
Common::g_timer->installTimerProc(&hintTimerCallback, 50000, this); _vm->_timer->installTimerProc(&hintTimerCallback, 50000, this);
break; break;
} }
_hintRqState = _hintNextRqState; _hintRqState = _hintNextRqState;
Common::g_timer->installTimerProc(&hintTimerCallback, 333333, this); _vm->_timer->installTimerProc(&hintTimerCallback, 333333, this);
break; break;
case kRQNoHint: case kRQNoHint:
@ -416,11 +416,11 @@ void Puzzle::solicitHint(void) {
// Roll to see if Sakka scolds // Roll to see if Sakka scolds
if (_vm->_rnd.getRandomNumber(1)) { if (_vm->_rnd.getRandomNumber(1)) {
_hintRqState = kRQSakkaDenies; _hintRqState = kRQSakkaDenies;
Common::g_timer->installTimerProc(&hintTimerCallback, 200000, this); _vm->_timer->installTimerProc(&hintTimerCallback, 200000, this);
} else { } else {
_hintRqState = kRQSpeaking; _hintRqState = kRQSpeaking;
_hintNextRqState = kRQHintRequested; _hintNextRqState = kRQHintRequested;
Common::g_timer->installTimerProc(&hintTimerCallback, 50000, this); _vm->_timer->installTimerProc(&hintTimerCallback, 50000, this);
} }
break; break;
@ -433,7 +433,7 @@ void Puzzle::solicitHint(void) {
_hintRqState = kRQSpeaking; _hintRqState = kRQSpeaking;
_hintNextRqState = kRQHintRequestedStage2; _hintNextRqState = kRQHintRequestedStage2;
Common::g_timer->installTimerProc(&hintTimerCallback, 50000, this); _vm->_timer->installTimerProc(&hintTimerCallback, 50000, this);
_vm->_interface->converseClear(); _vm->_interface->converseClear();
_vm->_interface->converseAddText(optionsStr[_lang][kROAccept], 1, 0, 0 ); _vm->_interface->converseAddText(optionsStr[_lang][kROAccept], 1, 0, 0 );
@ -460,7 +460,7 @@ void Puzzle::solicitHint(void) {
_vm->_interface->converseAddText(optionsStr[_lang][kROLater], 0, 0, 0); _vm->_interface->converseAddText(optionsStr[_lang][kROLater], 0, 0, 0);
_vm->_interface->converseDisplayText(); _vm->_interface->converseDisplayText();
Common::g_timer->installTimerProc(&hintTimerCallback, kPuzzleHintTime, this); _vm->_timer->installTimerProc(&hintTimerCallback, kPuzzleHintTime, this);
_hintRqState = kRQSkipEverything; _hintRqState = kRQSkipEverything;
break; break;
@ -483,8 +483,8 @@ void Puzzle::handleReply(int reply) {
case 2: // Decline the hint case 2: // Decline the hint
_vm->_actor->abortSpeech(); _vm->_actor->abortSpeech();
_hintRqState = kRQNoHint; _hintRqState = kRQNoHint;
Common::g_timer->removeTimerProc(&hintTimerCallback); _vm->_timer->removeTimerProc(&hintTimerCallback);
Common::g_timer->installTimerProc(&hintTimerCallback, kPuzzleHintTime * 2, this); _vm->_timer->installTimerProc(&hintTimerCallback, kPuzzleHintTime * 2, this);
clearHint(); clearHint();
break; break;
} }
@ -546,8 +546,8 @@ void Puzzle::giveHint(void) {
_vm->_interface->converseAddText(optionsStr[_lang][kROLater], 0, 0, 0); _vm->_interface->converseAddText(optionsStr[_lang][kROLater], 0, 0, 0);
_vm->_interface->converseDisplayText(); _vm->_interface->converseDisplayText();
Common::g_timer->removeTimerProc(&hintTimerCallback); _vm->_timer->removeTimerProc(&hintTimerCallback);
Common::g_timer->installTimerProc(&hintTimerCallback, kPuzzleHintTime, this); _vm->_timer->installTimerProc(&hintTimerCallback, kPuzzleHintTime, this);
} }
void Puzzle::clearHint(void) { void Puzzle::clearHint(void) {

View file

@ -326,7 +326,7 @@ void SaveLoadChooser::reflowLayout() {
int thumbY = g_gui.evaluator()->getVar("scummsaveload_thumbnail.y"); int thumbY = g_gui.evaluator()->getVar("scummsaveload_thumbnail.y");
int hPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.hPad"); int hPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.hPad");
int vPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.vPad"); int vPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.vPad");
int thumbH = ((_vm->_system->getHeight() % 200 && _vm->_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1); int thumbH = ((g_system->getHeight() % 200 && g_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1);
_container->resize(thumbX - hPad, thumbY - vPad, kThumbnailWidth + hPad * 2, thumbH + vPad * 2 + kLineHeight * 4); _container->resize(thumbX - hPad, thumbY - vPad, kThumbnailWidth + hPad * 2, thumbH + vPad * 2 + kLineHeight * 4);

View file

@ -46,9 +46,9 @@
namespace Scumm { namespace Scumm {
SoundHE::SoundHE(ScummEngine *parent) SoundHE::SoundHE(ScummEngine *parent, Audio::Mixer *mixer)
: :
Sound(parent), Sound(parent, mixer),
_vm((ScummEngine_v60he *)parent), _vm((ScummEngine_v60he *)parent),
_overrideFreq(0), _overrideFreq(0),
_heMusic(0), _heMusic(0),
@ -114,7 +114,7 @@ void SoundHE::processSoundQueues() {
int SoundHE::isSoundRunning(int sound) const { int SoundHE::isSoundRunning(int sound) const {
if (_vm->_game.heversion >= 70) { if (_vm->_game.heversion >= 70) {
if (sound >= 10000) { if (sound >= 10000) {
return _vm->_mixer->getSoundID(_heSoundChannels[sound - 10000]); return _mixer->getSoundID(_heSoundChannels[sound - 10000]);
} }
} else if (_vm->_game.heversion >= 60) { } else if (_vm->_game.heversion >= 60) {
if (sound == -2) { if (sound == -2) {
@ -124,7 +124,7 @@ int SoundHE::isSoundRunning(int sound) const {
} }
} }
if (_vm->_mixer->isSoundIDActive(sound)) if (_mixer->isSoundIDActive(sound))
return sound; return sound;
if (isSoundInQueue(sound)) if (isSoundInQueue(sound))
@ -189,7 +189,7 @@ void SoundHE::stopSoundChannel(int chan) {
_vm->_talkDelay = 0; _vm->_talkDelay = 0;
} }
_vm->_mixer->stopHandle(_heSoundChannels[chan]); _mixer->stopHandle(_heSoundChannels[chan]);
_heChannel[chan].sound = 0; _heChannel[chan].sound = 0;
_heChannel[chan].priority = 0; _heChannel[chan].priority = 0;
@ -219,7 +219,7 @@ int SoundHE::findFreeSoundChannel() {
if (min < 8) { if (min < 8) {
for (chan = min; chan < ARRAYSIZE(_heChannel); chan++) { for (chan = min; chan < ARRAYSIZE(_heChannel); chan++) {
if (_vm->_mixer->isSoundHandleActive(_heSoundChannels[chan]) == 0) if (_mixer->isSoundHandleActive(_heSoundChannels[chan]) == 0)
return chan; return chan;
} }
} else { } else {
@ -236,7 +236,7 @@ int SoundHE::isSoundCodeUsed(int sound) {
chan = i; chan = i;
} }
if (_vm->_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) { if (_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) {
return _heChannel[chan].sbngBlock; return _heChannel[chan].sbngBlock;
} else { } else {
return 0; return 0;
@ -250,7 +250,7 @@ int SoundHE::getSoundPos(int sound) {
chan = i; chan = i;
} }
if (_vm->_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) { if (_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) {
int time = _vm->getHETimer(chan + 4) * 11025 / 1000; int time = _vm->getHETimer(chan + 4) * 11025 / 1000;
return time; return time;
} else { } else {
@ -271,7 +271,7 @@ int SoundHE::getSoundVar(int sound, int var) {
chan = i; chan = i;
} }
if (_vm->_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) { if (_mixer->isSoundHandleActive(_heSoundChannels[chan]) && chan != -1) {
debug(5, "getSoundVar: sound %d var %d result %d", sound, var, _heChannel[chan].soundVars[var]); debug(5, "getSoundVar: sound %d var %d result %d", sound, var, _heChannel[chan].soundVars[var]);
return _heChannel[chan].soundVars[var]; return _heChannel[chan].soundVars[var];
} else { } else {
@ -528,14 +528,14 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
musicFile.seek(music_offs, SEEK_SET); musicFile.seek(music_offs, SEEK_SET);
_vm->_mixer->stopHandle(_heSoundChannels[heChannel]); _mixer->stopHandle(_heSoundChannels[heChannel]);
spoolPtr = _vm->_res->createResource(rtSpoolBuffer, heChannel, size); spoolPtr = _vm->_res->createResource(rtSpoolBuffer, heChannel, size);
assert(spoolPtr); assert(spoolPtr);
musicFile.read(spoolPtr, size); musicFile.read(spoolPtr, size);
musicFile.close(); musicFile.close();
if (_vm->_game.heversion == 70) { if (_vm->_game.heversion == 70) {
_vm->_mixer->playRaw(&_heSoundChannels[heChannel], spoolPtr, size, 11025, flags, soundID, 255, 0, 0,0, type); _mixer->playRaw(&_heSoundChannels[heChannel], spoolPtr, size, 11025, flags, soundID, 255, 0, 0,0, type);
return; return;
} }
} }
@ -585,8 +585,8 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
flags |= Audio::Mixer::FLAG_LOOP; flags |= Audio::Mixer::FLAG_LOOP;
} }
_vm->_mixer->stopHandle(_heSoundChannels[heChannel]); _mixer->stopHandle(_heSoundChannels[heChannel]);
_vm->_mixer->playRaw(&_heSoundChannels[heChannel], sound, size, rate, flags, soundID, 255, 0, 0,0, type); _mixer->playRaw(&_heSoundChannels[heChannel], sound, size, rate, flags, soundID, 255, 0, 0,0, type);
} }
// Support for sound in Humongous Entertainment games // Support for sound in Humongous Entertainment games
else if (READ_BE_UINT32(ptr) == MKID_BE('DIGI') || READ_BE_UINT32(ptr) == MKID_BE('TALK')) { else if (READ_BE_UINT32(ptr) == MKID_BE('DIGI') || READ_BE_UINT32(ptr) == MKID_BE('TALK')) {
@ -598,7 +598,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
// Skip DIGI/TALK (8) and HSHD (24) blocks // Skip DIGI/TALK (8) and HSHD (24) blocks
ptr += 32; ptr += 32;
if (_vm->_mixer->isSoundHandleActive(_heSoundChannels[heChannel])) { if (_mixer->isSoundHandleActive(_heSoundChannels[heChannel])) {
int curSnd = _heChannel[heChannel].sound; int curSnd = _heChannel[heChannel].sound;
if (curSnd == 1 && soundID != 1) if (curSnd == 1 && soundID != 1)
return; return;
@ -641,8 +641,8 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
_heChannel[heChannel].timer = size * 1000 / rate; _heChannel[heChannel].timer = size * 1000 / rate;
} }
_vm->_mixer->stopHandle(_heSoundChannels[heChannel]); _mixer->stopHandle(_heSoundChannels[heChannel]);
_vm->_mixer->playRaw(&_heSoundChannels[heChannel], ptr + heOffset + 8, size, rate, flags, soundID, 255, 0, 0,0, type); _mixer->playRaw(&_heSoundChannels[heChannel], ptr + heOffset + 8, size, rate, flags, soundID, 255, 0, 0,0, type);
} }
// Support for PCM music in 3DO versions of Humongous Entertainment games // Support for PCM music in 3DO versions of Humongous Entertainment games
@ -658,9 +658,9 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
flags = Audio::Mixer::FLAG_AUTOFREE; flags = Audio::Mixer::FLAG_AUTOFREE;
_vm->_mixer->stopID(_currentMusic); _mixer->stopID(_currentMusic);
_currentMusic = soundID; _currentMusic = soundID;
_vm->_mixer->playRaw(NULL, ptr + 8, size, rate, flags, soundID, 255, 0, 0,0, Audio::Mixer::kMusicSoundType); _mixer->playRaw(NULL, ptr + 8, size, rate, flags, soundID, 255, 0, 0,0, Audio::Mixer::kMusicSoundType);
} }
else if (READ_BE_UINT32(ptr) == MKID_BE('MIDI')) { else if (READ_BE_UINT32(ptr) == MKID_BE('MIDI')) {
if (_vm->_imuse) { if (_vm->_imuse) {

View file

@ -56,7 +56,7 @@ public: // Used by createSound()
} _heChannel[8]; } _heChannel[8];
public: public:
SoundHE(ScummEngine *parent); SoundHE(ScummEngine *parent, Audio::Mixer *mixer);
~SoundHE(); ~SoundHE();
virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0); virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);

View file

@ -44,8 +44,8 @@ void IMuseDigital::timer_handler(void *refCon) {
imuseDigital->callback(); imuseDigital->callback();
} }
IMuseDigital::IMuseDigital(ScummEngine_v7 *scumm, int fps) IMuseDigital::IMuseDigital(ScummEngine_v7 *scumm, Audio::Mixer *mixer, int fps)
: _vm(scumm) { : _vm(scumm), _mixer(mixer) {
_pause = false; _pause = false;
_sound = new ImuseDigiSndMgr(_vm); _sound = new ImuseDigiSndMgr(_vm);
assert(_sound); assert(_sound);
@ -200,7 +200,7 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
if (track->volGroupId == 3) if (track->volGroupId == 3)
type = Audio::Mixer::kMusicSoundType; type = Audio::Mixer::kMusicSoundType;
_vm->_mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false); _mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false);
} }
} }
} }
@ -318,9 +318,9 @@ void IMuseDigital::callback() {
if (result > mixer_size) if (result > mixer_size)
result = mixer_size; result = mixer_size;
if (_vm->_mixer->isReady()) { if (_mixer->isReady()) {
_vm->_mixer->setChannelVolume(track->handle, vol); _mixer->setChannelVolume(track->handle, vol);
_vm->_mixer->setChannelBalance(track->handle, pan); _mixer->setChannelBalance(track->handle, pan);
track->stream->append(data, result); track->stream->append(data, result);
track->regionOffset += result; track->regionOffset += result;
} }
@ -335,13 +335,13 @@ void IMuseDigital::callback() {
assert(mixer_size >= 0); assert(mixer_size >= 0);
} while (mixer_size != 0); } while (mixer_size != 0);
} else if (track->stream2) { } else if (track->stream2) {
if (_vm->_mixer->isReady()) { if (_mixer->isReady()) {
if (!track->started) { if (!track->started) {
track->started = true; track->started = true;
_vm->_mixer->playInputStream(type, &track->handle, track->stream2, -1, vol, pan, false); _mixer->playInputStream(type, &track->handle, track->stream2, -1, vol, pan, false);
} else { } else {
_vm->_mixer->setChannelVolume(track->handle, vol); _mixer->setChannelVolume(track->handle, vol);
_vm->_mixer->setChannelBalance(track->handle, pan); _mixer->setChannelBalance(track->handle, pan);
} }
} }
} }

View file

@ -90,6 +90,7 @@ private:
Common::Mutex _mutex; Common::Mutex _mutex;
ScummEngine_v7 *_vm; ScummEngine_v7 *_vm;
Audio::Mixer *_mixer;
ImuseDigiSndMgr *_sound; ImuseDigiSndMgr *_sound;
char *_audioNames; char *_audioNames;
@ -131,7 +132,7 @@ private:
void playDigMusic(const char *songName, const imuseDigTable *table, int atribPos, bool sequence); void playDigMusic(const char *songName, const imuseDigTable *table, int atribPos, bool sequence);
public: public:
IMuseDigital(ScummEngine_v7 *scumm, int fps); IMuseDigital(ScummEngine_v7 *scumm, Audio::Mixer *mixer, int fps);
virtual ~IMuseDigital(); virtual ~IMuseDigital();
void setAudioNames(int32 num, char *names); void setAudioNames(int32 num, char *names);

View file

@ -172,9 +172,9 @@ void IMuseDigital::flushTracks() {
track->stream->finish(); track->stream->finish();
} }
if (track->stream->endOfStream() if (track->stream->endOfStream()
|| _vm->_mixer->isPaused() // hack for paused Mixer || _mixer->isPaused() // hack for paused Mixer
|| _vm->_insaneRunning) { // INSANE hack for sync timer mode || _vm->_insaneRunning) { // INSANE hack for sync timer mode
_vm->_mixer->stopHandle(track->handle); _mixer->stopHandle(track->handle);
delete track->stream; delete track->stream;
track->stream = NULL; track->stream = NULL;
_sound->closeSound(track->soundHandle); _sound->closeSound(track->soundHandle);
@ -182,7 +182,7 @@ void IMuseDigital::flushTracks() {
track->used = false; track->used = false;
} }
} else if (track->stream2) { } else if (track->stream2) {
_vm->_mixer->stopHandle(track->handle); _mixer->stopHandle(track->handle);
delete track->stream2; delete track->stream2;
track->stream2 = NULL; track->stream2 = NULL;
track->used = false; track->used = false;
@ -285,7 +285,7 @@ int IMuseDigital::getSoundStatus(int sound) const {
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) { for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
Track *track = _track[l]; Track *track = _track[l];
if (track->soundId == sound) { if (track->soundId == sound) {
if ((track->stream2 && _vm->_mixer->isSoundHandleActive(track->handle)) || if ((track->stream2 && _mixer->isSoundHandleActive(track->handle)) ||
(track->stream && track->used && !track->readyToRemove)) { (track->stream && track->used && !track->readyToRemove)) {
return 1; return 1;
} }

View file

@ -179,7 +179,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
int32 streamBufferSize = track->iteration; int32 streamBufferSize = track->iteration;
track->stream2 = NULL; track->stream2 = NULL;
track->stream = Audio::makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize); track->stream = Audio::makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
_vm->_mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false); _mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false);
track->started = true; track->started = true;
} }
@ -358,7 +358,7 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel
// setup 1 second stream wrapped buffer // setup 1 second stream wrapped buffer
int32 streamBufferSize = fadeTrack->iteration; int32 streamBufferSize = fadeTrack->iteration;
fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags, streamBufferSize); fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags, streamBufferSize);
_vm->_mixer->playInputStream(type, &fadeTrack->handle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false); _mixer->playInputStream(type, &fadeTrack->handle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false);
fadeTrack->started = true; fadeTrack->started = true;
fadeTrack->used = true; fadeTrack->used = true;

View file

@ -28,9 +28,9 @@
namespace Scumm { namespace Scumm {
Player_MOD::Player_MOD(ScummEngine *scumm) { Player_MOD::Player_MOD(Audio::Mixer *mixer) {
int i; int i;
_mixer = scumm->_mixer; _mixer = mixer;
_samplerate = _mixer->getOutputRate(); _samplerate = _mixer->getOutputRate();
_mixamt = 0; _mixamt = 0;
_mixpos = 0; _mixpos = 0;

View file

@ -38,7 +38,7 @@ namespace Scumm {
*/ */
class Player_MOD : public Audio::AudioStream { class Player_MOD : public Audio::AudioStream {
public: public:
Player_MOD(ScummEngine *scumm); Player_MOD(Audio::Mixer *mixer);
virtual ~Player_MOD(); virtual ~Player_MOD();
virtual void setMusicVolume(int vol); virtual void setMusicVolume(int vol);

View file

@ -605,10 +605,10 @@ int16 APU_GetSample(void) {
} }
Player_NES::Player_NES(ScummEngine *scumm) { Player_NES::Player_NES(ScummEngine *scumm, Audio::Mixer *mixer) {
int i; int i;
_vm = scumm; _vm = scumm;
_mixer = scumm->_mixer; _mixer = mixer;
APUe::APU.SampleRate = _sample_rate = _mixer->getOutputRate(); APUe::APU.SampleRate = _sample_rate = _mixer->getOutputRate();
_samples_per_frame = _sample_rate / 60; _samples_per_frame = _sample_rate / 60;

View file

@ -45,7 +45,7 @@ static const int NUMCHANS = 4;
*/ */
class Player_NES : public Audio::AudioStream, public MusicEngine { class Player_NES : public Audio::AudioStream, public MusicEngine {
public: public:
Player_NES(ScummEngine *scumm); Player_NES(ScummEngine *scumm, Audio::Mixer *mixer);
virtual ~Player_NES(); virtual ~Player_NES();
virtual void setMusicVolume(int vol); virtual void setMusicVolume(int vol);

View file

@ -34,7 +34,8 @@ namespace Scumm {
#define TIMER_BASE_FREQ 1193000 #define TIMER_BASE_FREQ 1193000
#define FIXP_SHIFT 16 #define FIXP_SHIFT 16
Player_V1::Player_V1(ScummEngine *scumm, bool pcjr) : Player_V2(scumm, pcjr) { Player_V1::Player_V1(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr)
: Player_V2(scumm, mixer, pcjr) {
// Initialize channel code // Initialize channel code
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
clear_channel(i); clear_channel(i);

View file

@ -33,7 +33,7 @@ namespace Scumm {
*/ */
class Player_V1 : public Player_V2 { class Player_V1 : public Player_V2 {
public: public:
Player_V1(ScummEngine *scumm, bool pcjr); Player_V1(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr);
~Player_V1(); ~Player_V1();
virtual void startSound(int sound); virtual void startSound(int sound);

View file

@ -342,12 +342,12 @@ static const uint16 pcjr_freq_table[12] = {
#endif #endif
Player_V2::Player_V2(ScummEngine *scumm, bool pcjr) { Player_V2::Player_V2(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr) {
int i; int i;
_isV3Game = (scumm->_game.version >= 3); _isV3Game = (scumm->_game.version >= 3);
_vm = scumm; _vm = scumm;
_mixer = scumm->_mixer; _mixer = mixer;
_sample_rate = _mixer->getOutputRate(); _sample_rate = _mixer->getOutputRate();
_header_len = (scumm->_game.features & GF_OLD_BUNDLE) ? 4 : 6; _header_len = (scumm->_game.features & GF_OLD_BUNDLE) ? 4 : 6;

View file

@ -74,7 +74,7 @@ struct channel_data {
*/ */
class Player_V2 : public Audio::AudioStream, public MusicEngine { class Player_V2 : public Audio::AudioStream, public MusicEngine {
public: public:
Player_V2(ScummEngine *scumm, bool pcjr); Player_V2(ScummEngine *scumm, Audio::Mixer *mixer, bool pcjr);
virtual ~Player_V2(); virtual ~Player_V2();
virtual void setMusicVolume(int vol); virtual void setMusicVolume(int vol);

View file

@ -1303,7 +1303,7 @@ static V2A_Sound *findSound (unsigned long crc) {
return NULL; return NULL;
} }
Player_V2A::Player_V2A(ScummEngine *scumm) { Player_V2A::Player_V2A(ScummEngine *scumm, Audio::Mixer *mixer) {
int i; int i;
_vm = scumm; _vm = scumm;
@ -1317,7 +1317,7 @@ Player_V2A::Player_V2A(ScummEngine *scumm) {
_slot[i].sound = NULL; _slot[i].sound = NULL;
} }
_mod = new Player_MOD(scumm); _mod = new Player_MOD(mixer);
_mod->setUpdateProc(update_proc, this, 60); _mod->setUpdateProc(update_proc, this, 60);
} }

View file

@ -40,7 +40,7 @@ class V2A_Sound;
*/ */
class Player_V2A : public MusicEngine { class Player_V2A : public MusicEngine {
public: public:
Player_V2A(ScummEngine *scumm); Player_V2A(ScummEngine *scumm, Audio::Mixer *mixer);
virtual ~Player_V2A(); virtual ~Player_V2A();
virtual void setMusicVolume(int vol); virtual void setMusicVolume(int vol);

View file

@ -35,7 +35,7 @@ static const uint16 note_freqs[4][12] = {
{0x00D6, 0x00CA, 0x00BE, 0x00B4, 0x00A9, 0x00A0, 0x0097, 0x008E, 0x0086, 0x007F, 0x00F0, 0x00E2} {0x00D6, 0x00CA, 0x00BE, 0x00B4, 0x00A9, 0x00A0, 0x0097, 0x008E, 0x0086, 0x007F, 0x00F0, 0x00E2}
}; };
Player_V3A::Player_V3A(ScummEngine *scumm) { Player_V3A::Player_V3A(ScummEngine *scumm, Audio::Mixer *mixer) {
int i; int i;
_vm = scumm; _vm = scumm;
for (i = 0; i < V3A_MAXMUS; i++) { for (i = 0; i < V3A_MAXMUS; i++) {
@ -56,7 +56,7 @@ Player_V3A::Player_V3A(ScummEngine *scumm) {
_isinit = false; _isinit = false;
_mod = new Player_MOD(scumm); _mod = new Player_MOD(mixer);
_mod->setUpdateProc(update_proc, this, 60); _mod->setUpdateProc(update_proc, this, 60);
} }

View file

@ -39,7 +39,7 @@ class ScummEngine;
*/ */
class Player_V3A : public MusicEngine { class Player_V3A : public MusicEngine {
public: public:
Player_V3A(ScummEngine *scumm); Player_V3A(ScummEngine *scumm, Audio::Mixer *mixer);
virtual ~Player_V3A(); virtual ~Player_V3A();
virtual void setMusicVolume(int vol); virtual void setMusicVolume(int vol);

View file

@ -1009,9 +1009,9 @@ void ScummEngine::setupScumm() {
// Create the sound manager // Create the sound manager
if (_game.heversion > 0) if (_game.heversion > 0)
_sound = new SoundHE(this); _sound = new SoundHE(this, _mixer);
else else
_sound = new Sound(this); _sound = new Sound(this, _mixer);
// Setup the music engine // Setup the music engine
setupMusic(_game.midi); setupMusic(_game.midi);
@ -1096,16 +1096,14 @@ void ScummEngine::setupScumm() {
void ScummEngine_v7::setupScumm() { void ScummEngine_v7::setupScumm() {
if (_game.features & GF_DIGI_IMUSE) { if (_game.features & GF_DIGI_IMUSE) {
#ifndef DISABLE_SCUMM_7_8 _musicEngine = _imuseDigital = new IMuseDigital(this, _mixer, 10);
_musicEngine = _imuseDigital = new IMuseDigital(this, 10);
#endif
} }
ScummEngine::setupScumm(); ScummEngine::setupScumm();
// Create FT INSANE object // Create FT INSANE object
if (_game.id == GID_FT) if (_game.id == GID_FT)
_insane = new Insane((ScummEngine_v7 *)this); _insane = new Insane(this);
else else
_insane = 0; _insane = 0;
@ -1457,19 +1455,19 @@ void ScummEngine::setupMusic(int midi) {
// TODO // TODO
_musicEngine = NULL; _musicEngine = NULL;
} else if (_game.platform == Common::kPlatformNES) { } else if (_game.platform == Common::kPlatformNES) {
_musicEngine = new Player_NES(this); _musicEngine = new Player_NES(this, _mixer);
} else if ((_game.platform == Common::kPlatformAmiga) && (_game.version == 2)) { } else if ((_game.platform == Common::kPlatformAmiga) && (_game.version == 2)) {
_musicEngine = new Player_V2A(this); _musicEngine = new Player_V2A(this, _mixer);
} else if ((_game.platform == Common::kPlatformAmiga) && (_game.version == 3)) { } else if ((_game.platform == Common::kPlatformAmiga) && (_game.version == 3)) {
_musicEngine = new Player_V3A(this); _musicEngine = new Player_V3A(this, _mixer);
} else if ((_game.platform == Common::kPlatformAmiga) && (_game.version <= 4)) { } else if ((_game.platform == Common::kPlatformAmiga) && (_game.version <= 4)) {
_musicEngine = NULL; _musicEngine = NULL;
} else if (_game.id == GID_MANIAC && (_game.version == 1)) { } else if (_game.id == GID_MANIAC && (_game.version == 1)) {
_musicEngine = new Player_V1(this, midiDriver != MD_PCSPK); _musicEngine = new Player_V1(this, _mixer, midiDriver != MD_PCSPK);
} else if (_game.version <= 2) { } else if (_game.version <= 2) {
_musicEngine = new Player_V2(this, midiDriver != MD_PCSPK); _musicEngine = new Player_V2(this, _mixer, midiDriver != MD_PCSPK);
} else if ((_musicType == MDT_PCSPK) && ((_game.version > 2) && (_game.version <= 4))) { } else if ((_musicType == MDT_PCSPK) && ((_game.version > 2) && (_game.version <= 4))) {
_musicEngine = new Player_V2(this, midiDriver != MD_PCSPK); _musicEngine = new Player_V2(this, _mixer, midiDriver != MD_PCSPK);
} else if (_game.version >= 3 && _game.heversion <= 61 && _game.platform != Common::kPlatform3DO) { } else if (_game.version >= 3 && _game.heversion <= 61 && _game.platform != Common::kPlatform3DO) {
MidiDriver *nativeMidiDriver = 0; MidiDriver *nativeMidiDriver = 0;
MidiDriver *adlibMidiDriver = 0; MidiDriver *adlibMidiDriver = 0;

View file

@ -56,9 +56,10 @@ struct MP3OffsetTable { /* Compressed Sound (.SO3) */
}; };
Sound::Sound(ScummEngine *parent) Sound::Sound(ScummEngine *parent, Audio::Mixer *mixer)
: :
_vm(parent), _vm(parent),
_mixer(mixer),
_soundQuePos(0), _soundQuePos(0),
_soundQue2Pos(0), _soundQue2Pos(0),
_sfxFile(0), _sfxFile(0),
@ -187,7 +188,7 @@ void Sound::playSound(int soundID) {
// Allocate a sound buffer, copy the data into it, and play // Allocate a sound buffer, copy the data into it, and play
sound = (char *)malloc(size); sound = (char *)malloc(size);
memcpy(sound, ptr, size); memcpy(sound, ptr, size);
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID); _mixer->playRaw(NULL, sound, size, rate, flags, soundID);
} }
// WORKAROUND bug # 1311447 // WORKAROUND bug # 1311447
else if (READ_BE_UINT32(ptr) == 0x460e200d) { else if (READ_BE_UINT32(ptr) == 0x460e200d) {
@ -209,7 +210,7 @@ void Sound::playSound(int soundID) {
// Allocate a sound buffer, copy the data into it, and play // Allocate a sound buffer, copy the data into it, and play
sound = (char *)malloc(size); sound = (char *)malloc(size);
memcpy(sound, ptr, size); memcpy(sound, ptr, size);
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID); _mixer->playRaw(NULL, sound, size, rate, flags, soundID);
} }
// Support for sampled sound effects in Monkey Island 1 and 2 // Support for sampled sound effects in Monkey Island 1 and 2
else if (READ_BE_UINT32(ptr) == MKID_BE('SBL ')) { else if (READ_BE_UINT32(ptr) == MKID_BE('SBL ')) {
@ -280,7 +281,7 @@ void Sound::playSound(int soundID) {
// Allocate a sound buffer, copy the data into it, and play // Allocate a sound buffer, copy the data into it, and play
sound = (char *)malloc(size); sound = (char *)malloc(size);
memcpy(sound, ptr + 6, size); memcpy(sound, ptr + 6, size);
_vm->_mixer->playRaw(NULL, sound, size, rate, flags, soundID); _mixer->playRaw(NULL, sound, size, rate, flags, soundID);
} }
else if ((_vm->_game.platform == Common::kPlatformFMTowns && _vm->_game.version == 3) || READ_BE_UINT32(ptr) == MKID_BE('SOUN') || READ_BE_UINT32(ptr) == MKID_BE('TOWS')) { else if ((_vm->_game.platform == Common::kPlatformFMTowns && _vm->_game.version == 3) || READ_BE_UINT32(ptr) == MKID_BE('SOUN') || READ_BE_UINT32(ptr) == MKID_BE('TOWS')) {
@ -333,7 +334,7 @@ void Sound::playSound(int soundID) {
if (loopEnd > 0) if (loopEnd > 0)
flags |= Audio::Mixer::FLAG_LOOP; flags |= Audio::Mixer::FLAG_LOOP;
_vm->_mixer->playRaw(NULL, sound, waveSize, rate, flags, soundID, 255, 0, loopStart, loopEnd); _mixer->playRaw(NULL, sound, waveSize, rate, flags, soundID, 255, 0, loopStart, loopEnd);
} }
break; break;
case 1: case 1:
@ -394,7 +395,7 @@ void Sound::playSound(int soundID) {
sound = (char *)malloc(size); sound = (char *)malloc(size);
int vol = ptr[24] * 4; int vol = ptr[24] * 4;
memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size); memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
_vm->_mixer->playRaw(NULL, sound, size, rate, Audio::Mixer::FLAG_AUTOFREE, soundID, vol, 0); _mixer->playRaw(NULL, sound, size, rate, Audio::Mixer::FLAG_AUTOFREE, soundID, vol, 0);
} }
else { else {
@ -458,7 +459,7 @@ void Sound::processSfxQueues() {
} else if (_vm->_game.heversion >= 60) { } else if (_vm->_game.heversion >= 60) {
finished = !isSoundRunning(1); finished = !isSoundRunning(1);
} else { } else {
finished = !_vm->_mixer->isSoundHandleActive(_talkChannelHandle); finished = !_mixer->isSoundHandleActive(_talkChannelHandle);
} }
if ((uint) act < 0x80 && ((_vm->_game.version == 8) || (_vm->_game.version <= 7 && !_vm->_string[0].no_talk_anim))) { if ((uint) act < 0x80 && ((_vm->_game.version == 8) || (_vm->_game.version <= 7 && !_vm->_string[0].no_talk_anim))) {
@ -556,7 +557,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle
if (mode == 1 && (_vm->_game.id == GID_TENTACLE || _vm->_game.id == GID_SAMNMAX)) { if (mode == 1 && (_vm->_game.id == GID_TENTACLE || _vm->_game.id == GID_SAMNMAX)) {
id = 777777 + _talk_sound_channel; id = 777777 + _talk_sound_channel;
_vm->_mixer->stopID(id); _mixer->stopID(id);
} }
if (b > 8) { if (b > 8) {
@ -598,7 +599,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle
_mouthSyncMode = true; _mouthSyncMode = true;
} }
if (!_soundsPaused && _vm->_mixer->isReady()) { if (!_soundsPaused && _mixer->isReady()) {
Audio::AudioStream *input = NULL; Audio::AudioStream *input = NULL;
switch (_soundMode) { switch (_soundMode) {
@ -636,7 +637,7 @@ void Sound::startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle
_vm->_imuseDigital->startVoice(kTalkSoundID, input); _vm->_imuseDigital->startVoice(kTalkSoundID, input);
#endif #endif
} else { } else {
_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, input, id); _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, input, id);
} }
} }
} }
@ -650,7 +651,7 @@ void Sound::stopTalkSound() {
} else if (_vm->_game.heversion >= 60) { } else if (_vm->_game.heversion >= 60) {
stopSound(1); stopSound(1);
} else { } else {
_vm->_mixer->stopHandle(_talkChannelHandle); _mixer->stopHandle(_talkChannelHandle);
} }
_sfxMode &= ~2; _sfxMode &= ~2;
} }
@ -682,7 +683,7 @@ int Sound::isSoundRunning(int sound) const {
if (sound == _currentCDSound) if (sound == _currentCDSound)
return pollCD(); return pollCD();
if (_vm->_mixer->isSoundIDActive(sound)) if (_mixer->isSoundIDActive(sound))
return 1; return 1;
if (isSoundInQueue(sound)) if (isSoundInQueue(sound))
@ -727,7 +728,7 @@ bool Sound::isSoundInUse(int sound) const {
if (_vm->_imuse) if (_vm->_imuse)
return _vm->_imuse->get_sound_active(sound); return _vm->_imuse->get_sound_active(sound);
if (_vm->_mixer->isSoundIDActive(sound)) if (_mixer->isSoundIDActive(sound))
return 1; return 1;
return false; return false;
@ -765,7 +766,7 @@ void Sound::stopSound(int sound) {
} }
if (!(_vm->_game.features & GF_DIGI_IMUSE)) if (!(_vm->_game.features & GF_DIGI_IMUSE))
_vm->_mixer->stopID(sound); _mixer->stopID(sound);
if (_vm->_musicEngine) if (_vm->_musicEngine)
_vm->_musicEngine->stopSound(sound); _vm->_musicEngine->stopSound(sound);
@ -797,7 +798,7 @@ void Sound::stopAllSounds() {
// Stop all SFX // Stop all SFX
if (!_vm->_imuseDigital) { if (!_vm->_imuseDigital) {
_vm->_mixer->stopAll(); _mixer->stopAll();
} }
} }
@ -874,7 +875,7 @@ void Sound::pauseSounds(bool pause) {
} }
#endif #endif
_vm->_mixer->pauseAll(pause); _mixer->pauseAll(pause);
if ((_vm->_game.features & GF_AUDIOTRACKS) && _vm->VAR(_vm->VAR_MUSIC_TIMER) > 0) { if ((_vm->_game.features & GF_AUDIOTRACKS) && _vm->VAR(_vm->VAR_MUSIC_TIMER) > 0) {
if (pause) if (pause)
@ -983,7 +984,7 @@ BaseScummFile *Sound::openSfxFile() {
} }
bool Sound::isSfxFinished() const { bool Sound::isSfxFinished() const {
return !_vm->_mixer->hasActiveChannelOfType(Audio::Mixer::kSFXSoundType); return !_mixer->hasActiveChannelOfType(Audio::Mixer::kSFXSoundType);
} }
// We use a real timer in an attempt to get better sync with CD tracks. This is // We use a real timer in an attempt to get better sync with CD tracks. This is

View file

@ -27,6 +27,10 @@
#include "sound/mixer.h" #include "sound/mixer.h"
#include "scumm/saveload.h" #include "scumm/saveload.h"
namespace Audio {
class Mixer;
}
namespace Scumm { namespace Scumm {
class ScummEngine; class ScummEngine;
@ -52,6 +56,7 @@ public:
protected: protected:
ScummEngine *_vm; ScummEngine *_vm;
Audio::Mixer *_mixer;
int16 _soundQuePos, _soundQue[0x100]; int16 _soundQuePos, _soundQue[0x100];
int16 _soundQue2Pos; int16 _soundQue2Pos;
@ -85,7 +90,7 @@ public:
byte _sfxMode; byte _sfxMode;
public: public:
Sound(ScummEngine *parent); Sound(ScummEngine *parent, Audio::Mixer *mixer);
virtual ~Sound(); virtual ~Sound();
virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0); virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0); virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);

View file

@ -1003,7 +1003,7 @@ void OptionsDialog::onAction(Widget *widget, int result) {
if (widget == _musicSwitch) { if (widget == _musicSwitch) {
_vm->_sound->muteMusic(result != 0); _vm->_sound->muteMusic(result != 0);
} else if (widget == _musicSlider) { } else if (widget == _musicSlider) {
_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, result); _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, result);
_vm->_sound->muteMusic(result == 0); _vm->_sound->muteMusic(result == 0);
_musicSwitch->setValue(result != 0); _musicSwitch->setValue(result != 0);
} else if (widget == _speechSlider) { } else if (widget == _speechSlider) {

View file

@ -68,6 +68,8 @@ AudioCDManager::AudioCDManager() {
memset(_cachedTracks, 0, sizeof(_cachedTracks)); memset(_cachedTracks, 0, sizeof(_cachedTracks));
memset(_trackInfo, 0, sizeof(_trackInfo)); memset(_trackInfo, 0, sizeof(_trackInfo));
_currentCache = 0; _currentCache = 0;
_mixer = g_system->getMixer();
assert(_mixer);
} }
void AudioCDManager::play(int track, int numLoops, int startFrame, int duration) { void AudioCDManager::play(int track, int numLoops, int startFrame, int duration) {
@ -83,9 +85,9 @@ void AudioCDManager::play(int track, int numLoops, int startFrame, int duration)
_cd.duration = duration; _cd.duration = duration;
if (index >= 0) { if (index >= 0) {
g_engine->_mixer->stopHandle(_cd.handle); _mixer->stopHandle(_cd.handle);
_cd.playing = true; _cd.playing = true;
_trackInfo[index]->play(g_engine->_mixer, &_cd.handle, _cd.start, _cd.duration); _trackInfo[index]->play(_mixer, &_cd.handle, _cd.start, _cd.duration);
} else { } else {
g_system->playCD(track, numLoops, startFrame, duration); g_system->playCD(track, numLoops, startFrame, duration);
_cd.playing = false; _cd.playing = false;
@ -95,7 +97,7 @@ void AudioCDManager::play(int track, int numLoops, int startFrame, int duration)
void AudioCDManager::stop() { void AudioCDManager::stop() {
if (_cd.playing) { if (_cd.playing) {
g_engine->_mixer->stopHandle(_cd.handle); _mixer->stopHandle(_cd.handle);
_cd.playing = false; _cd.playing = false;
} else { } else {
g_system->stopCD(); g_system->stopCD();
@ -109,16 +111,16 @@ bool AudioCDManager::isPlaying() const {
void AudioCDManager::updateCD() { void AudioCDManager::updateCD() {
if (_cd.playing) { if (_cd.playing) {
// If the sound handle is 0, then playback stopped. // If the sound handle is 0, then playback stopped.
if (!g_engine->_mixer->isSoundHandleActive(_cd.handle)) { if (!_mixer->isSoundHandleActive(_cd.handle)) {
// If playback just stopped, check if the current track is supposed // If playback just stopped, check if the current track is supposed
// to be repeated, and if that's the case, play it again. Else, stop // to be repeated, and if that's the case, play it again. Else, stop
// the CD explicitly. // the CD explicitly.
if (_cd.numLoops == -1 || --_cd.numLoops > 0) { if (_cd.numLoops == -1 || --_cd.numLoops > 0) {
int index = getCachedTrack(_cd.track); int index = getCachedTrack(_cd.track);
assert(index >= 0); assert(index >= 0);
_trackInfo[index]->play(g_engine->_mixer, &_cd.handle, _cd.start, _cd.duration); _trackInfo[index]->play(_mixer, &_cd.handle, _cd.start, _cd.duration);
} else { } else {
g_engine->_mixer->stopHandle(_cd.handle); _mixer->stopHandle(_cd.handle);
_cd.playing = false; _cd.playing = false;
} }
} }

View file

@ -31,9 +31,10 @@
namespace Audio { namespace Audio {
class DigitalTrackInfo { class DigitalTrackInfo {
public: public:
virtual void play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration) = 0; virtual void play(Mixer *mixer, SoundHandle *handle, int startFrame, int duration) = 0;
virtual ~DigitalTrackInfo() { } virtual ~DigitalTrackInfo() { }
}; };
@ -65,7 +66,7 @@ private:
private: private:
/* used for emulated CD music */ /* used for emulated CD music */
struct ExtStatus : Status { struct ExtStatus : Status {
Audio::SoundHandle handle; SoundHandle handle;
}; };
ExtStatus _cd; ExtStatus _cd;
@ -81,6 +82,7 @@ private:
DigitalTrackInfo *_trackInfo[CACHE_TRACKS]; DigitalTrackInfo *_trackInfo[CACHE_TRACKS];
int _currentCache; int _currentCache;
Mixer *_mixer;
}; };
/** Shortcut for accessing the audio CD manager. */ /** Shortcut for accessing the audio CD manager. */

View file

@ -26,6 +26,7 @@
#include "engines/engine.h" #include "engines/engine.h"
#include "common/config-manager.h" #include "common/config-manager.h"
#include "common/str.h" #include "common/str.h"
#include "common/system.h"
#include "common/util.h" #include "common/util.h"
#include "sound/mididrv.h" #include "sound/mididrv.h"
@ -211,9 +212,9 @@ MidiDriver *MidiDriver::createMidi(int midiDriver) {
switch (midiDriver) { switch (midiDriver) {
case MD_NULL: return MidiDriver_NULL_create(); case MD_NULL: return MidiDriver_NULL_create();
case MD_ADLIB: return MidiDriver_ADLIB_create(g_engine->_mixer); case MD_ADLIB: return MidiDriver_ADLIB_create(g_system->getMixer());
case MD_TOWNS: return MidiDriver_YM2612_create(g_engine->_mixer); case MD_TOWNS: return MidiDriver_YM2612_create(g_system->getMixer());
// Right now PC Speaker and PCjr are handled // Right now PC Speaker and PCjr are handled
// outside the MidiDriver architecture, so // outside the MidiDriver architecture, so
@ -222,11 +223,11 @@ MidiDriver *MidiDriver::createMidi(int midiDriver) {
case MD_PCJR: return NULL; case MD_PCJR: return NULL;
#ifdef USE_FLUIDSYNTH #ifdef USE_FLUIDSYNTH
case MD_FLUIDSYNTH: return MidiDriver_FluidSynth_create(g_engine->_mixer); case MD_FLUIDSYNTH: return MidiDriver_FluidSynth_create(g_system->getMixer());
#endif #endif
#ifdef USE_MT32EMU #ifdef USE_MT32EMU
case MD_MT32: return MidiDriver_MT32_create(g_engine->_mixer); case MD_MT32: return MidiDriver_MT32_create(g_system->getMixer());
#endif #endif
#if defined(PALMOS_MODE) #if defined(PALMOS_MODE)

View file

@ -39,8 +39,8 @@ class Channel;
class Mixer; class Mixer;
class SoundHandle { class SoundHandle {
friend class Audio::Channel; friend class Channel;
friend class Audio::Mixer; friend class Mixer;
uint32 _val; uint32 _val;
public: public:
inline SoundHandle() : _val(0xFFFFFFFF) {} inline SoundHandle() : _val(0xFFFFFFFF) {}

View file

@ -21,6 +21,7 @@
#include "common/stdafx.h" #include "common/stdafx.h"
#include "sound/mpu401.h" #include "sound/mpu401.h"
#include "common/system.h"
#include "common/timer.h" #include "common/timer.h"
#include "common/util.h" // for ARRAYSIZE #include "common/util.h" // for ARRAYSIZE
@ -100,7 +101,7 @@ MidiDriver_MPU401::MidiDriver_MPU401() :
void MidiDriver_MPU401::close() { void MidiDriver_MPU401::close() {
if (_timer_proc) if (_timer_proc)
Common::g_timer->removeTimerProc(_timer_proc); g_system->getTimerManager()->removeTimerProc(_timer_proc);
_timer_proc = 0; _timer_proc = 0;
for (int i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
send(0x7B << 8 | 0xB0 | i); send(0x7B << 8 | 0xB0 | i);
@ -134,9 +135,9 @@ MidiChannel *MidiDriver_MPU401::allocateChannel() {
void MidiDriver_MPU401::setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) { void MidiDriver_MPU401::setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) {
if (!_timer_proc || !timer_proc) { if (!_timer_proc || !timer_proc) {
if (_timer_proc) if (_timer_proc)
Common::g_timer->removeTimerProc(_timer_proc); g_system->getTimerManager()->removeTimerProc(_timer_proc);
_timer_proc = timer_proc; _timer_proc = timer_proc;
if (timer_proc) if (timer_proc)
Common::g_timer->installTimerProc(timer_proc, 10000, timer_param); g_system->getTimerManager()->installTimerProc(timer_proc, 10000, timer_param);
} }
} }

View file

@ -75,7 +75,7 @@ public:
int getRate() const { return _outputRate; } int getRate() const { return _outputRate; }
}; };
class MT32File: public MT32Emu::File { class MT32File : public MT32Emu::File {
Common::File file; Common::File file;
public: public:
bool open(const char *filename, OpenMode mode) { bool open(const char *filename, OpenMode mode) {