[Scummvm-cvs-logs] scummvm master -> 4b98d6a9e44e2868cf6f4c7d32f9ab291b542eae
athrxx
athrxx at scummvm.org
Sun May 29 01:17:53 CEST 2011
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
187ecdd54f KYRA: remove useless mutex from sound_towns
3d42141e9d SCUMM: implement some missing (very low relevance) imuse code
c60807cbb9 FM-TOWNS AUDIO: Unlock internal mutex before calling imuse timer proc.
d7f877b3ab KYRA: pause midi sounds while gmm is running
4b98d6a9e4 SCUMM: Fix bug #1013617
Commit: 187ecdd54f94026dd47b959050295f10faa65bb0
https://github.com/scummvm/scummvm/commit/187ecdd54f94026dd47b959050295f10faa65bb0
Author: athrxx (athrxx at scummvm.org)
Date: 2011-05-28T16:03:49-07:00
Commit Message:
KYRA: remove useless mutex from sound_towns
Changed paths:
engines/kyra/sound_intern.h
engines/kyra/sound_towns.cpp
diff --git a/engines/kyra/sound_intern.h b/engines/kyra/sound_intern.h
index 488dbc3..e9cffd8 100644
--- a/engines/kyra/sound_intern.h
+++ b/engines/kyra/sound_intern.h
@@ -139,8 +139,6 @@ private:
TownsEuphonyDriver *_driver;
- Common::Mutex _mutex;
-
bool _cdaPlaying;
const uint8 *_musicFadeTable;
diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp
index 9a9892c..73d435f 100644
--- a/engines/kyra/sound_towns.cpp
+++ b/engines/kyra/sound_towns.cpp
@@ -297,8 +297,6 @@ bool SoundTowns::loadInstruments() {
if (!twm)
return false;
- Common::StackLock lock(_mutex);
-
Screen::decodeFrame4(twm, _musicTrackData, 50570);
for (int i = 0; i < 128; i++)
_driver->loadInstrument(0, i, &_musicTrackData[i * 48 + 8]);
@@ -322,8 +320,6 @@ bool SoundTowns::loadInstruments() {
}
void SoundTowns::playEuphonyTrack(uint32 offset, int loop) {
- Common::StackLock lock(_mutex);
-
uint8 *twm = _vm->resource()->fileData("twmusic.pak", 0);
Screen::decodeFrame4(twm + 19312 + offset, _musicTrackData, 50570);
delete[] twm;
Commit: 3d42141e9dda203a5dae7bb91384405be5abc243
https://github.com/scummvm/scummvm/commit/3d42141e9dda203a5dae7bb91384405be5abc243
Author: athrxx (athrxx at scummvm.org)
Date: 2011-05-28T16:03:55-07:00
Commit Message:
SCUMM: implement some missing (very low relevance) imuse code
1) Don't skip transpose setting in sysex command 0. There are only a few sounds where this setting is used (mainly sfx).
2) Make MI2 and INDY4 read certain player start parameters from the sound resource. The start parameters usually match our default parameters (exception: e.g. LeChuck's Fortress). The use of these parameters has been dropped in DOTT (they use default parameters like we do).
Changed paths:
engines/scumm/imuse/imuse.cpp
engines/scumm/imuse/imuse_internal.h
engines/scumm/imuse/imuse_part.cpp
engines/scumm/imuse/imuse_player.cpp
engines/scumm/imuse/sysex_scumm.cpp
diff --git a/engines/scumm/imuse/imuse.cpp b/engines/scumm/imuse/imuse.cpp
index fe23b88..7d971f5 100644
--- a/engines/scumm/imuse/imuse.cpp
+++ b/engines/scumm/imuse/imuse.cpp
@@ -99,8 +99,9 @@ IMuseInternal::~IMuseInternal() {
}
}
-byte *IMuseInternal::findStartOfSound(int sound) {
+byte *IMuseInternal::findStartOfSound(int sound, int ct) {
int32 size, pos;
+ static uint32 id[] = { 'MThd', 'FORM', 'MDhd', 'MDpg' };
byte *ptr = g_scumm->_res->_types[rtSound][sound]._address;
@@ -110,10 +111,11 @@ byte *IMuseInternal::findStartOfSound(int sound) {
}
// Check for old-style headers first, like 'RO'
+ int trFlag = (kMThd | kFORM);
if (ptr[0] == 'R' && ptr[1] == 'O'&& ptr[2] != 'L')
- return ptr;
+ return ct == trFlag ? ptr : 0;
if (ptr[4] == 'S' && ptr[5] == 'O')
- return ptr + 4;
+ return ct == trFlag ? ptr + 4 : 0;
ptr += 4;
size = READ_BE_UINT32(ptr);
@@ -124,12 +126,16 @@ byte *IMuseInternal::findStartOfSound(int sound) {
size = 48; // Arbitrary; we should find our tag within the first 48 bytes of the resource
pos = 0;
while (pos < size) {
- if (!memcmp(ptr + pos, "MThd", 4) || !memcmp(ptr + pos, "FORM", 4))
- return ptr + pos;
+ for (int i = 0; i < ARRAYSIZE(id); ++i) {
+ if ((ct & (1 << i)) && (READ_BE_UINT32(ptr + pos) == id[i]))
+ return ptr + pos;
+ }
++pos; // We could probably iterate more intelligently
}
- debug(3, "IMuseInternal::findStartOfSound(): Failed to align on sound %d", sound);
+ if (ct == (kMThd | kFORM))
+ debug(3, "IMuseInternal::findStartOfSound(): Failed to align on sound %d", sound);
+
return 0;
}
@@ -556,7 +562,7 @@ bool IMuseInternal::startSound_internal(int sound, int offset) {
return false;
}
- void *ptr = findStartOfSound(sound);
+ byte *ptr = findStartOfSound(sound);
if (!ptr) {
debug(2, "IMuseInternal::startSound(): Couldn't find sound %d", sound);
return false;
@@ -576,8 +582,11 @@ bool IMuseInternal::startSound_internal(int sound, int offset) {
// Bug #590511 and Patch #607175 (which was reversed to fix
// an FOA regression: Bug #622606).
Player *player = findActivePlayer(sound);
- if (!player)
- player = allocate_player(128);
+ if (!player) {
+ ptr = findStartOfSound(sound, IMuseInternal::kMDhd);
+ player = allocate_player(ptr ? (READ_BE_UINT32(&ptr[4]) && ptr[10] ? ptr[10] : 128) : 128);
+ }
+
if (!player)
return false;
diff --git a/engines/scumm/imuse/imuse_internal.h b/engines/scumm/imuse/imuse_internal.h
index ec60b22..8808a36 100644
--- a/engines/scumm/imuse/imuse_internal.h
+++ b/engines/scumm/imuse/imuse_internal.h
@@ -229,6 +229,7 @@ protected:
// Sequencer part
int start_seq_sound(int sound, bool reset_vars = true);
+ void loadStartParameters(int sound);
int query_param(int param);
public:
@@ -445,7 +446,14 @@ protected:
static void midiTimerCallback(void *data);
void on_timer(MidiDriver *midi);
- byte *findStartOfSound(int sound);
+ enum ChunkType {
+ kMThd = 1,
+ kFORM = 2,
+ kMDhd = 4, // Used in MI2 and INDY4. Contain certain start parameters (priority, volume, etc. ) for the player.
+ kMDpg = 8 // These chunks exist in DOTT and SAMNMAX. They don't get processed, however.
+ };
+
+ byte *findStartOfSound(int sound, int ct = (kMThd | kFORM));
bool isMT32(int sound);
bool isMIDI(int sound);
int get_queue_sound_status(int sound) const;
diff --git a/engines/scumm/imuse/imuse_part.cpp b/engines/scumm/imuse/imuse_part.cpp
index 808af23..5df8407 100644
--- a/engines/scumm/imuse/imuse_part.cpp
+++ b/engines/scumm/imuse/imuse_part.cpp
@@ -137,7 +137,8 @@ void Part::set_pan(int8 pan) {
}
void Part::set_transpose(int8 transpose) {
- _transpose_eff = transpose_clamp((_transpose = transpose) + _player->getTranspose(), -24, 24);
+ _transpose = transpose;
+ _transpose_eff = (_transpose == -128) ? 0 : transpose_clamp(_transpose + _player->getTranspose(), -24, 24);
sendPitchBend();
}
diff --git a/engines/scumm/imuse/imuse_player.cpp b/engines/scumm/imuse/imuse_player.cpp
index e7ee935..0b084f3 100644
--- a/engines/scumm/imuse/imuse_player.cpp
+++ b/engines/scumm/imuse/imuse_player.cpp
@@ -90,7 +90,7 @@ Player::~Player() {
}
bool Player::startSound(int sound, MidiDriver *midi) {
- void *ptr;
+ byte *ptr;
int i;
// Not sure what the old code was doing,
@@ -108,13 +108,8 @@ bool Player::startSound(int sound, MidiDriver *midi) {
_active = true;
_midi = midi;
_id = sound;
- _priority = 0x80;
- _volume = 0x7F;
- _vol_chan = 0xFFFF;
- _vol_eff = (_se->get_channel_volume(0xFFFF) << 7) >> 7;
- _pan = 0;
- _transpose = 0;
- _detune = 0;
+
+ loadStartParameters(sound);
for (i = 0; i < ARRAYSIZE(_parameterFaders); ++i)
_parameterFaders[i].init();
@@ -125,7 +120,7 @@ bool Player::startSound(int sound, MidiDriver *midi) {
_midi = NULL;
return false;
}
-
+
debugC(DEBUG_IMUSE, "Starting music %d", sound);
return true;
}
@@ -199,11 +194,43 @@ int Player::start_seq_sound(int sound, bool reset_vars) {
_parser->property(MidiParser::mpSmartJump, 1);
_parser->loadMusic(ptr, 0);
_parser->setTrack(_track_index);
- setSpeed(reset_vars ? 128 : _speed);
+
+ ptr = _se->findStartOfSound(sound, IMuseInternal::kMDhd);
+ setSpeed(reset_vars ? (ptr ? (READ_BE_UINT32(&ptr[4]) && ptr[15] ? ptr[15] : 128) : 128) : _speed);
return 0;
}
+void Player::loadStartParameters(int sound) {
+ _priority = 0x80;
+ _volume = 0x7F;
+ _vol_chan = 0xFFFF;
+ _vol_eff = (_se->get_channel_volume(0xFFFF) << 7) >> 7;
+ _pan = 0;
+ _transpose = 0;
+ _detune = 0;
+
+ byte *ptr = _se->findStartOfSound(sound, IMuseInternal::kMDhd);
+ uint32 size = 0;
+
+ if (ptr) {
+ ptr += 4;
+ size = READ_BE_UINT32(ptr);
+ ptr += 4;
+
+ // MDhd chunks don't get used in MI1 and contain only zeroes.
+ // We check for volume, priority and speed settings of zero here.
+ if (size && (ptr[2] | ptr[3] | ptr[7])) {
+ _priority = ptr[2];
+ _volume = ptr[3];
+ _pan = ptr[4];
+ _transpose = ptr[5];
+ _detune = ptr[6];
+ setSpeed(ptr[7]);
+ }
+ }
+}
+
void Player::uninit_parts() {
assert(!_parts || _parts->_player == this);
diff --git a/engines/scumm/imuse/sysex_scumm.cpp b/engines/scumm/imuse/sysex_scumm.cpp
index 6ab71c2..4eb3bee 100644
--- a/engines/scumm/imuse/sysex_scumm.cpp
+++ b/engines/scumm/imuse/sysex_scumm.cpp
@@ -64,6 +64,11 @@ void sysexHandler_Scumm(Player *player, const byte *msg, uint16 len) {
// BYTE 14: Pitchbend range(lower 4 bits) [bug #1088045]
// BYTE 15: Program(upper 4 bits)
// BYTE 16: Program(lower 4 bits)
+
+ // athrxx (05-21-2011):
+ // BYTE 9, 10: Transpose (if set to 0x80, this means that part->_transpose_eff will be 0 (also ignoring player->_transpose)
+ // BYTE 11, 12: Detune
+
part = player->getPart(p[0] & 0x0F);
if (part) {
part->set_onoff(p[2] & 0x01);
@@ -71,7 +76,8 @@ void sysexHandler_Scumm(Player *player, const byte *msg, uint16 len) {
part->set_pri(p[4]);
part->volume((p[5] & 0x0F) << 4 |(p[6] & 0x0F));
part->set_pan((p[7] & 0x0F) << 4 | (p[8] & 0x0F));
- part->_percussion = player->_isMIDI ? ((p[9] & 0x08) > 0) : false;
+ part->_percussion = player->_isMIDI ? ((p[9] & 0x08) > 0) : false;
+ part->set_transpose((p[9] & 0x0F) << 4 | (p[10] & 0x0F));
part->set_detune((p[11] & 0x0F) << 4 | (p[12] & 0x0F));
part->pitchBendFactor((p[13] & 0x0F) << 4 | (p[14] & 0x0F));
if (part->_percussion) {
Commit: c60807cbb9dec063c0b00f8d6ffdb19e83db48f3
https://github.com/scummvm/scummvm/commit/c60807cbb9dec063c0b00f8d6ffdb19e83db48f3
Author: athrxx (athrxx at scummvm.org)
Date: 2011-05-28T16:04:01-07:00
Commit Message:
FM-TOWNS AUDIO: Unlock internal mutex before calling imuse timer proc.
Changed paths:
audio/softsynth/fmtowns_pc98/towns_audio.cpp
audio/softsynth/fmtowns_pc98/towns_audio.h
audio/softsynth/fmtowns_pc98/towns_midi.cpp
audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
engines/scumm/player_towns.cpp
diff --git a/audio/softsynth/fmtowns_pc98/towns_audio.cpp b/audio/softsynth/fmtowns_pc98/towns_audio.cpp
index 5161871..42a8252 100644
--- a/audio/softsynth/fmtowns_pc98/towns_audio.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_audio.cpp
@@ -103,12 +103,12 @@ private:
class TownsAudioInterfaceInternal : public TownsPC98_FmSynth {
public:
- TownsAudioInterfaceInternal(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver);
+ TownsAudioInterfaceInternal(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver, bool externalMutexHandling = false);
~TownsAudioInterfaceInternal();
- static TownsAudioInterfaceInternal *addNewRef(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver);
+ static TownsAudioInterfaceInternal *addNewRef(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver, bool externalMutexHandling = false);
static void releaseRef();
- bool checkPluginDriver(TownsAudioInterfacePluginDriver *driver);
+ bool checkPluginDriver(TownsAudioInterfacePluginDriver *driver, bool externalMutexHandling = false);
bool init();
@@ -252,7 +252,8 @@ private:
static const uint16 _pcmPhase2[];
};
-TownsAudioInterfaceInternal::TownsAudioInterfaceInternal(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver) : TownsPC98_FmSynth(mixer, kTypeTowns),
+TownsAudioInterfaceInternal::TownsAudioInterfaceInternal(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver, bool externalMutexHandling) :
+ TownsPC98_FmSynth(mixer, kTypeTowns, externalMutexHandling),
_fmInstruments(0), _pcmInstruments(0), _pcmChan(0), _waveTables(0), _waveTablesTotalDataSize(0),
_baserate(55125.0f / (float)mixer->getOutputRate()), _tickLength(0), _timer(0), _drv(driver),
_pcmSfxChanMask(0), _musicVolume(Audio::Mixer::kMaxMixerVolume), _sfxVolume(Audio::Mixer::kMaxMixerVolume),
@@ -395,13 +396,13 @@ TownsAudioInterfaceInternal::~TownsAudioInterfaceInternal() {
delete[] _pcmChan;
}
-TownsAudioInterfaceInternal *TownsAudioInterfaceInternal::addNewRef(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver) {
+TownsAudioInterfaceInternal *TownsAudioInterfaceInternal::addNewRef(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver, bool externalMutexHandling) {
_refCount++;
if (_refCount == 1 && _refInstance == 0)
- _refInstance = new TownsAudioInterfaceInternal(mixer, driver);
+ _refInstance = new TownsAudioInterfaceInternal(mixer, driver, externalMutexHandling);
else if (_refCount < 2 || _refInstance == 0)
error("TownsAudioInterfaceInternal::addNewRef(): Internal reference management failure");
- else if (!_refInstance->checkPluginDriver(driver))
+ else if (!_refInstance->checkPluginDriver(driver, externalMutexHandling))
error("TownsAudioInterfaceInternal::addNewRef(): Plugin driver conflict");
return _refInstance;
@@ -419,7 +420,7 @@ void TownsAudioInterfaceInternal::releaseRef() {
}
}
-bool TownsAudioInterfaceInternal::checkPluginDriver(TownsAudioInterfacePluginDriver *driver) {
+bool TownsAudioInterfaceInternal::checkPluginDriver(TownsAudioInterfacePluginDriver *driver, bool externalMutexHandling) {
if (_refCount <= 1)
return true;
@@ -428,6 +429,7 @@ bool TownsAudioInterfaceInternal::checkPluginDriver(TownsAudioInterfacePluginDri
return false;
} else {
_drv = driver;
+ _externalMutex = externalMutexHandling;
}
return true;
@@ -1669,7 +1671,6 @@ void TownsAudioInterfaceInternal::updateOutputVolumeInternal() {
int volume = (int)(((float)(maxVol * 255) / 63.0f));
int balance = maxVol ? (int)( ( ((int)_outputLevel[13] * (_outputMute[13] ^ 1) - _outputLevel[12] * (_outputMute[12] ^ 1)) * 127) / (float)maxVol) : 0;
- Common::StackLock lock(_mutex);
g_system->getAudioCDManager()->setVolume(volume);
g_system->getAudioCDManager()->setBalance(balance);
@@ -1854,8 +1855,8 @@ void TownsAudio_WaveTable::clear() {
data = 0;
}
-TownsAudioInterface::TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver) {
- _intf = TownsAudioInterfaceInternal::addNewRef(mixer, driver);
+TownsAudioInterface::TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver, bool externalMutexHandling) {
+ _intf = TownsAudioInterfaceInternal::addNewRef(mixer, driver, externalMutexHandling);
}
TownsAudioInterface::~TownsAudioInterface() {
@@ -1887,12 +1888,4 @@ void TownsAudioInterface::setSoundEffectVolume(int volume) {
void TownsAudioInterface::setSoundEffectChanMask(int mask) {
_intf->setSoundEffectChanMask(mask);
-}
-
-void TownsAudioInterface::lockInternal() {
- _intf->mutexLock();
-}
-
-void TownsAudioInterface::unlockInternal() {
- _intf->mutexUnlock();
-}
+}
\ No newline at end of file
diff --git a/audio/softsynth/fmtowns_pc98/towns_audio.h b/audio/softsynth/fmtowns_pc98/towns_audio.h
index b00243f..4af888f 100644
--- a/audio/softsynth/fmtowns_pc98/towns_audio.h
+++ b/audio/softsynth/fmtowns_pc98/towns_audio.h
@@ -35,7 +35,7 @@ public:
class TownsAudioInterface {
public:
- TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver);
+ TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver, bool externalMutexHandling = false);
~TownsAudioInterface();
bool init();
@@ -48,13 +48,6 @@ public:
// The first 6 bits are the 6 fm channels. The next 8 bits are pcm channels.
void setSoundEffectChanMask(int mask);
- // These methods should not be needed in standard situations, since the mutex
- // is handled internally. However, they may be required to avoid lockup situations
- // if the code using this class has a mutex of its own (example for a lockup
- // situation: imuse.cpp, line 78).
- void lockInternal();
- void unlockInternal();
-
private:
TownsAudioInterfaceInternal *_intf;
};
diff --git a/audio/softsynth/fmtowns_pc98/towns_midi.cpp b/audio/softsynth/fmtowns_pc98/towns_midi.cpp
index 00f0d43..4617b05 100644
--- a/audio/softsynth/fmtowns_pc98/towns_midi.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_midi.cpp
@@ -834,7 +834,9 @@ const uint8 TownsMidiInputChannel::_programAdjustLevel[] = {
MidiDriver_TOWNS::MidiDriver_TOWNS(Audio::Mixer *mixer) : _timerProc(0), _timerProcPara(0), _channels(0), _out(0),
_chanState(0), _operatorLevelTable(0), _tickCounter1(0), _tickCounter2(0), _rand(1), _allocCurPos(0), _isOpen(false) {
- _intf = new TownsAudioInterface(mixer, this);
+ // We set exteral mutex handling to true, since this driver is only suitable for use with the SCUMM engine
+ // which has its own mutex. This causes lockups which cannot always be avoided.
+ _intf = new TownsAudioInterface(mixer, this, true);
_channels = new TownsMidiInputChannel*[32];
for (int i = 0; i < 32; i++)
diff --git a/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp b/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
index 4336de9..f4dd3cf 100644
--- a/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
+++ b/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
@@ -851,7 +851,7 @@ void TownsPC98_FmSynthPercussionSource::advanceInput(RhtChannel *ins) {
}
#endif // DISABLE_PC98_RHYTHM_CHANNEL
-TownsPC98_FmSynth::TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type) :
+TownsPC98_FmSynth::TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type, bool externalMutexHandling) :
_mixer(mixer),
_chanInternal(0), _ssg(0),
#ifndef DISABLE_PC98_RHYTHM_CHANNEL
@@ -861,7 +861,8 @@ TownsPC98_FmSynth::TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type) :
_hasPercussion(type == kType86 ? true : false),
_oprRates(0), _oprRateshift(0), _oprAttackDecay(0), _oprFrq(0), _oprSinTbl(0), _oprLevelOut(0), _oprDetune(0),
_rtt(type == kTypeTowns ? 0x514767 : 0x5B8D80), _baserate(55125.0f / (float)mixer->getOutputRate()),
- _volMaskA(0), _volMaskB(0), _volumeA(255), _volumeB(255), _regProtectionFlag(false), _ready(false) {
+ _volMaskA(0), _volMaskB(0), _volumeA(255), _volumeB(255),
+ _regProtectionFlag(false), _externalMutex(externalMutexHandling), _ready(false) {
memset(&_timers[0], 0, sizeof(ChipTimer));
memset(&_timers[1], 0, sizeof(ChipTimer));
@@ -1147,7 +1148,7 @@ int TownsPC98_FmSynth::readBuffer(int16 *buffer, const int numSamples) {
bool locked = false;
if (_ready) {
- mutexLock();
+ _mutex.lock();
locked = true;
}
@@ -1157,7 +1158,19 @@ int TownsPC98_FmSynth::readBuffer(int16 *buffer, const int numSamples) {
for (int i = 0; i < 2; i++) {
if (_timers[i].enabled && _timers[i].cb) {
if (!_timers[i].smpTillCb) {
+
+ if (locked && _externalMutex) {
+ _mutex.unlock();
+ locked = false;
+ }
+
(this->*_timers[i].cb)();
+
+ if (_ready && !locked && _externalMutex) {
+ _mutex.lock();
+ locked = true;
+ }
+
_timers[i].smpTillCb = _timers[i].smpPerCb;
_timers[i].smpTillCbRem += _timers[i].smpPerCbRem;
@@ -1201,7 +1214,7 @@ int TownsPC98_FmSynth::readBuffer(int16 *buffer, const int numSamples) {
}
if (locked)
- mutexUnlock();
+ _mutex.unlock();
delete[] tmpStart;
@@ -1220,14 +1233,6 @@ int TownsPC98_FmSynth::getRate() const {
return _mixer->getOutputRate();
}
-void TownsPC98_FmSynth::mutexLock() {
- _mutex.lock();
-}
-
-void TownsPC98_FmSynth::mutexUnlock() {
- _mutex.unlock();
-}
-
void TownsPC98_FmSynth::deinit() {
_ready = false;
_mixer->stopHandle(_soundHandle);
diff --git a/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h b/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
index 6ea9815..50a05f9 100644
--- a/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
+++ b/audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
@@ -59,7 +59,7 @@ public:
kType86
};
- TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type);
+ TownsPC98_FmSynth(Audio::Mixer *mixer, EmuType type, bool externalMutexHandling = false);
virtual ~TownsPC98_FmSynth();
virtual bool init();
@@ -73,9 +73,6 @@ public:
bool endOfData() const;
int getRate() const;
- void mutexLock();
- void mutexUnlock();
-
protected:
void deinit();
@@ -104,6 +101,7 @@ protected:
const bool _hasPercussion;
Common::Mutex _mutex;
+ bool _externalMutex;
private:
void generateTables();
diff --git a/engines/scumm/player_towns.cpp b/engines/scumm/player_towns.cpp
index 15b2f65..e71a8d0 100644
--- a/engines/scumm/player_towns.cpp
+++ b/engines/scumm/player_towns.cpp
@@ -581,15 +581,12 @@ Player_Towns_v2::Player_Towns_v2(ScummEngine *vm, Audio::Mixer *mixer, IMuse *im
}
Player_Towns_v2::~Player_Towns_v2() {
- // Avoid lockup in imuse.cpp, line 78
- _intf->lockInternal();
- if (_imuseDispose)
- delete _imuse;
- _intf->unlockInternal();
-
delete _intf;
_intf = 0;
+ if (_imuseDispose)
+ delete _imuse;
+
delete[] _sblData;
delete[] _soundOverride;
}
Commit: d7f877b3ab080b8e01bd6d55d2b52114dfe0f5fa
https://github.com/scummvm/scummvm/commit/d7f877b3ab080b8e01bd6d55d2b52114dfe0f5fa
Author: athrxx (athrxx at scummvm.org)
Date: 2011-05-28T16:04:08-07:00
Commit Message:
KYRA: pause midi sounds while gmm is running
Changed paths:
engines/kyra/kyra_v1.cpp
engines/kyra/sound.cpp
engines/kyra/sound.h
engines/kyra/sound_intern.h
engines/kyra/sound_midi.cpp
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index 7f4f1ec..75df1d1 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -84,7 +84,7 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)
}
void KyraEngine_v1::pauseEngineIntern(bool pause) {
- Engine::pauseEngineIntern(pause);
+ _sound->pause(pause);
_timer->pause(pause);
}
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp
index 4da35cc..3713537 100644
--- a/engines/kyra/sound.cpp
+++ b/engines/kyra/sound.cpp
@@ -43,6 +43,10 @@ Sound::Sound(KyraEngine_v1 *vm, Audio::Mixer *mixer)
Sound::~Sound() {
}
+void Sound::pause(bool paused) {
+ _mixer->pauseAll(paused);
+}
+
bool Sound::voiceFileIsPresent(const char *file) {
for (int i = 0; _supportedCodecs[i].fileext; ++i) {
Common::String f = file;
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index 4f8e542..566b37f 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -101,7 +101,7 @@ public:
/**
* Load a sound file for playing music
- * (and somtimes sound effects) from.
+ * (and sometimes sound effects) from.
*/
virtual void loadSoundFile(Common::String file) = 0;
@@ -153,6 +153,11 @@ public:
*/
virtual void beginFadeOut() = 0;
+ /**
+ * Stops all audio playback when paused. Continues after end of pause.
+ */
+ virtual void pause(bool paused);
+
void enableMusic(int enable) { _musicEnabled = enable; }
int musicEnabled() const { return _musicEnabled; }
void enableSFX(bool enable) { _sfxEnabled = enable; }
@@ -275,6 +280,7 @@ public:
void stopAllSoundEffects() { _sfx->stopAllSoundEffects(); }
void beginFadeOut() { _music->beginFadeOut(); }
+ void pause(bool paused) { _music->pause(paused); _sfx->pause(paused); }
private:
Sound *_music, *_sfx;
};
diff --git a/engines/kyra/sound_intern.h b/engines/kyra/sound_intern.h
index e9cffd8..2ba0890 100644
--- a/engines/kyra/sound_intern.h
+++ b/engines/kyra/sound_intern.h
@@ -71,6 +71,8 @@ public:
void stopAllSoundEffects();
void beginFadeOut();
+
+ void pause(bool paused);
private:
static void onTimer(void *data);
diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp
index 00f6c93..6c003d0 100644
--- a/engines/kyra/sound_midi.cpp
+++ b/engines/kyra/sound_midi.cpp
@@ -714,6 +714,26 @@ void SoundMidiPC::beginFadeOut() {
_fadeStartTime = _vm->_system->getMillis();
}
+void SoundMidiPC::pause(bool paused) {
+ // Stop all mixer related sounds
+ Sound::pause(paused);
+
+ Common::StackLock lock(_mutex);
+
+ if (paused) {
+ _music->setMidiDriver(0);
+ for (int i = 0; i < 3; i++)
+ _sfx[i]->setMidiDriver(0);
+ for (int i = 0; i < 16; i++)
+ _output->stopNotesOnChannel(i);
+ } else {
+ _music->setMidiDriver(_output);
+ for (int i = 0; i < 3; ++i)
+ _sfx[i]->setMidiDriver(_output);
+ // Possible TODO (IMHO unnecessary): restore notes and/or update _fadeStartTime
+ }
+}
+
void SoundMidiPC::onTimer(void *data) {
SoundMidiPC *midi = (SoundMidiPC *)data;
Commit: 4b98d6a9e44e2868cf6f4c7d32f9ab291b542eae
https://github.com/scummvm/scummvm/commit/4b98d6a9e44e2868cf6f4c7d32f9ab291b542eae
Author: athrxx (athrxx at scummvm.org)
Date: 2011-05-28T16:04:14-07:00
Commit Message:
SCUMM: Fix bug #1013617
(ZAK FM-TOWNS: Wrong verb ('Teleport To') shown)
Changed paths:
engines/scumm/string.cpp
diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index c27b6d5..4b3207c 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -1210,7 +1210,8 @@ int ScummEngine::convertVerbMessage(byte *dst, int dstSize, int var) {
num = readVar(var);
if (num) {
for (k = 1; k < _numVerbs; k++) {
- if (num == _verbs[k].verbid && !_verbs[k].type && !_verbs[k].saveid) {
+ // Fix ZAK FM-TOWNS bug #1013617 by emulating exact (inconsistant?) behavior of the original code
+ if (num == _verbs[k].verbid && !_verbs[k].type && (!_verbs[k].saveid || (_game.version == 3 && _game.platform == Common::kPlatformFMTowns))) {
const byte *ptr = getResourceAddress(rtVerb, k);
return convertMessageToString(ptr, dst, dstSize);
}
More information about the Scummvm-git-logs
mailing list