Opened 14 years ago

Closed 14 years ago

#2011 closed defect (fixed)

BS1 Hangs after cutscene without sw or hw mixing

Reported by: SF/jellby Owned by: eriktorbjorn
Priority: normal Component: Engine: Sword1
Keywords: Cc:
Game: Broken Sword 1

Description

This probably happens with other games too.

I have a soundcard with no hardware mixing. If I don't setup
software mixing, BS1 hangs at the last frame of the cutscene
played when entering the sewers (near the beginning).

The problem is solved if I activate ALSA's software mixer or if I
remove the sound files, so I think that proves it's a sound problem
(management of the sound device).

See also this forum message:
http://sourceforge.net/forum/forum.php?
thread_id=1275794&forum_id=115757

Mandrake Linux 10.1
ScummVM 0.8.0CVS (Apr 29 2005 15:22:13)
Features compiled in: Vorbis FLAC MP3 ALSA zLib MPEG2

Ticket imported from: #1192646. Ticket imported from: bugs/2011.

Attachments (3)

SAVEGAME.000 (529 bytes ) - added by SF/jellby 14 years ago.
Before entering the sewer (open it with the bar) English version
8m13.ogg (18.4 KB ) - added by SF/jellby 14 years ago.
sample ogg file, stutters with ogg123
ireland.zip (84.1 KB ) - added by SF/jellby 14 years ago.

Download all attachments as: .zip

Change History (14)

by SF/jellby, 14 years ago

Attachment: SAVEGAME.000 added

Before entering the sewer (open it with the bar) English version

comment:1 by eriktorbjorn, 14 years ago

In regards to the forum thread, there is no difference in
how ScummVM plays the cutscene audio compared to how it
plays other sounds. They all go through ScummVM's own mixer.
(Except for hardware MIDI.)

At the very end of the BS1 cutscene player there is this:

while (!anim->soundFinished())
_sys->delayMillis(100);

Where soundFinished() simply checks if the _bgSound sound
handle is still active. I can understand how this could
cause the half-second freeze that frank_m24 describes.
Though since the entire cutscene soundtrack is about 7
seconds (according to ogginfo), I don't understand at all
why it would hang there indefinitely.

Just out of curiosity, what happens if you use ogg123 or any
other bare-bones Ogg Vorbis player to play the sewer.ogg file?

by SF/jellby, 14 years ago

Attachment: 8m13.ogg added

sample ogg file, stutters with ogg123

comment:2 by SF/jellby, 14 years ago

Hmm... now that you mention it... If I play sewer.ogg (or any other .ogg in
the game) with ogg123, the sound stutters and I get several "ALSA:
underrun, at least 0ms." lines in the console. It plays fine in-game or with
mplayer, though.

I'm attaching the shortest .ogg file if anyone wants to test it...

comment:3 by eriktorbjorn, 14 years ago

Oh well, I was just wondering if maybe there was something
strange with the Ogg Vorbis libraries on your system.
Unlikely idea, I know.

Since I can't reproduce this problem myself there isn't
really much I can do. If I could reproduce it, what I would
do first would be to check if that while-loop is where the
cutscene hangs. That's in sword1/animation.cpp

If so, I'd try to figure out why ScummVM's mixer claimed the
sound handle was still active. That'd be in sound/mixer.cpp,
though I'm less familiar with that part of the code.

But I don't know if that's of any help to you...

comment:4 by SF/jellby, 14 years ago

It doesn't seem to reach the test you mentioned. I modified sword1/
animation.cpp around line 170 so that it's:

}
printf("Frame: %i\n",frameCount); //ifg
}
printf("End of animation\n"); //ifg
}
while (!anim->soundFinished())
_sys->delayMillis(100);
delete anim;

Without "AUDIODEV=swmixer" it stucks at "Frame: 54", "End of animation"
is never shown.

So, with my little programming knowledge, it would seem there's a problem
in decodeFrame (graphics/animation.cpp), which also does some sound
tests. Could that be?

comment:5 by SF/jellby, 14 years ago

It looks like the AUDIODEV trick is not enough. I've now played to Ireland
and the game hangs as well at the end of ireland.mp2. Still, it seems
related to sound and, although the behaviour is not 100% reproducible, it
seems using my custom-encoded ireland.ogg makes the hang more likely.

By the way, my .ogg's are stereo while the downloaded ones are mono, I
don't know if that makes any difference.

comment:6 by SF/jellby, 14 years ago

OK, I've re-encoded video and sound and the problem seems to have
disappeared. Now ogg files are mono. However, I don't think it was right
for scummvm to hang...

I'm attaching a zip with two files: the old ireland.ogg, which makes the
game hang, and a savegame: just exit the museum, go to the aiport and to
Ireland. Here, it hangs.

by SF/jellby, 14 years ago

Attachment: ireland.zip added

comment:7 by eriktorbjorn, 14 years ago

I still can't reproduce the problem. Not on this computer,
at least.

comment:8 by SF/jellby, 14 years ago

Well, in case it helps this is an IBM Thinkpad R51. Exactly this model:

http://www-307.ibm.com/pc/support/site.wss/quickPath.do?
quickPathEntry=1829r6g

comment:9 by eriktorbjorn, 14 years ago

I was thinking more in terms of operating systems. I
couldn't reproduce it under Windows. Perhaps I'll have more
"luck" under Linux.

comment:10 by eriktorbjorn, 14 years ago

Owner: set to eriktorbjorn
Resolution: fixed
Status: newclosed

comment:11 by eriktorbjorn, 14 years ago

I was able to reproduce it under Linux. The problem is
actually the exact opposite of what I first thought: it's
not that the sound is too long, it's that it's too short.
The cutscene player waits for it to play for a certain
duration before drawing the next frame. If the sound ends
prematurely, it just keeps on waiting.

There was some code in there that looks like it was intended
to catch this case, but it wasn't enough.

It should be fixed in CVS now. Otherwise, feel free to reopen.

Note: See TracTickets for help on using tickets.