cutscene playback fix
Geller Sandor
wildy at petra.hos.u-szeged.hu
Sun Jun 13 08:51:47 EDT 2004
Hi!
I've encountered reproducible segfaults with the MVE player. The segfaults
were originated from src/movie/mveplayer.cpp, when free(pixelbuf) is
called. Tracking down the problem, I found some strange things in the
code with cutscene playing, so I created a small patch, which resolves my
problems. The attached patch makes the following:
1. when initializeMovie is called, it sets the static variable playing to
1 - without this, when you press ESC while playing the intro or some
other cutscene, you can't see other cutscenes
2. when pixelbuf is allocated, the return code of malloc isn't checked, so
I protected the free(pixelbuf) with if (pixelbuf)
3. the key_check in display_video_handler() was bogus, I removed the
key_check function completely from the source, and added a proper check
in display_video_handler()
I hope that this patch works for everyone. If the developers want to
include this patch, they can, under any license.
Regards,
Sandor GELLER
-------------- next part --------------
diff -urN freespace2.orig/include/key.h freespace2/include/key.h
--- freespace2.orig/include/key.h 2002-08-04 04:31:00.000000000 +0200
+++ freespace2/include/key.h 2004-06-13 14:13:14.000000000 +0200
@@ -129,7 +129,6 @@
int key_down_count(int scancode);
int key_up_count(int scancode);
int key_checkch();
-int key_check(int key);
// Put "key" back in the input buffer.
void key_outkey(int key);
diff -urN freespace2.orig/src/io/key.cpp freespace2/src/io/key.cpp
--- freespace2.orig/src/io/key.cpp 2004-06-11 21:56:59.000000000 +0200
+++ freespace2/src/io/key.cpp 2004-06-13 14:12:22.000000000 +0200
@@ -777,11 +777,6 @@
return n;
}
-int key_check(int key)
-{
- return key_data.down_check[key];
-}
-
// Add a key up or down code to the key buffer. state=1 -> down, state=0 -> up
// latency => time difference in ms between when key was actually pressed and now
//void key_mark( uint code, int state )
diff -urN freespace2.orig/src/movie/mveplayer.cpp freespace2/src/movie/mveplayer.cpp
--- freespace2.orig/src/movie/mveplayer.cpp 2002-07-27 23:46:18.000000000 +0200
+++ freespace2/src/movie/mveplayer.cpp 2004-06-13 14:32:29.000000000 +0200
@@ -552,6 +552,7 @@
static int display_video_handler(unsigned char major, unsigned char minor, unsigned char *data, int len, void *context)
{
+ int k;
ConvertAndDraw();
#if 0
@@ -568,8 +569,13 @@
#ifdef PLAT_UNIX
os_poll (); /* DDOI - run event loop(s) */
#endif
- if (key_check (KEY_ESC)) playing = 0;
-
+ k = key_inkey();
+ if ( k == KEY_ESC ) {
+ playing = 0;
+ } else {
+ key_outkey (k);
+ }
+
return 1;
}
@@ -669,6 +675,7 @@
mve_set_handler(mve, 0x0c, video_palette_handler);
mve_set_handler(mve, 0x0f, video_codemap_handler);
mve_set_handler(mve, 0x11, video_data_handler);
+ playing = 1;
}
void playMovie(MVESTREAM *mve)
@@ -690,5 +697,5 @@
void shutdownMovie(MVESTREAM *mve)
{
- free (pixelbuf);
+ if (pixelbuf) free (pixelbuf);
}
More information about the freespace2
mailing list