aboutsummaryrefslogtreecommitdiff
path: root/engines/touche
diff options
context:
space:
mode:
authorD G Turner2012-12-16 16:03:32 +0000
committerD G Turner2012-12-16 16:03:32 +0000
commit74cd6a4d269b1a0504f8ceada779ef28d89875a2 (patch)
tree6a85748b56b70e19daf01305971e3b89fcf88df9 /engines/touche
parent101d355b4a14cb14b23435a69fb1d687bfad2c92 (diff)
downloadscummvm-rg350-74cd6a4d269b1a0504f8ceada779ef28d89875a2.tar.gz
scummvm-rg350-74cd6a4d269b1a0504f8ceada779ef28d89875a2.tar.bz2
scummvm-rg350-74cd6a4d269b1a0504f8ceada779ef28d89875a2.zip
TOUCHE: Fix external music to work with any music format.
This also removes the direct dependency on vorbis. Thanks to [md5] for the majority of this patch.
Diffstat (limited to 'engines/touche')
-rw-r--r--engines/touche/touche.cpp21
-rw-r--r--engines/touche/touche.h2
2 files changed, 10 insertions, 13 deletions
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index ada12099c3..d03425a69f 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -33,7 +33,6 @@
#include "common/textconsole.h"
#include "audio/mixer.h"
-#include "audio/decoders/vorbis.h"
#include "engines/util.h"
#include "graphics/cursorman.h"
@@ -96,7 +95,6 @@ ToucheEngine::~ToucheEngine() {
delete _console;
stopMusic();
- _extMusicFile.close();
delete _midiPlayer;
}
@@ -3317,12 +3315,12 @@ bool ToucheEngine::canSaveGameStateCurrently() {
void ToucheEngine::initMusic() {
// Detect External Music Files
bool extMusic = true;
- for (int num = 0; num < 26; num++) {
- Common::String extMusicFilename = Common::String::format("track%02d.ogg", num+1);
- Common::File extMusicFile;
- if (!extMusicFile.open(extMusicFilename))
+ for (int num = 0; num < 26 && extMusic; num++) {
+ Common::String extMusicFilename = Common::String::format("track%02d", num+1);
+ Audio::SeekableAudioStream *musicStream = Audio::SeekableAudioStream::openStreamFile(extMusicFilename);
+ if (!musicStream)
extMusic = false;
- extMusicFile.close();
+ delete musicStream;
}
if (!extMusic) {
@@ -3343,12 +3341,12 @@ void ToucheEngine::startMusic(int num) {
_fData.seek(offs);
_midiPlayer->play(_fData, size, true);
} else {
- Common::String extMusicFilename = Common::String::format("track%02d.ogg", num);
- if (!_extMusicFile.open(extMusicFilename)) {
+ Common::String extMusicFilename = Common::String::format("track%02d", num);
+ _extMusicFileStream = Audio::SeekableAudioStream::openStreamFile(extMusicFilename);
+ if (!_extMusicFileStream) {
error("Unable to open %s for reading", extMusicFilename.c_str());
}
- Audio::SeekableAudioStream *musicStream = Audio::makeVorbisStream(&_extMusicFile, DisposeAfterUse::NO);
- Audio::LoopingAudioStream *loopStream = new Audio::LoopingAudioStream(musicStream, 0);
+ Audio::LoopingAudioStream *loopStream = new Audio::LoopingAudioStream(_extMusicFileStream, 0);
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, loopStream);
_mixer->setChannelVolume(_musicHandle, _musicVolume);
}
@@ -3360,7 +3358,6 @@ void ToucheEngine::stopMusic() {
_midiPlayer->stop();
else {
_mixer->stopHandle(_musicHandle);
- _extMusicFile.close();
}
}
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 6b04dfbbea..7901d0f1b6 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -649,7 +649,7 @@ protected:
int _musicVolume;
Audio::SoundHandle _musicHandle;
- Common::File _extMusicFile;
+ Audio::SeekableAudioStream *_extMusicFileStream;
void initMusic();
public: // To allow access from console