[Scummvm-cvs-logs] scummvm master -> 1f543652b7cb6a092896f626aa334e56a55c47ec

fuzzie fuzzie at fuzzie.org
Fri Apr 1 14:46:45 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1f543652b7 MOHAWK: Handle waiting for sound cues in LBAnimation.


Commit: 1f543652b7cb6a092896f626aa334e56a55c47ec
    https://github.com/scummvm/scummvm/commit/1f543652b7cb6a092896f626aa334e56a55c47ec
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-04-01T05:44:41-07:00

Commit Message:
MOHAWK: Handle waiting for sound cues in LBAnimation.

Changed paths:
    engines/mohawk/livingbooks.cpp
    engines/mohawk/livingbooks.h



diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp
index 74dbfb3..26bb09a 100644
--- a/engines/mohawk/livingbooks.cpp
+++ b/engines/mohawk/livingbooks.cpp
@@ -1360,12 +1360,17 @@ NodeState LBAnimationNode::update(bool seeking) {
 				break;
 			}
 
-			assert(entry.size == 4);
-			uint16 strLen = READ_BE_UINT16(entry.data + 2);
-
-			if (strLen) {
-				warning("Named wave file encountered (strlen %04x, id %d)", strLen, soundResourceId);
+			Common::String cue;
+			uint pos = 2;
+			while (pos < entry.size) {
+				char in = entry.data[pos];
+				if (!in)
+					break;
+				pos++;
+				cue += in;
 			}
+			if (pos == entry.size)
+				error("Cue in sound kLBAnimOp wasn't null-terminated");
 
 			switch (entry.opcode) {
 			case kLBAnimOpPlaySound:
@@ -1378,7 +1383,7 @@ NodeState LBAnimationNode::update(bool seeking) {
 				if (seeking)
 					break;
 				debug(4, "b: WaitForSound(%0d)", soundResourceId);
-				if (!_parent->soundPlaying(soundResourceId))
+				if (!_parent->soundPlaying(soundResourceId, cue))
 					break;
 				_currentEntry--;
 				return kLBNodeWaiting;
@@ -1744,11 +1749,27 @@ void LBAnimation::stop() {
 
 void LBAnimation::playSound(uint16 resourceId) {
 	_currentSound = resourceId;
-	_vm->_sound->playSound(_currentSound);
+	_vm->_sound->playSound(_currentSound, Audio::Mixer::kMaxChannelVolume, false, &_cueList);
 }
 
-bool LBAnimation::soundPlaying(uint16 resourceId) {
-	return _currentSound == resourceId && _vm->_sound->isPlaying(_currentSound);
+bool LBAnimation::soundPlaying(uint16 resourceId, const Common::String &cue) {
+	if (_currentSound != resourceId)
+		return false;
+	if (!_vm->_sound->isPlaying(_currentSound))
+		return false;
+
+	if (cue.empty())
+		return true;
+
+	uint samples = _vm->_sound->getNumSamplesPlayed(_currentSound);
+	for (uint i = 0; i < _cueList.pointCount; i++) {
+		if (_cueList.points[i].sampleFrame > samples)
+			break;
+		if (_cueList.points[i].name == cue)
+			return false;
+	}
+
+	return true;
 }
 
 bool LBAnimation::transparentAt(int x, int y) {
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 7138078..e55f14b 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -29,6 +29,7 @@
 #include "mohawk/mohawk.h"
 #include "mohawk/console.h"
 #include "mohawk/graphics.h"
+#include "mohawk/sound.h"
 
 #include "common/config-file.h"
 #include "common/substream.h"
@@ -313,7 +314,7 @@ public:
 	void stop();
 
 	void playSound(uint16 resourceId);
-	bool soundPlaying(uint16 resourceId);
+	bool soundPlaying(uint16 resourceId, const Common::String &cue);
 
 	bool transparentAt(int x, int y);
 
@@ -335,7 +336,10 @@ protected:
 	Common::Array<LBAnimationNode *> _nodes;
 
 	uint16 _tempo;
+
 	uint16 _currentSound;
+	CueList _cueList;
+
 	uint32 _lastTime, _currentFrame;
 	bool _running;
 






More information about the Scummvm-git-logs mailing list