[Scummvm-cvs-logs] CVS: scummvm/scumm player_v2.cpp,2.58,2.59

Jochen Hoenicke hoenicke at users.sourceforge.net
Tue Mar 15 05:42:08 CET 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1341

Modified Files:
	player_v2.cpp 
Log Message:
Fix Bug #1163202 (music never stops).  Some code cleanup.

Index: player_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/player_v2.cpp,v
retrieving revision 2.58
retrieving revision 2.59
diff -u -d -r2.58 -r2.59
--- player_v2.cpp	15 Mar 2005 10:04:35 -0000	2.58
+++ player_v2.cpp	15 Mar 2005 13:41:15 -0000	2.59
@@ -556,7 +556,7 @@
 	current_channel = channel;
 
 	if (channel->d.next_cmd == 0)
-		return;
+		goto check_stopped;
 	script_ptr = &_current_data[channel->d.next_cmd];
 
 	for (;;) {
@@ -597,7 +597,7 @@
 
 			case 0xfa: // clear current channel
 				if (opcode == 0xfa)
-					debug(9, "clear channel");
+					debug(7, "clear channel");
 				channel->d.next_cmd   = 0;
 				channel->d.base_freq  = 0;
 				channel->d.freq_delta = 0;
@@ -669,14 +669,20 @@
 					note = *script_ptr++;
 					is_last_note = note & 0x80;
 					note &= 0x7f;
-					if (note == 0x7f) 
+					if (note == 0x7f) {
+						debug(8, "channels[%d]: pause %d", 
+							  channel - _channels, channel->d.time_left);
 						goto end;
+					}
 				} else {
 
 					channel->d.time_left = ((opcode & 7) << 8) | *script_ptr++;
 
-					if ((opcode & 0x10))
+					if ((opcode & 0x10)) {
+						debug(8, "channels[%d]: pause %d", 
+							  channel - _channels, channel->d.time_left);
 						goto end;
+					}
 
 					is_last_note = 0;
 					note = (*script_ptr++) & 0x7f;
@@ -716,24 +722,24 @@
 
 end:
 	channel = current_channel;
-	if (channel->d.time_left)
-		goto finish;
+	if (channel->d.time_left) {
+		channel->d.next_cmd = script_ptr - _current_data;
+		return;
+	}
 
 	channel->d.next_cmd = 0;
+
+check_stopped:
 	int i;
 	for (i = 0; i < 4; i++) {
 		if (_channels[i].d.time_left)
-			goto finish;
+			return;
 	}
 
 	_current_nr = 0;
 	_current_data = 0;
 	chainNextSound();
 	return;
-
-finish:
-	channel->d.next_cmd = script_ptr - _current_data;
-	return;
 }
 
 void Player_V2::next_freqs(ChannelInfo *channel) {
@@ -794,6 +800,11 @@
 	uint step;
 
 	do {
+		if (!(_next_tick >> FIXP_SHIFT)) {
+			_next_tick += _tick_len;
+			nextTick();
+		}
+
 		step = len;
 		if (step > (_next_tick >> FIXP_SHIFT))
 			step = (_next_tick >> FIXP_SHIFT);
@@ -803,11 +814,6 @@
 			generateSpkSamples(data, step);
 		data += 2 * step;
 		_next_tick -= step << FIXP_SHIFT;
-
-		if (!(_next_tick >> FIXP_SHIFT)) {
-			_next_tick += _tick_len;
-			nextTick();
-		}
 	} while (len -= step);
 
 	mutex_down();





More information about the Scummvm-git-logs mailing list