aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD G Turner2012-12-15 03:14:00 +0000
committerD G Turner2012-12-15 03:14:00 +0000
commit702aecf12548a6113d3f1b4496c85dc199a58d6a (patch)
tree957abf1956770f321ac7050967e35227193ef339
parentde39adfb78f7f467d524930bf87930048d7ea32e (diff)
downloadscummvm-rg350-702aecf12548a6113d3f1b4496c85dc199a58d6a.tar.gz
scummvm-rg350-702aecf12548a6113d3f1b4496c85dc199a58d6a.tar.bz2
scummvm-rg350-702aecf12548a6113d3f1b4496c85dc199a58d6a.zip
TOUCHE: Fixes to external digital music support.
This removes most of the bad accesses and use of invalid pointers, but it is still not quite correct. Also, it appears the music id and external track ids may not be a direct mapping.
-rw-r--r--engines/touche/touche.cpp19
-rw-r--r--engines/touche/touche.h2
2 files changed, 11 insertions, 10 deletions
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 7e3fe67575..5338387be9 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -62,7 +62,6 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
_playSoundCounter = 0;
_musicVolume = 0;
- _musicStream = 0;
_processRandomPaletteCounter = 0;
@@ -96,8 +95,9 @@ ToucheEngine::~ToucheEngine() {
DebugMan.clearAllDebugChannels();
delete _console;
+ stopMusic();
+ _extMusicFile.close();
delete _midiPlayer;
- delete _musicStream;
}
Common::Error ToucheEngine::run() {
@@ -3340,21 +3340,20 @@ void ToucheEngine::startMusic(int num) {
_fData.seek(offs);
_midiPlayer->play(_fData, size, true);
} else {
- Common::File extMusicFile;
+ _extMusicFile.close();
Common::String extMusicFilename = Common::String::format("track%02d.ogg", num);
- if (!extMusicFile.open(extMusicFilename)) {
+ if (!_extMusicFile.open(extMusicFilename)) {
error("Unable to open %s for reading", extMusicFilename.c_str());
}
- delete _musicStream;
- _musicStream = Audio::makeVorbisStream(&extMusicFile, DisposeAfterUse::NO);
- Audio::LoopingAudioStream loopStream(_musicStream, 0);
- _mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, &loopStream);
+ Audio::SeekableAudioStream *musicStream = Audio::makeVorbisStream(&_extMusicFile, DisposeAfterUse::NO);
+ Audio::LoopingAudioStream *loopStream = new Audio::LoopingAudioStream(musicStream, 0);
+ _mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, loopStream);
_mixer->setChannelVolume(_musicHandle, _musicVolume);
- extMusicFile.close();
}
}
void ToucheEngine::stopMusic() {
+ debug(1, "stopMusic()");
if (_midiPlayer)
_midiPlayer->stop();
else {
@@ -3369,6 +3368,7 @@ int ToucheEngine::getMusicVolume() {
}
void ToucheEngine::setMusicVolume(int volume) {
+ debug(1, "setMusicVolume(%d)", volume);
_musicVolume = CLIP(volume, 0, 255);
if (_midiPlayer)
@@ -3379,6 +3379,7 @@ void ToucheEngine::setMusicVolume(int volume) {
}
void ToucheEngine::adjustMusicVolume(int diff) {
+ debug(1, "adjustMusicVolume(%d)", diff);
_musicVolume = CLIP(_musicVolume + diff, 0, 255);
if (_midiPlayer)
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index e63609b9a6..75d99c21d4 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -649,7 +649,7 @@ protected:
int _musicVolume;
Audio::SoundHandle _musicHandle;
- Audio::SeekableAudioStream *_musicStream;
+ Common::File _extMusicFile;
void initMusic();
void startMusic(int num);