aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Hoenicke2005-03-15 13:41:15 +0000
committerJochen Hoenicke2005-03-15 13:41:15 +0000
commit86cd961b72455b4513a0d6575c0b65d08fd82d8d (patch)
treeb3795b287d0efa2c81291b40e249c18456902ecf
parent402dd115eade0a59f2fb0647bad1e1de6f953f82 (diff)
downloadscummvm-rg350-86cd961b72455b4513a0d6575c0b65d08fd82d8d.tar.gz
scummvm-rg350-86cd961b72455b4513a0d6575c0b65d08fd82d8d.tar.bz2
scummvm-rg350-86cd961b72455b4513a0d6575c0b65d08fd82d8d.zip
Fix Bug #1163202 (music never stops). Some code cleanup.
svn-id: r17155
-rw-r--r--scumm/player_v2.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/scumm/player_v2.cpp b/scumm/player_v2.cpp
index 4643921602..97eba6cecd 100644
--- a/scumm/player_v2.cpp
+++ b/scumm/player_v2.cpp
@@ -556,7 +556,7 @@ void Player_V2::execute_cmd(ChannelInfo *channel) {
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 @@ void Player_V2::execute_cmd(ChannelInfo *channel) {
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 @@ void Player_V2::execute_cmd(ChannelInfo *channel) {
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 @@ void Player_V2::execute_cmd(ChannelInfo *channel) {
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 @@ void Player_V2::do_mix(int16 *data, uint len) {
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 @@ void Player_V2::do_mix(int16 *data, uint len) {
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();