[Scummvm-cvs-logs] SF.net SVN: scummvm:[52232] scummvm/trunk
athrxx at users.sourceforge.net
athrxx at users.sourceforge.net
Fri Aug 20 19:04:33 CEST 2010
Revision: 52232
http://scummvm.svn.sourceforge.net/scummvm/?rev=52232&view=rev
Author: athrxx
Date: 2010-08-20 17:04:32 +0000 (Fri, 20 Aug 2010)
Log Message:
-----------
KYRA/TOWNS: fix memory leak and some cleanup
Modified Paths:
--------------
scummvm/trunk/engines/kyra/sound_towns.cpp
scummvm/trunk/engines/scumm/script_v5.cpp
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.cpp
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
Modified: scummvm/trunk/engines/kyra/sound_towns.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_towns.cpp 2010-08-20 16:40:13 UTC (rev 52231)
+++ scummvm/trunk/engines/kyra/sound_towns.cpp 2010-08-20 17:04:32 UTC (rev 52232)
@@ -48,6 +48,7 @@
SoundTowns::~SoundTowns() {
AudioCD.stop();
haltTrack();
+ delete _driver;
delete[] _musicTrackData;
delete[] _sfxFileData;
}
Modified: scummvm/trunk/engines/scumm/script_v5.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v5.cpp 2010-08-20 16:40:13 UTC (rev 52231)
+++ scummvm/trunk/engines/scumm/script_v5.cpp 2010-08-20 17:04:32 UTC (rev 52232)
@@ -1978,7 +1978,6 @@
result = _sound->getCurrentCDSound();
break;
case 0xFF:
- // TODO: Might return current CD volume in FM-TOWNS Loom. See also bug #805691.
result = _townsPlayer->getCurrentCdaVolume();
break;
default:
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.cpp 2010-08-20 16:40:13 UTC (rev 52231)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.cpp 2010-08-20 17:04:32 UTC (rev 52232)
@@ -222,19 +222,14 @@
_timerBase = (uint32)(_baserate * 1000000.0f);
_tickLength = 2 * _timerBase;
-
- setTimerCallbackA((ChipTimerProc)&TownsAudioInterface::timerCallbackA);
- setTimerCallbackB((ChipTimerProc)&TownsAudioInterface::timerCallbackB);
}
TownsAudioInterface::~TownsAudioInterface() {
Common::StackLock lock(_mutex);
reset();
+ deinit();
_ready = false;
- setTimerCallbackA();
- setTimerCallbackB();
-
delete[] _fmSaveReg[0];
delete[] _fmSaveReg[1];
delete[] _fmInstruments;
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp 2010-08-20 16:40:13 UTC (rev 52231)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_driver.cpp 2010-08-20 17:04:32 UTC (rev 52232)
@@ -1037,21 +1037,14 @@
_musicPlaying(false), _sfxPlaying(false), _fading(false), _looping(0), _ready(false) {
_sfxOffsets[0] = _sfxOffsets[1] = 0;
-
- setTimerCallbackA((ChipTimerProc)&TownsPC98_AudioDriver::timerCallbackA);
- setTimerCallbackB((ChipTimerProc)&TownsPC98_AudioDriver::timerCallbackB);
}
TownsPC98_AudioDriver::~TownsPC98_AudioDriver() {
Common::StackLock lock(_mutex);
-
reset();
-
+ deinit();
_ready = false;
- setTimerCallbackA();
- setTimerCallbackB();
-
if (_channels) {
for (int i = 0; i < _numChan; i++)
delete _channels[i];
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp 2010-08-20 16:40:13 UTC (rev 52231)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp 2010-08-20 17:04:32 UTC (rev 52232)
@@ -842,11 +842,9 @@
}
TownsPC98_FmSynth::~TownsPC98_FmSynth() {
- Common::StackLock lock(_mutex);
-
- _ready = false;
+ if (_ready)
+ deinit();
- _mixer->stopHandle(_soundHandle);
delete _ssg;
delete _prc;
delete[] _chanInternal;
@@ -885,6 +883,9 @@
_prc->init(_percussionData);
}
+ _timers[0].cb = &TownsPC98_FmSynth::timerCallbackA;
+ _timers[1].cb = &TownsPC98_FmSynth::timerCallbackB;
+
_mixer->playStream(Audio::Mixer::kPlainSoundType,
&_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
@@ -1158,14 +1159,13 @@
return numSamples;
}
-void TownsPC98_FmSynth::setTimerCallbackA(ChipTimerProc proc) {
- _timers[0].cb = proc;
+void TownsPC98_FmSynth::deinit() {
+ _mixer->stopHandle(_soundHandle);
+ _timers[0].cb = &TownsPC98_FmSynth::idleTimerCallback;
+ _timers[1].cb = &TownsPC98_FmSynth::idleTimerCallback;
+ _ready = false;
}
-void TownsPC98_FmSynth::setTimerCallbackB(ChipTimerProc proc) {
- _timers[1].cb = proc;
-}
-
uint8 TownsPC98_FmSynth::readSSGStatus() {
return _ssg->chanEnable();
}
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h 2010-08-20 16:40:13 UTC (rev 52231)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h 2010-08-20 17:04:32 UTC (rev 52232)
@@ -71,9 +71,7 @@
}
protected:
- typedef void (TownsPC98_FmSynth::*ChipTimerProc)();
- void setTimerCallbackA(ChipTimerProc proc = &TownsPC98_FmSynth::timerCallbackA);
- void setTimerCallbackB(ChipTimerProc proc = &TownsPC98_FmSynth::timerCallbackB);
+ void deinit();
// Implement this in your inherited class if your driver generates
// additional output that has to be inserted into the buffer.
@@ -84,8 +82,8 @@
}
uint8 readSSGStatus();
- virtual void timerCallbackA() {}
- virtual void timerCallbackB() {}
+ virtual void timerCallbackA() = 0;
+ virtual void timerCallbackB() = 0;
// The audio driver can store and apply two different audio settings
// (usually for music and sound effects). The channel mask will determine
@@ -143,6 +141,9 @@
bool _regProtectionFlag;
+ typedef void (TownsPC98_FmSynth::*ChipTimerProc)();
+ void idleTimerCallback() {};
+
struct ChipTimer {
bool enabled;
uint16 value;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list