[Scummvm-cvs-logs] SF.net SVN: scummvm:[38326] scummvm/branches/branch-0-13-0/engines/groovie
spookypeanut at users.sourceforge.net
spookypeanut at users.sourceforge.net
Sun Feb 15 23:49:51 CET 2009
Revision: 38326
http://scummvm.svn.sourceforge.net/scummvm/?rev=38326&view=rev
Author: spookypeanut
Date: 2009-02-15 22:49:50 +0000 (Sun, 15 Feb 2009)
Log Message:
-----------
T7G: Backport of 38284: Fix for #2511456
Modified Paths:
--------------
scummvm/branches/branch-0-13-0/engines/groovie/music.cpp
scummvm/branches/branch-0-13-0/engines/groovie/music.h
scummvm/branches/branch-0-13-0/engines/groovie/script.cpp
Modified: scummvm/branches/branch-0-13-0/engines/groovie/music.cpp
===================================================================
--- scummvm/branches/branch-0-13-0/engines/groovie/music.cpp 2009-02-15 22:43:13 UTC (rev 38325)
+++ scummvm/branches/branch-0-13-0/engines/groovie/music.cpp 2009-02-15 22:49:50 UTC (rev 38326)
@@ -33,7 +33,7 @@
MusicPlayer::MusicPlayer(GroovieEngine *vm, const Common::String >lName) :
_vm(vm), _midiParser(NULL), _data(NULL), _driver(NULL),
- _backgroundFileRef(0), _gameVolume(100), _prevCDtrack(0) {
+ _backgroundFileRef(0), _gameVolume(100), _prevCDtrack(0), _isPlaying(0) {
// Create the parser
_midiParser = MidiParser::createParser_XMIDI();
@@ -95,6 +95,8 @@
void MusicPlayer::playSong(uint16 fileref) {
Common::StackLock lock(_mutex);
+ _fadingEndVolume = 100;
+ _gameVolume = 100;
// Play the referenced file once
play(fileref, false);
}
@@ -174,19 +176,26 @@
_fadingEndVolume = 100;
}
-void MusicPlayer::endTrack() {
- debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: End of song");
- unload();
- if (_backgroundFileRef) {
+void MusicPlayer::startBackground() {
+ debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: startBackground()");
+ if (!_isPlaying && _backgroundFileRef) {
+ debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Starting the background song (0x%4X)", _backgroundFileRef);
play(_backgroundFileRef, true);
}
}
+void MusicPlayer::endTrack() {
+ debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: endTrack()");
+ unload();
+}
+
void MusicPlayer::applyFading() {
+ debugC(6, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: applyFading() _fadingStartTime = %d, _fadingDuration = %d, _fadingStartVolume = %d, _fadingEndVolume = %d", _fadingStartTime, _fadingDuration, _fadingStartVolume, _fadingEndVolume);
Common::StackLock lock(_mutex);
// Calculate the passed time
uint32 time = _vm->_system->getMillis() - _fadingStartTime;
+ debugC(6, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: time = %d, _gameVolume = %d", time, _gameVolume);
if (time >= _fadingDuration) {
// Set the end volume
_gameVolume = _fadingEndVolume;
@@ -195,13 +204,11 @@
_gameVolume = (_fadingStartVolume * (_fadingDuration - time) +
_fadingEndVolume * time) / _fadingDuration;
}
-
if (_gameVolume == _fadingEndVolume) {
// If we were fading to 0, stop the playback and restore the volume
if (_fadingEndVolume == 0) {
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Faded to zero: end of song");
unload();
- _fadingEndVolume = 100;
}
}
@@ -232,8 +239,8 @@
// Set the looping option
_midiParser->property(MidiParser::mpAutoLoop, loop);
- _gameVolume = 100;
+ _isPlaying = true;
// Load the new file
return load(fileref);
}
@@ -269,6 +276,7 @@
void MusicPlayer::unload() {
debugC(1, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: Stopping the playback");
+ _isPlaying = false;
// Unload the parser
_midiParser->unloadMusic();
@@ -355,6 +363,7 @@
}
void MusicPlayer::onTimer(void *refCon) {
+ debugC(9, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: onTimer()");
MusicPlayer *music = (MusicPlayer *)refCon;
Common::StackLock lock(music->_mutex);
Modified: scummvm/branches/branch-0-13-0/engines/groovie/music.h
===================================================================
--- scummvm/branches/branch-0-13-0/engines/groovie/music.h 2009-02-15 22:43:13 UTC (rev 38325)
+++ scummvm/branches/branch-0-13-0/engines/groovie/music.h 2009-02-15 22:49:50 UTC (rev 38326)
@@ -41,6 +41,7 @@
void playSong(uint16 fileref);
void setBackgroundSong(uint16 fileref);
void playCD(uint8 track);
+ void startBackground();
// Volume
void setUserVolume(uint16 volume);
@@ -99,6 +100,7 @@
MidiParser *_midiParser;
MidiDriver *_driver;
uint8 _musicType;
+ bool _isPlaying;
uint16 _backgroundFileRef;
uint8 _prevCDtrack;
Modified: scummvm/branches/branch-0-13-0/engines/groovie/script.cpp
===================================================================
--- scummvm/branches/branch-0-13-0/engines/groovie/script.cpp 2009-02-15 22:43:13 UTC (rev 38325)
+++ scummvm/branches/branch-0-13-0/engines/groovie/script.cpp 2009-02-15 22:49:50 UTC (rev 38326)
@@ -585,6 +585,8 @@
// Save the current pressed character for the whole loop
_kbdChar = _eventKbdChar;
_eventKbdChar = 0;
+
+ _vm->_musicPlayer->startBackground();
}
void Script::o_keyboardaction() {
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