[Swfdec] 9 commits - libswfdec-gtk/swfdec_source.c libswfdec/swfdec_marshal.list libswfdec/swfdec_player.c libswfdec/swfdec_player.h libswfdec/swfdec_player_internal.h libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_swf_instance.c test/dump.c test/Makefile.am test/parse.c test/sound test/swfdec-extract.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Sun Aug 26 10:31:03 PDT 2007


 libswfdec-gtk/swfdec_source.c              |    2 
 libswfdec/swfdec_marshal.list              |    2 
 libswfdec/swfdec_player.c                  |   55 ++++++++++++----------
 libswfdec/swfdec_player.h                  |    4 -
 libswfdec/swfdec_player_internal.h         |    2 
 libswfdec/swfdec_sprite_movie.c            |   70 +++++++++++++++--------------
 libswfdec/swfdec_swf_instance.c            |    1 
 test/Makefile.am                           |    7 --
 test/dump.c                                |    2 
 test/parse.c                               |   53 ---------------------
 test/swfdec-extract.c                      |    2 
 test/trace/netstream-load-loop-6.swf.trace |    1 
 test/trace/netstream-load-loop-7.swf.trace |    1 
 test/trace/netstream-load-loop-8.swf.trace |    1 
 test/trace/trace.c                         |   24 +++++----
 15 files changed, 94 insertions(+), 133 deletions(-)

New commits:
diff-tree a814430ddec42b4803e93b5b44055a7c45182a27 (from 560fa82af756a4fbe6e132bd7f99b636a7ad9be7)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 26 19:26:58 2007 +0200

    add same hack here

diff --git a/test/swfdec-extract.c b/test/swfdec-extract.c
index 04f5988..73e49fa 100644
--- a/test/swfdec-extract.c
+++ b/test/swfdec-extract.c
@@ -240,6 +240,8 @@ main (int argc, char *argv[])
   }
 
   player = swfdec_player_new_from_file (argv[1]);
+  /* FIXME: HACK! */
+  swfdec_player_advance (player, 0);
   if (!SWFDEC_IS_SPRITE_MOVIE (player->roots->data)) {
     g_printerr ("Error parsing file \"%s\"\n", argv[1]);
     g_object_unref (player);
diff-tree 560fa82af756a4fbe6e132bd7f99b636a7ad9be7 (from 35f50913a304a1888c1f8d215c3d9f1cf1e1f146)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 26 19:26:00 2007 +0200

    make this work again

diff --git a/test/dump.c b/test/dump.c
index 96109e9..f91c4f8 100644
--- a/test/dump.c
+++ b/test/dump.c
@@ -409,6 +409,8 @@ main (int argc, char *argv[])
     g_object_unref (player);
     return 1;
   }
+  /* FIXME: HACK! */
+  swfdec_player_advance (player, 0);
   s = (SwfdecSwfDecoder *) SWFDEC_MOVIE (player->roots->data)->swf->decoder;
   if (swfdec_player_get_rate (player) == 0 || 
       !SWFDEC_IS_SWF_DECODER (s)) {
diff-tree 35f50913a304a1888c1f8d215c3d9f1cf1e1f146 (from 9490205e6f41fe442872a583d4170d3f25c5a0b4)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 26 19:24:08 2007 +0200

    This test is completely useless now

diff --git a/test/Makefile.am b/test/Makefile.am
index f0a0409..8f74f60 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -3,17 +3,14 @@ SUBDIRS = image sound trace various
 
 if WITH_GTK
 noinst_LTLIBRARIES = libswfedit.la
-noinst_PROGRAMS = swfdec-extract dump parse swfedit swfscript
+noinst_PROGRAMS = swfdec-extract dump swfedit swfscript
 else
-noinst_PROGRAMS = swfdec-extract dump parse 
+noinst_PROGRAMS = swfdec-extract dump
 endif
 
 dump_CFLAGS = $(GLOBAL_CFLAGS) $(SWFDEC_CFLAGS) $(CAIRO_CFLAGS) $(PANGO_CFLAGS)
 dump_LDFLAGS = $(SWFDEC_LIBS) $(CAIRO_LIBS) $(PANGO_LIBS)
 
-parse_CFLAGS = $(GLOBAL_CFLAGS) $(SWFDEC_CFLAGS) $(CAIRO_CFLAGS)
-parse_LDFLAGS = $(SWFDEC_LIBS) $(CAIRO_LIBS)
-
 swfdec_extract_CFLAGS = $(GLOBAL_CFLAGS) $(SWFDEC_CFLAGS) $(CAIRO_CFLAGS)
 swfdec_extract_LDFLAGS = $(SWFDEC_LIBS) $(CAIRO_LIBS)
 
diff --git a/test/parse.c b/test/parse.c
deleted file mode 100644
index 48bbd2f..0000000
--- a/test/parse.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Swfdec
- * Copyright (C) 2003-2006 David Schleef <ds at schleef.org>
- *		 2005-2006 Eric Anholt <eric at anholt.net>
- *		      2006 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <libswfdec/swfdec.h>
-
-int
-main (int argc, char *argv[])
-{
-  SwfdecPlayer *player;
-
-  swfdec_init ();
-
-  if (argc < 2){
-    g_print ("usage: %s FILENAME\n", argv[0]);
-    return 0;
-  }
-
-  player = swfdec_player_new_from_file (argv[1]);
-  if (!swfdec_player_is_initialized (player)) {
-    g_printerr ("Error parsing file \"%s\"\n", argv[1]);
-    g_object_unref (player);
-    player = NULL;
-    return 1;
-  }
-
-  g_object_unref (player);
-  player = NULL;
-
-  return 0;
-}
-
diff-tree 9490205e6f41fe442872a583d4170d3f25c5a0b4 (from 9f317479647298bbf1e720eb9c253a1d133d5744)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 26 19:23:08 2007 +0200

    rename since we have to do one iteration more

diff --git a/test/sound/adpcm-2-2.swf.0.0.raw b/test/sound/adpcm-2-2.swf.0.0.raw
deleted file mode 100644
index f959559..0000000
Binary files a/test/sound/adpcm-2-2.swf.0.0.raw and /dev/null differ
diff --git a/test/sound/adpcm-2-2.swf.1.0.raw b/test/sound/adpcm-2-2.swf.1.0.raw
new file mode 100644
index 0000000..f959559
Binary files /dev/null and b/test/sound/adpcm-2-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-2.swf.0.0.raw b/test/sound/adpcm-2.swf.0.0.raw
deleted file mode 100644
index 20cbd37..0000000
Binary files a/test/sound/adpcm-2.swf.0.0.raw and /dev/null differ
diff --git a/test/sound/adpcm-2.swf.1.0.raw b/test/sound/adpcm-2.swf.1.0.raw
new file mode 100644
index 0000000..20cbd37
Binary files /dev/null and b/test/sound/adpcm-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-3-2.swf.0.0.raw b/test/sound/adpcm-3-2.swf.0.0.raw
deleted file mode 100644
index a8de755..0000000
Binary files a/test/sound/adpcm-3-2.swf.0.0.raw and /dev/null differ
diff --git a/test/sound/adpcm-3-2.swf.1.0.raw b/test/sound/adpcm-3-2.swf.1.0.raw
new file mode 100644
index 0000000..a8de755
Binary files /dev/null and b/test/sound/adpcm-3-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-3.swf.0.0.raw b/test/sound/adpcm-3.swf.0.0.raw
deleted file mode 100644
index 0f1a834..0000000
Binary files a/test/sound/adpcm-3.swf.0.0.raw and /dev/null differ
diff --git a/test/sound/adpcm-3.swf.1.0.raw b/test/sound/adpcm-3.swf.1.0.raw
new file mode 100644
index 0000000..0f1a834
Binary files /dev/null and b/test/sound/adpcm-3.swf.1.0.raw differ
diff --git a/test/sound/adpcm-4-2.swf.0.0.raw b/test/sound/adpcm-4-2.swf.0.0.raw
deleted file mode 100644
index 2bc89ef..0000000
Binary files a/test/sound/adpcm-4-2.swf.0.0.raw and /dev/null differ
diff --git a/test/sound/adpcm-4-2.swf.1.0.raw b/test/sound/adpcm-4-2.swf.1.0.raw
new file mode 100644
index 0000000..2bc89ef
Binary files /dev/null and b/test/sound/adpcm-4-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-4.swf.0.0.raw b/test/sound/adpcm-4.swf.0.0.raw
deleted file mode 100644
index 1e8c6f4..0000000
Binary files a/test/sound/adpcm-4.swf.0.0.raw and /dev/null differ
diff --git a/test/sound/adpcm-4.swf.1.0.raw b/test/sound/adpcm-4.swf.1.0.raw
new file mode 100644
index 0000000..1e8c6f4
Binary files /dev/null and b/test/sound/adpcm-4.swf.1.0.raw differ
diff --git a/test/sound/adpcm-5-2.swf.0.0.raw b/test/sound/adpcm-5-2.swf.0.0.raw
deleted file mode 100644
index f57feb4..0000000
Binary files a/test/sound/adpcm-5-2.swf.0.0.raw and /dev/null differ
diff --git a/test/sound/adpcm-5-2.swf.1.0.raw b/test/sound/adpcm-5-2.swf.1.0.raw
new file mode 100644
index 0000000..f57feb4
Binary files /dev/null and b/test/sound/adpcm-5-2.swf.1.0.raw differ
diff --git a/test/sound/adpcm-5.swf.0.0.raw b/test/sound/adpcm-5.swf.0.0.raw
deleted file mode 100644
index cc4c44b..0000000
Binary files a/test/sound/adpcm-5.swf.0.0.raw and /dev/null differ
diff --git a/test/sound/adpcm-5.swf.1.0.raw b/test/sound/adpcm-5.swf.1.0.raw
new file mode 100644
index 0000000..cc4c44b
Binary files /dev/null and b/test/sound/adpcm-5.swf.1.0.raw differ
diff-tree 9f317479647298bbf1e720eb9c253a1d133d5744 (from d1ca3601102b10b5d64f03eed69d1634b193d7dd)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 26 19:20:22 2007 +0200

    remove debugging g_print()s

diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 2b14e51..a20bcb7 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -492,7 +492,6 @@ swfdec_player_add_external_action (Swfde
     }
     player->external_timeout.callback = swfdec_player_trigger_external_actions;
     swfdec_player_add_timeout (player, &player->external_timeout);
-    g_print ("adding at time %lu\n", (gulong) SWFDEC_TICKS_TO_MSECS (player->time));
   }
 }
 
diff --git a/test/trace/trace.c b/test/trace/trace.c
index 65a4c5b..f42fb0f 100644
--- a/test/trace/trace.c
+++ b/test/trace/trace.c
@@ -133,7 +133,6 @@ run_test (gpointer testp, gpointer unuse
     /* FIXME: will not do 10 iterations if there's other stuff loaded */
     glong advance = swfdec_player_get_next_event (player);
 
-    g_print ("advancing %ld (of %lu left)\n", advance, time_left);
     g_assert (advance >= 0);
     if (inter) {
       int t = swfdec_interaction_get_next_event (inter);
diff-tree d1ca3601102b10b5d64f03eed69d1634b193d7dd (from 01235ec735043322af3c5be841275b87858d6831)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 26 19:18:50 2007 +0200

    port to new get_next_event()

diff --git a/libswfdec-gtk/swfdec_source.c b/libswfdec-gtk/swfdec_source.c
index 59f0d85..471b99b 100644
--- a/libswfdec-gtk/swfdec_source.c
+++ b/libswfdec-gtk/swfdec_source.c
@@ -49,7 +49,7 @@ swfdec_iterate_get_msecs_to_next_event (
 
   g_assert (source->player);
   diff = swfdec_player_get_next_event (source->player);
-  if (diff == 0)
+  if (diff == -1)
     return G_MAXLONG;
   diff *= source->speed;
   g_source_get_current_time (source_, &now);
diff-tree 01235ec735043322af3c5be841275b87858d6831 (from 72645a85fb17deead8c16e0ab261408f7db5feee)
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 26 19:06:54 2007 +0200

    rework initialization code
    
    swfdec_player_set_loader() no longer calls into the script engine but requires
    a call to swfdec_player_advance() now.
    swfdec_player_advance in turn was changed to allow triggering timeouts
    immediately. So if something external happens, it can happen _now_ and not
    _almost now_, as it was before.
    There's some unfortunate side effects:
    1) swfdec_player_get_next_event() can now return 0 which was reserved for
       "nothing is happening" before. TO cope with that, it returns a signed long
       now where a return value of -1 indicates this.
    2) It is no longer possible to detect if the file can be played by Swfdec
       directly after calling swfdec_player_set_loader(), since the player will
       never be initialized by then.

diff --git a/libswfdec/swfdec_marshal.list b/libswfdec/swfdec_marshal.list
index ce6782c..86ab787 100644
--- a/libswfdec/swfdec_marshal.list
+++ b/libswfdec/swfdec_marshal.list
@@ -2,4 +2,4 @@ BOOLEAN:DOUBLE,DOUBLE,INT
 BOOLEAN:UINT,UINT,BOOLEAN
 VOID:DOUBLE,DOUBLE,DOUBLE,DOUBLE
 VOID:STRING,STRING
-VOID:UINT,UINT
+VOID:ULONG,UINT
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 7c70cf8..2b14e51 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -240,7 +240,7 @@ swfdec_player_get_next_event_time (Swfde
   if (player->timeouts) {
     return ((SwfdecTimeout *) player->timeouts->data)->timestamp - player->time;
   } else {
-    return 0;
+    return G_MAXUINT64;
   }
 }
 
@@ -277,7 +277,7 @@ swfdec_player_add_timeout (SwfdecPlayer 
 
   g_return_if_fail (SWFDEC_IS_PLAYER (player));
   g_return_if_fail (timeout != NULL);
-  g_return_if_fail (timeout->timestamp > player->time);
+  g_return_if_fail (timeout->timestamp >= player->time);
   g_return_if_fail (timeout->callback != NULL);
 
   SWFDEC_LOG ("adding timeout %p in %"G_GUINT64_FORMAT" msecs", timeout, 
@@ -478,11 +478,21 @@ swfdec_player_add_external_action (Swfde
   action->func = action_func;
   action->data = action_data;
   if (!player->external_timeout.callback) {
-    /* trigger execution immediately, but at least 100ms after the last external timeout */
-    player->external_timeout.timestamp = MAX (player->time + 1,
-	player->external_timeout.timestamp + SWFDEC_MSECS_TO_TICKS (100));
+    /* trigger execution immediately.
+     * But if initialized, keep at least 100ms from when the last external 
+     * timeout triggered. This is a crude method to get around infinite loops
+     * when script actions executed by external actions trigger another external
+     * action that would execute instantly.
+     */
+    if (player->initialized) {
+      player->external_timeout.timestamp = MAX (player->time,
+	  player->external_timeout.timestamp + SWFDEC_MSECS_TO_TICKS (100));
+    } else {
+      player->external_timeout.timestamp = player->time;
+    }
     player->external_timeout.callback = swfdec_player_trigger_external_actions;
     swfdec_player_add_timeout (player, &player->external_timeout);
+    g_print ("adding at time %lu\n", (gulong) SWFDEC_TICKS_TO_MSECS (player->time));
   }
 }
 
@@ -1096,7 +1106,7 @@ swfdec_player_iterate (SwfdecTimeout *ti
 }
 
 static void
-swfdec_player_do_advance (SwfdecPlayer *player, guint msecs, guint audio_samples)
+swfdec_player_do_advance (SwfdecPlayer *player, gulong msecs, guint audio_samples)
 {
   GList *walk;
   SwfdecAudio *audio;
@@ -1106,7 +1116,7 @@ swfdec_player_do_advance (SwfdecPlayer *
   
   swfdec_player_lock (player);
   target_time = player->time + SWFDEC_MSECS_TO_TICKS (msecs);
-  SWFDEC_DEBUG ("advancing %u msecs (%u audio frames)", msecs, audio_samples);
+  SWFDEC_DEBUG ("advancing %lu msecs (%u audio frames)", msecs, audio_samples);
 
   player->audio_skip = audio_samples;
   /* iterate all playing sounds */
@@ -1275,8 +1285,8 @@ swfdec_player_class_init (SwfdecPlayerCl
       g_param_spec_enum ("mouse-cursor", "mouse cursor", "how the mouse pointer should be presented",
 	  SWFDEC_TYPE_MOUSE_CURSOR, SWFDEC_MOUSE_CURSOR_NONE, G_PARAM_READABLE));
   g_object_class_install_property (object_class, PROP_NEXT_EVENT,
-      g_param_spec_uint ("next-event", "next event", "how many milliseconds until the next event or 0 when no event pending",
-	  0, G_MAXUINT, 0, G_PARAM_READABLE));
+      g_param_spec_long ("next-event", "next event", "how many milliseconds until the next event or 0 when no event pending",
+	  -1, G_MAXLONG, -1, G_PARAM_READABLE));
   g_object_class_install_property (object_class, PROP_CACHE_SIZE,
       g_param_spec_uint ("cache-size", "cache size", "maximum cache size in bytes",
 	  0, G_MAXUINT, 50 * 1024 * 1024, G_PARAM_READABLE));
@@ -1321,8 +1331,8 @@ swfdec_player_class_init (SwfdecPlayerCl
    */
   signals[ADVANCE] = g_signal_new ("advance", G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (SwfdecPlayerClass, advance), 
-      NULL, NULL, swfdec_marshal_VOID__UINT_UINT,
-      G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+      NULL, NULL, swfdec_marshal_VOID__ULONG_UINT,
+      G_TYPE_NONE, 2, G_TYPE_ULONG, G_TYPE_UINT);
   /**
    * SwfdecPlayer::handle-key:
    * @player: the #SwfdecPlayer affected
@@ -1601,7 +1611,7 @@ swfdec_player_initialize (SwfdecPlayer *
   player->internal_height = player->stage_height >=0 ? (guint) player->stage_height : player->height;
   player->initialized = TRUE;
   if (rate) {
-    player->iterate_timeout.timestamp = player->time + SWFDEC_TICKS_PER_SECOND * 256 / rate;
+    player->iterate_timeout.timestamp = player->time;
     swfdec_player_add_timeout (player, &player->iterate_timeout);
     SWFDEC_LOG ("initialized iterate timeout %p to %"G_GUINT64_FORMAT" (now %"G_GUINT64_FORMAT")",
 	&player->iterate_timeout, player->iterate_timeout.timestamp, player->time);
@@ -1709,24 +1719,18 @@ swfdec_player_set_loader (SwfdecPlayer *
  * been set on @player yet.
  * If the @variables are set and validate, they will be set as properties on the 
  * root movie. 
- * <note>If you want to capture events during the setup process, you want to 
- * connect your signal handlers before calling swfdec_player_set_loader() and
- * not use conveniencse functions such as swfdec_player_new_from_file().</note>
  **/
 void
 swfdec_player_set_loader_with_variables (SwfdecPlayer *player, SwfdecLoader *loader,
     const char *variables)
 {
   g_return_if_fail (SWFDEC_IS_PLAYER (player));
-  g_return_if_fail (player->roots == NULL);
+  g_return_if_fail (player->loader == NULL);
   g_return_if_fail (SWFDEC_IS_LOADER (loader));
 
-  swfdec_player_lock (player);
   player->loader = loader;
   g_object_ref (loader);
   swfdec_player_add_level_from_loader (player, 0, loader, variables);
-  swfdec_player_perform_external_actions (player);
-  swfdec_player_unlock (player);
 }
 
 /**
@@ -1934,11 +1938,10 @@ swfdec_player_render (SwfdecPlayer *play
  * often as the SwfdecPlayer::next-event property indicates.
  **/
 void
-swfdec_player_advance (SwfdecPlayer *player, guint msecs)
+swfdec_player_advance (SwfdecPlayer *player, gulong msecs)
 {
   guint frames;
   g_return_if_fail (SWFDEC_IS_PLAYER (player));
-  g_return_if_fail (msecs > 0);
 
   frames = SWFDEC_TICKS_TO_SAMPLES (player->time + SWFDEC_MSECS_TO_TICKS (msecs))
     - SWFDEC_TICKS_TO_SAMPLES (player->time);
@@ -1972,9 +1975,9 @@ swfdec_player_is_initialized (SwfdecPlay
  * Queries how long to the next event. This is the next time when you should 
  * call swfdec_player_advance() to forward to.
  *
- * Returns: number of milliseconds until next event or 0 if no outstanding event
+ * Returns: number of milliseconds until next event or -1 if no outstanding event
  **/
-guint
+glong
 swfdec_player_get_next_event (SwfdecPlayer *player)
 {
   SwfdecTick tick;
@@ -1983,9 +1986,10 @@ swfdec_player_get_next_event (SwfdecPlay
   g_return_val_if_fail (SWFDEC_IS_PLAYER (player), 0);
 
   tick = swfdec_player_get_next_event_time (player);
-  ret = SWFDEC_TICKS_TO_MSECS (tick);
-  if (tick % (SWFDEC_TICKS_PER_SECOND / 1000))
-    ret++;
+  if (tick == G_MAXUINT64)
+    return -1;
+  /* round up to full msecs */
+  ret = SWFDEC_TICKS_TO_MSECS (tick + SWFDEC_TICKS_PER_SECOND / 1000 - 1); 
 
   return ret;
 }
diff --git a/libswfdec/swfdec_player.h b/libswfdec/swfdec_player.h
index aba2b62..357bb54 100644
--- a/libswfdec/swfdec_player.h
+++ b/libswfdec/swfdec_player.h
@@ -77,7 +77,7 @@ void		swfdec_player_set_loader_with_vari
 						 const char *	variables);
 
 gboolean	swfdec_player_is_initialized	(SwfdecPlayer *	player);
-guint		swfdec_player_get_next_event  	(SwfdecPlayer *	player);
+glong		swfdec_player_get_next_event  	(SwfdecPlayer *	player);
 double		swfdec_player_get_rate		(SwfdecPlayer *	player);
 void		swfdec_player_get_image_size	(SwfdecPlayer *	player,
 						 int *		width,
@@ -107,7 +107,7 @@ void		swfdec_player_render		(SwfdecPlaye
 						 double		width,
 						 double		height);
 void		swfdec_player_advance		(SwfdecPlayer *	player,
-						 guint		msecs);
+						 gulong		msecs);
 gboolean	swfdec_player_handle_mouse	(SwfdecPlayer *	player, 
 						 double		x,
 						 double		y,
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index 858c6eb..9153aae 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -125,7 +125,7 @@ struct _SwfdecPlayerClass
   SwfdecAsContextClass	context_class;
 
   void			(* advance)		(SwfdecPlayer *		player,
-						 guint			msecs,
+						 gulong			msecs,
 						 guint			audio_samples);
   gboolean		(* handle_key)		(SwfdecPlayer *		player,
 						 guint			key,
diff --git a/test/trace/netstream-load-loop-6.swf.trace b/test/trace/netstream-load-loop-6.swf.trace
index 45634b3..294ee20 100644
--- a/test/trace/netstream-load-loop-6.swf.trace
+++ b/test/trace/netstream-load-loop-6.swf.trace
@@ -7,6 +7,7 @@ hey
 hey
 hey
 hey
+hey
 ho
 hey
 hey
diff --git a/test/trace/netstream-load-loop-7.swf.trace b/test/trace/netstream-load-loop-7.swf.trace
index 45634b3..294ee20 100644
--- a/test/trace/netstream-load-loop-7.swf.trace
+++ b/test/trace/netstream-load-loop-7.swf.trace
@@ -7,6 +7,7 @@ hey
 hey
 hey
 hey
+hey
 ho
 hey
 hey
diff --git a/test/trace/netstream-load-loop-8.swf.trace b/test/trace/netstream-load-loop-8.swf.trace
index 45634b3..294ee20 100644
--- a/test/trace/netstream-load-loop-8.swf.trace
+++ b/test/trace/netstream-load-loop-8.swf.trace
@@ -7,6 +7,7 @@ hey
 hey
 hey
 hey
+hey
 ho
 hey
 hey
diff --git a/test/trace/trace.c b/test/trace/trace.c
index 03d57cc..65a4c5b 100644
--- a/test/trace/trace.c
+++ b/test/trace/trace.c
@@ -79,13 +79,19 @@ fscommand_cb (SwfdecPlayer *player, cons
 }
 
 static void
+initialized_cb (SwfdecPlayer *player, GParamSpec *pspec, gulong *time_left)
+{
+  *time_left = ceil (10000 / swfdec_player_get_rate (player));
+}
+
+static void
 run_test (gpointer testp, gpointer unused)
 {
   Test *test = testp;
   SwfdecLoader *loader;
   SwfdecPlayer *player;
   SwfdecBuffer *buffer;
-  guint time_left;
+  gulong time_left = G_MAXULONG;
   char *str;
   GString *string, *output;
   GError *error = NULL;
@@ -105,11 +111,6 @@ run_test (gpointer testp, gpointer unuse
   g_signal_connect (player, "trace", G_CALLBACK (trace_cb), string);
   g_signal_connect (player, "fscommand", G_CALLBACK (fscommand_cb), &quit);
   swfdec_player_set_loader (player, loader);
-  if (!swfdec_player_is_initialized (player)) {
-    g_string_append_printf (output, "  ERROR: player is not initialized\n");
-    g_object_unref (player);
-    goto fail;
-  }
   str = g_strdup_printf ("%s.act", test->filename);
   if (g_file_test (str, G_FILE_TEST_EXISTS)) {
     inter = swfdec_interaction_new_from_file (str, &error);
@@ -122,7 +123,7 @@ run_test (gpointer testp, gpointer unuse
     }
     time_left = swfdec_interaction_get_duration (inter);
   } else {
-    time_left = ceil (10000 / swfdec_player_get_rate (player));
+    g_signal_connect (player, "notify::initialized", G_CALLBACK (initialized_cb), &time_left);
     inter = NULL;
   }
   g_free (str);
@@ -130,17 +131,19 @@ run_test (gpointer testp, gpointer unuse
   /* FIXME: Make the number of iterations configurable? */
   while (quit == FALSE) {
     /* FIXME: will not do 10 iterations if there's other stuff loaded */
-    guint advance = swfdec_player_get_next_event (player);
+    glong advance = swfdec_player_get_next_event (player);
 
+    g_print ("advancing %ld (of %lu left)\n", advance, time_left);
+    g_assert (advance >= 0);
     if (inter) {
       int t = swfdec_interaction_get_next_event (inter);
       g_assert (t >= 0);
-      advance = MIN (advance, (guint) t);
+      advance = MIN (advance, t);
     }
-    if (advance > time_left)
+    if ((guint) advance > time_left)
       break;
-    swfdec_player_advance (player, advance);
     time_left -= advance;
+    swfdec_player_advance (player, advance);
     if (inter) {
       swfdec_interaction_advance (inter, player, advance);
       if (time_left == 0)
diff-tree 72645a85fb17deead8c16e0ab261408f7db5feee (from parents)
Merge: 8d18a4a8ed4116df50047ba30345cebff1804d64 9c493afbf731e5bf31f2be58fde29c29f8cc453d
Author: Benjamin Otte <otte at gnome.org>
Date:   Sun Aug 26 15:32:50 2007 +0200

    Merge branch 'master' into new-init

diff-tree 8d18a4a8ed4116df50047ba30345cebff1804d64 (from d4d5dde0824487576861912640d9bdd0d0565af7)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Aug 23 22:34:01 2007 +0200

    first try in getting movie initialization order correct

diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 21a98c6..5bce6fa 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -492,6 +492,41 @@ swfdec_sprite_movie_do_enter_frame (gpoi
 }
 
 static void
+swfdec_sprite_movie_do_init_movie (SwfdecSpriteMovie *movie)
+{
+  SwfdecMovie *mov = SWFDEC_MOVIE (movie);
+  SwfdecAsContext *context = SWFDEC_AS_OBJECT (movie)->context;
+  SwfdecAsObject *constructor = NULL;
+
+  g_assert (mov->swf != NULL);
+
+  if (movie->sprite) {
+    const char *name;
+
+    g_assert (movie->sprite->parse_frame > 0);
+    movie->n_frames = movie->sprite->n_frames;
+    name = swfdec_swf_instance_get_export_name (mov->swf,
+	SWFDEC_CHARACTER (movie->sprite));
+    if (name != NULL) {
+      name = swfdec_as_context_get_string (context, name);
+      constructor = swfdec_player_get_export_class (SWFDEC_PLAYER (context),
+	  name);
+    }
+  }
+  if (constructor == NULL)
+    constructor = SWFDEC_PLAYER (context)->MovieClip;
+
+  swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), constructor);
+}
+
+static void
+swfdec_sprite_movie_init_movie (SwfdecMovie *movie)
+{
+  swfdec_sprite_movie_do_init_movie (SWFDEC_SPRITE_MOVIE (movie)); 
+  swfdec_sprite_movie_goto (SWFDEC_SPRITE_MOVIE (movie), 1);
+}
+
+static void
 swfdec_sprite_movie_iterate (SwfdecMovie *mov)
 {
   SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
@@ -501,6 +536,9 @@ swfdec_sprite_movie_iterate (SwfdecMovie
   if (mov->will_be_removed)
     return;
 
+  if (movie->sprite != NULL && movie->frame == 0)
+    swfdec_sprite_movie_do_init_movie (movie);
+
   swfdec_player_add_action (player, movie, swfdec_sprite_movie_do_enter_frame, NULL);
   if (movie->playing && movie->sprite != NULL) {
     if (movie->frame == movie->n_frames)
@@ -588,38 +626,6 @@ new_decoder:
 }
 
 static void
-swfdec_sprite_movie_init_movie (SwfdecMovie *mov)
-{
-  SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
-  SwfdecAsContext *context = SWFDEC_AS_OBJECT (movie)->context;
-  SwfdecAsObject *constructor = NULL;
-
-  g_assert (mov->swf != NULL);
-
-  if (movie->sprite) {
-    const char *name;
-
-    g_assert (movie->sprite->parse_frame > 0);
-    movie->n_frames = movie->sprite->n_frames;
-    name = swfdec_swf_instance_get_export_name (mov->swf,
-	SWFDEC_CHARACTER (movie->sprite));
-    if (name != NULL) {
-      name = swfdec_as_context_get_string (context, name);
-      constructor = swfdec_player_get_export_class (SWFDEC_PLAYER (context),
-	  name);
-    }
-  }
-  if (constructor == NULL)
-    constructor = SWFDEC_PLAYER (context)->MovieClip;
-
-  swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), constructor);
-  swfdec_sprite_movie_goto (movie, 1);
-  if (!swfdec_sprite_movie_iterate_end (mov)) {
-    g_assert_not_reached ();
-  }
-}
-
-static void
 swfdec_sprite_movie_finish_movie (SwfdecMovie *mov)
 {
   SwfdecSpriteMovie *movie = SWFDEC_SPRITE_MOVIE (mov);
diff --git a/libswfdec/swfdec_swf_instance.c b/libswfdec/swfdec_swf_instance.c
index df6b252..4523f05 100644
--- a/libswfdec/swfdec_swf_instance.c
+++ b/libswfdec/swfdec_swf_instance.c
@@ -62,7 +62,6 @@ swfdec_swf_instance_loader_target_image 
   if (SWFDEC_IS_SWF_DECODER (instance->decoder)) {
     movie->sprite = SWFDEC_SWF_DECODER (instance->decoder)->main_sprite;
 
-    swfdec_movie_initialize (SWFDEC_MOVIE (movie));
     swfdec_movie_invalidate (SWFDEC_MOVIE (movie));
   } else if (SWFDEC_IS_FLV_DECODER (instance->decoder)) {
     /* nothing to do, please move along */


More information about the Swfdec mailing list