[Scummvm-cvs-logs] SF.net SVN: scummvm:[35756] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Jan 6 17:21:23 CET 2009


Revision: 35756
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35756&view=rev
Author:   peres001
Date:     2009-01-06 16:21:23 +0000 (Tue, 06 Jan 2009)

Log Message:
-----------
Implemented pauseEngineIntern, and fixed music volume handling in SoundMan.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/sound.cpp
    scummvm/trunk/engines/parallaction/sound.h

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2009-01-06 16:10:04 UTC (rev 35755)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2009-01-06 16:21:23 UTC (rev 35756)
@@ -134,6 +134,12 @@
 	return Common::kNoError;
 }
 
+void Parallaction::pauseEngineIntern(bool pause) {
+	if (_soundMan) {
+		_soundMan->pause(pause);
+	}
+}
+
 bool canScroll() {
 	return (_vm->_gfx->_backgroundInfo->width > _vm->_screenWidth);
 }

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2009-01-06 16:10:04 UTC (rev 35755)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2009-01-06 16:21:23 UTC (rev 35756)
@@ -253,6 +253,7 @@
 	// Engine APIs
 	virtual Common::Error init();
 	virtual bool hasFeature(EngineFeature f) const;
+	virtual void pauseEngineIntern(bool pause);
 
 	// info
 	int32			_screenWidth;

Modified: scummvm/trunk/engines/parallaction/sound.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/sound.cpp	2009-01-06 16:10:04 UTC (rev 35755)
+++ scummvm/trunk/engines/parallaction/sound.cpp	2009-01-06 16:21:23 UTC (rev 35756)
@@ -49,6 +49,7 @@
 
 	void play(Common::SeekableReadStream *stream);
 	void stop();
+	void pause(bool p);
 	void updateTimer();
 	void adjustVolume(int diff);
 	void setVolume(int volume);
@@ -74,6 +75,7 @@
 	uint8 *_midiData;
 	bool _isLooping;
 	bool _isPlaying;
+	bool _paused;
 	int _masterVolume;
 	MidiChannel *_channelsTable[NUM_CHANNELS];
 	uint8 _channelsVolume[NUM_CHANNELS];
@@ -81,10 +83,12 @@
 };
 
 MidiPlayer::MidiPlayer(MidiDriver *driver)
-	: _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0) {
+	: _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _paused(false), _masterVolume(0) {
 	assert(_driver);
 	memset(_channelsTable, 0, sizeof(_channelsTable));
-	memset(_channelsVolume, 0, sizeof(_channelsVolume));
+	for (int i = 0; i < NUM_CHANNELS; i++) {
+		_channelsVolume[i] = 127;
+	}
 
 	open();
 }
@@ -125,7 +129,21 @@
 	_mutex.unlock();
 }
 
+void MidiPlayer::pause(bool p) {
+	_paused = p;
+
+	for (int i = 0; i < NUM_CHANNELS; ++i) {
+		if (_channelsTable[i]) {
+			_channelsTable[i]->volume(_paused ? 0 : _channelsVolume[i] * _masterVolume / 255);
+		}
+	}
+}
+
 void MidiPlayer::updateTimer() {
+	if (_paused) {
+		return;
+	}
+
 	_mutex.lock();
 	if (_isPlaying) {
 		_parser->onTimer();
@@ -217,7 +235,6 @@
 	player->updateTimer();
 }
 
-
 DosSoundMan::DosSoundMan(Parallaction *vm, MidiDriver *midiDriver) : SoundMan(vm), _musicData1(0) {
 	_midiPlayer = new MidiPlayer(midiDriver);
 }
@@ -254,12 +271,18 @@
 
 	Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile);
 	_midiPlayer->play(stream);
+	_midiPlayer->setVolume(255);
 }
 
 void DosSoundMan::stopMusic() {
 	_midiPlayer->stop();
 }
 
+void DosSoundMan::pause(bool p) {
+	SoundMan::pause(p);
+	_midiPlayer->pause(p);
+}
+
 void DosSoundMan::playCharacterMusic(const char *character) {
 	if (character == NULL) {
 		return;

Modified: scummvm/trunk/engines/parallaction/sound.h
===================================================================
--- scummvm/trunk/engines/parallaction/sound.h	2009-01-06 16:10:04 UTC (rev 35755)
+++ scummvm/trunk/engines/parallaction/sound.h	2009-01-06 16:21:23 UTC (rev 35756)
@@ -62,6 +62,8 @@
 	virtual void stopMusic() = 0;
 	virtual void playCharacterMusic(const char *character) = 0;
 	virtual void playLocationMusic(const char *location) = 0;
+	virtual void pause(bool p) { }
+
 	void setMusicVolume(int value);
 };
 
@@ -80,6 +82,8 @@
 
 	void playCharacterMusic(const char *character);
 	void playLocationMusic(const char *location);
+
+	void pause(bool p);
 };
 
 #define NUM_AMIGA_CHANNELS 4


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