[Scummvm-cvs-logs] scummvm master -> 9986d73e474c7b54b80c53506c64e2c4044d8fb8
digitall
dgturner at iee.org
Sun Dec 16 14:13:40 CET 2012
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
8b379a5718 TOUCHE: Add generic music functions to wrap MidiPlayer usages.
eb30e5c594 TOUCHE: Add support for external digital music.
de39adfb78 TOUCHE: Fix incorrect handle usage.
702aecf125 TOUCHE: Fixes to external digital music support.
2c80977b13 TOUCHE: Fix external digital music support.
9986d73e47 Merge branch 'toucheExtMusic'
Commit: 8b379a5718df054775d24adcd45d4c45b9d34e74
https://github.com/scummvm/scummvm/commit/8b379a5718df054775d24adcd45d4c45b9d34e74
Author: D G Turner (digitall at scummvm.org)
Date: 2012-12-12T09:02:59-08:00
Commit Message:
TOUCHE: Add generic music functions to wrap MidiPlayer usages.
This is a precursor to adding code within these functions to select
between MIDI and external digital music files.
Changed paths:
engines/touche/menu.cpp
engines/touche/resource.cpp
engines/touche/touche.cpp
engines/touche/touche.h
diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index c58e2f1..57882fa 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -260,7 +260,7 @@ void ToucheEngine::redrawMenu(void *menu) {
Graphics::drawRect(_offscreenBuffer, kScreenWidth, 106, 118, 340, 164, 0xF9, 0xF7);
switch (menuData->mode) {
case kMenuSettingsMode:
- drawVolumeSlideBar(_offscreenBuffer, kScreenWidth, _midiPlayer->getVolume());
+ drawVolumeSlideBar(_offscreenBuffer, kScreenWidth, getMusicVolume());
menuData->buttonsTable[5].data = 0;
menuData->buttonsTable[6].data = 0;
menuData->buttonsTable[7].data = 0;
@@ -307,10 +307,10 @@ void ToucheEngine::handleMenuAction(void *menu, int actionId) {
_talkTextMode = kTalkModeVoiceAndText;
break;
case kActionLowerVolume:
- _midiPlayer->adjustVolume(-16);
+ adjustMusicVolume(-16);
break;
case kActionUpperVolume:
- _midiPlayer->adjustVolume(+16);
+ adjustMusicVolume(+16);
break;
case kActionScrollUpSaves:
--_saveLoadCurrentPage;
diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp
index 0790d72..9625224 100644
--- a/engines/touche/resource.cpp
+++ b/engines/touche/resource.cpp
@@ -610,10 +610,7 @@ void ToucheEngine::res_stopSound() {
void ToucheEngine::res_loadMusic(int num) {
debugC(9, kDebugResource, "ToucheEngine::res_loadMusic() num=%d", num);
- uint32 size;
- const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
- _fData.seek(offs);
- _midiPlayer->play(_fData, size, true);
+ startMusic(num);
}
void ToucheEngine::res_loadSpeech(int num) {
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 4b98996..8fdbad5 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -100,7 +100,7 @@ Common::Error ToucheEngine::run() {
setupOpcodes();
- _midiPlayer = new MidiPlayer;
+ initMusic();
// Setup mixer
syncSoundSettings();
@@ -120,7 +120,7 @@ Common::Error ToucheEngine::run() {
}
void ToucheEngine::restart() {
- _midiPlayer->stop();
+ stopMusic();
_gameState = kGameStateGameLoop;
_displayQuitDialog = false;
@@ -216,7 +216,7 @@ void ToucheEngine::readConfigurationSettings() {
_talkTextMode = kTalkModeVoiceOnly;
}
}
- _midiPlayer->setVolume(ConfMan.getInt("music_volume"));
+ setMusicVolume(ConfMan.getInt("music_volume"));
}
void ToucheEngine::writeConfigurationSettings() {
@@ -234,7 +234,7 @@ void ToucheEngine::writeConfigurationSettings() {
ConfMan.setBool("subtitles", true);
break;
}
- ConfMan.setInt("music_volume", _midiPlayer->getVolume());
+ ConfMan.setInt("music_volume", getMusicVolume());
ConfMan.flushToDisk();
}
@@ -3307,4 +3307,31 @@ bool ToucheEngine::canSaveGameStateCurrently() {
return _gameState == kGameStateGameLoop && _flagsTable[618] == 0 && !_hideInventoryTexts;
}
+void ToucheEngine::initMusic() {
+ _midiPlayer = new MidiPlayer;
+}
+
+void ToucheEngine::startMusic(int num) {
+ uint32 size;
+ const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
+ _fData.seek(offs);
+ _midiPlayer->play(_fData, size, true);
+}
+
+void ToucheEngine::stopMusic() {
+ _midiPlayer->stop();
+}
+
+int ToucheEngine::getMusicVolume() {
+ return _midiPlayer->getVolume();
+}
+
+void ToucheEngine::setMusicVolume(int volume) {
+ _midiPlayer->setVolume(volume);
+}
+
+void ToucheEngine::adjustMusicVolume(int diff) {
+ _midiPlayer->adjustVolume(diff);
+}
+
} // namespace Touche
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 949727b..72993e2 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -646,6 +646,13 @@ protected:
MidiPlayer *_midiPlayer;
+ void initMusic();
+ void startMusic(int num);
+ void stopMusic();
+ int getMusicVolume();
+ void setMusicVolume(int volume);
+ void adjustMusicVolume(int diff);
+
Common::Language _language;
Common::RandomSource _rnd;
Commit: eb30e5c59417329544d671632d2db1ca4f8fe655
https://github.com/scummvm/scummvm/commit/eb30e5c59417329544d671632d2db1ca4f8fe655
Author: D G Turner (digitall at scummvm.org)
Date: 2012-12-12T17:41:54-08:00
Commit Message:
TOUCHE: Add support for external digital music.
Detection of the external digital music files works, but they currently
fail to play and cause segfaults if present... Suspected to be related
to premature destruction of audiostream data.
Changed paths:
engines/touche/touche.cpp
engines/touche/touche.h
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 8fdbad5..dd52a07 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -32,6 +32,9 @@
#include "common/keyboard.h"
#include "common/textconsole.h"
+#include "audio/mixer.h"
+#include "audio/decoders/vorbis.h"
+
#include "engines/util.h"
#include "graphics/cursorman.h"
#include "graphics/palette.h"
@@ -58,6 +61,9 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
_playSoundCounter = 0;
+ _musicVolume = 0;
+ _musicStream = 0;
+
_processRandomPaletteCounter = 0;
_fastWalkMode = false;
@@ -91,6 +97,7 @@ ToucheEngine::~ToucheEngine() {
delete _console;
delete _midiPlayer;
+ delete _musicStream;
}
Common::Error ToucheEngine::run() {
@@ -3308,30 +3315,77 @@ bool ToucheEngine::canSaveGameStateCurrently() {
}
void ToucheEngine::initMusic() {
- _midiPlayer = new MidiPlayer;
+ // 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))
+ extMusic = false;
+ extMusicFile.close();
+ }
+
+ if (!extMusic) {
+ _midiPlayer = new MidiPlayer;
+ debug(1, "initMusic(): Using midi music!");
+ } else
+ debug(1, "initMusic(): Using external digital music!");
}
void ToucheEngine::startMusic(int num) {
+ debug(1, "startMusic(%d)", num);
uint32 size;
- const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
- _fData.seek(offs);
- _midiPlayer->play(_fData, size, true);
+ if (_midiPlayer) {
+ const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
+ _fData.seek(offs);
+ _midiPlayer->play(_fData, size, true);
+ } else {
+ Common::File extMusicFile;
+ Common::String extMusicFilename = Common::String::format("track%02d.ogg", num);
+ 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);
+ _mixer->setChannelVolume(_musicHandle, _musicVolume);
+ extMusicFile.close();
+ }
}
void ToucheEngine::stopMusic() {
- _midiPlayer->stop();
+ if (_midiPlayer)
+ _midiPlayer->stop();
+ else {
+ _mixer->stopHandle(_speechHandle);
+ }
}
int ToucheEngine::getMusicVolume() {
- return _midiPlayer->getVolume();
+ if (_midiPlayer)
+ _musicVolume = _midiPlayer->getVolume();
+ return _musicVolume;
}
void ToucheEngine::setMusicVolume(int volume) {
- _midiPlayer->setVolume(volume);
+ _musicVolume = CLIP(volume, 0, 255);
+
+ if (_midiPlayer)
+ _midiPlayer->setVolume(_musicVolume);
+ else {
+ _mixer->setChannelVolume(_musicHandle, _musicVolume);
+ }
}
void ToucheEngine::adjustMusicVolume(int diff) {
- _midiPlayer->adjustVolume(diff);
+ _musicVolume = CLIP(_musicVolume + diff, 0, 255);
+
+ if (_midiPlayer)
+ _midiPlayer->adjustVolume(diff);
+ else {
+ _mixer->setChannelVolume(_musicHandle, _musicVolume);
+ }
}
} // namespace Touche
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 72993e2..e63609b 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -31,6 +31,7 @@
#include "common/util.h"
#include "audio/mixer.h"
+#include "audio/audiostream.h"
#include "engines/engine.h"
@@ -646,6 +647,10 @@ protected:
MidiPlayer *_midiPlayer;
+ int _musicVolume;
+ Audio::SoundHandle _musicHandle;
+ Audio::SeekableAudioStream *_musicStream;
+
void initMusic();
void startMusic(int num);
void stopMusic();
Commit: de39adfb78f7f467d524930bf87930048d7ea32e
https://github.com/scummvm/scummvm/commit/de39adfb78f7f467d524930bf87930048d7ea32e
Author: D G Turner (digitall at scummvm.org)
Date: 2012-12-14T15:28:01-08:00
Commit Message:
TOUCHE: Fix incorrect handle usage.
Changed paths:
engines/touche/touche.cpp
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index dd52a07..7e3fe67 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -3358,7 +3358,7 @@ void ToucheEngine::stopMusic() {
if (_midiPlayer)
_midiPlayer->stop();
else {
- _mixer->stopHandle(_speechHandle);
+ _mixer->stopHandle(_musicHandle);
}
}
Commit: 702aecf12548a6113d3f1b4496c85dc199a58d6a
https://github.com/scummvm/scummvm/commit/702aecf12548a6113d3f1b4496c85dc199a58d6a
Author: D G Turner (digitall at scummvm.org)
Date: 2012-12-14T19:14:00-08:00
Commit Message:
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.
Changed paths:
engines/touche/touche.cpp
engines/touche/touche.h
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 7e3fe67..5338387 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 e63609b..75d99c2 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);
Commit: 2c80977b13f5002ff8812ac9e0fd4c12e46fc625
https://github.com/scummvm/scummvm/commit/2c80977b13f5002ff8812ac9e0fd4c12e46fc625
Author: D G Turner (digitall at scummvm.org)
Date: 2012-12-15T18:34:35-08:00
Commit Message:
TOUCHE: Fix external digital music support.
Thanks to clone2727 for pointing out the issue here.
Tested with Valgrind and no leaks present.
However, the music output is still not correct, when compared to
Midi output. This is due to the track numbering. Either the
external files need renaming or a mapping table will be needed.
Changed paths:
engines/touche/touche.cpp
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 5338387..ada1209 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -3335,12 +3335,14 @@ void ToucheEngine::initMusic() {
void ToucheEngine::startMusic(int num) {
debug(1, "startMusic(%d)", num);
uint32 size;
+
+ stopMusic();
+
if (_midiPlayer) {
const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
_fData.seek(offs);
_midiPlayer->play(_fData, size, true);
} else {
- _extMusicFile.close();
Common::String extMusicFilename = Common::String::format("track%02d.ogg", num);
if (!_extMusicFile.open(extMusicFilename)) {
error("Unable to open %s for reading", extMusicFilename.c_str());
@@ -3358,6 +3360,7 @@ void ToucheEngine::stopMusic() {
_midiPlayer->stop();
else {
_mixer->stopHandle(_musicHandle);
+ _extMusicFile.close();
}
}
Commit: 9986d73e474c7b54b80c53506c64e2c4044d8fb8
https://github.com/scummvm/scummvm/commit/9986d73e474c7b54b80c53506c64e2c4044d8fb8
Author: D G Turner (digitall at scummvm.org)
Date: 2012-12-16T05:12:02-08:00
Commit Message:
Merge branch 'toucheExtMusic'
Changed paths:
engines/touche/menu.cpp
engines/touche/resource.cpp
engines/touche/touche.cpp
engines/touche/touche.h
More information about the Scummvm-git-logs
mailing list