[Swfdec-commits] 4 commits - doc/Makefile.am doc/swfdec-sections.txt swfdec/swfdec_player.c swfdec/swfdec_script.c swfdec/swfdec_sprite_movie.c swfdec/swfdec_tag.c vivified/core

Benjamin Otte company at kemper.freedesktop.org
Fri Mar 21 14:30:23 PDT 2008


 doc/Makefile.am              |    1 -
 doc/swfdec-sections.txt      |    4 ++++
 swfdec/swfdec_player.c       |    1 +
 swfdec/swfdec_script.c       |   15 +++++++++++++++
 swfdec/swfdec_sprite_movie.c |   16 +++++++++-------
 swfdec/swfdec_tag.c          |   27 ++++++++++++++++++++++++++-
 vivified/core/vivi_ming.c    |    2 +-
 7 files changed, 56 insertions(+), 10 deletions(-)

New commits:
commit f872cefb1d77bd92cfba884118cd0c54565ab2e6
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Mar 21 22:26:37 2008 +0100

    put the init scripts into the decoder's cache, too

diff --git a/swfdec/swfdec_sprite_movie.c b/swfdec/swfdec_sprite_movie.c
index 943bc15..f6bc003 100644
--- a/swfdec/swfdec_sprite_movie.c
+++ b/swfdec/swfdec_sprite_movie.c
@@ -373,8 +373,11 @@ swfdec_sprite_movie_perform_one_action (SwfdecSpriteMovie *movie, guint tag, Swf
       if (!skip_scripts) {
 	SwfdecScript *script = swfdec_swf_decoder_get_script (
 	    SWFDEC_SWF_DECODER (mov->resource->decoder), buffer->data);
-	g_assert (script);
-	swfdec_player_add_action_script (player, mov, script, 2);
+	if (script) {
+	  swfdec_player_add_action_script (player, mov, script, 2);
+	} else {
+	  SWFDEC_ERROR ("Failed to locate script for DoAction tag");
+	}
       }
       return TRUE;
     case SWFDEC_TAG_PLACEOBJECT:
@@ -447,7 +450,6 @@ swfdec_sprite_movie_perform_one_action (SwfdecSpriteMovie *movie, guint tag, Swf
       {
 	guint id;
 	SwfdecSprite *sprite;
-	char *name;
 
 	id = swfdec_bits_get_u16 (&bits);
 	SWFDEC_LOG ("InitAction");
@@ -461,12 +463,12 @@ swfdec_sprite_movie_perform_one_action (SwfdecSpriteMovie *movie, guint tag, Swf
 	  SWFDEC_ERROR ("sprite %u already has an init action", id);
 	  return TRUE;
 	}
-	name = g_strdup_printf ("InitAction %u", id);
-	sprite->init_action = swfdec_script_new_from_bits (&bits, name, 
-	    swfdec_movie_get_version (mov));
-	g_free (name);
+	sprite->init_action = swfdec_script_ref (swfdec_swf_decoder_get_script (
+	    SWFDEC_SWF_DECODER (mov->resource->decoder), buffer->data + 2));
 	if (sprite->init_action) {
 	  swfdec_player_add_action_script (player, mov, sprite->init_action, 0);
+	} else {
+	  SWFDEC_ERROR ("Failed to locate script for InitAction of Sprite %u", id);
 	}
       }
       return TRUE;
diff --git a/swfdec/swfdec_tag.c b/swfdec/swfdec_tag.c
index 1995e99..9c5b8c9 100644
--- a/swfdec/swfdec_tag.c
+++ b/swfdec/swfdec_tag.c
@@ -509,6 +509,31 @@ tag_func_do_action (SwfdecSwfDecoder * s, guint tag)
   return SWFDEC_STATUS_OK;
 }
 
+static int
+tag_func_do_init_action (SwfdecSwfDecoder * s, guint tag)
+{
+  SwfdecScript *script;
+  SwfdecBits bits;
+  char *name;
+  guint id;
+
+  bits = s->b;
+  id = swfdec_bits_get_u16 (&bits);
+  if (swfdec_bits_left (&bits) == 0) {
+    SWFDEC_WARNING ("empty script, ignoring");
+    return SWFDEC_STATUS_OK;
+  }
+  name = g_strdup_printf ("Init %u", id);
+  script = swfdec_script_new_from_bits (&bits, name, s->version);
+  g_free (name);
+  if (script) {
+    swfdec_swf_decoder_add_script (s, script);
+    tag_func_enqueue (s, tag);
+  }
+
+  return SWFDEC_STATUS_OK;
+}
+
 struct tag_func_struct
 {
   const char *name;
@@ -568,7 +593,7 @@ static struct tag_func_struct tag_funcs[] = {
   [SWFDEC_TAG_EXPORTASSETS] = {"ExportAssets", tag_func_enqueue, 0},
   [SWFDEC_TAG_IMPORTASSETS] = {"ImportAssets", NULL, 0},
   [SWFDEC_TAG_ENABLEDEBUGGER] = {"EnableDebugger", NULL, 0},
-  [SWFDEC_TAG_DOINITACTION] = {"DoInitAction", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+  [SWFDEC_TAG_DOINITACTION] = {"DoInitAction", tag_func_do_init_action, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEVIDEOSTREAM] = {"DefineVideoStream", tag_func_define_video, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_VIDEOFRAME] = {"VideoFrame", tag_func_video_frame, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEFONTINFO2] = {"DefineFontInfo2", tag_func_define_font_info, 0},
commit e558c2bbdb49a070dc93871393c182997a4ca3ad
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Mar 21 22:16:54 2008 +0100

    update to min API changes

diff --git a/vivified/core/vivi_ming.c b/vivified/core/vivi_ming.c
index a126455..c015c1a 100644
--- a/vivified/core/vivi_ming.c
+++ b/vivified/core/vivi_ming.c
@@ -88,7 +88,7 @@ vivi_ming_compile (const char *code, char **error)
 {
   byte *data;
   SWFAction action;
-  gsize len;
+  gssize len;
   SwfdecBuffer *buffer;
   SwfdecScript *script;
 
commit ab25a320be1bb7bb303c113b062486590f0cfade
Merge: 2577ca9... 9a85d37...
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Mar 21 22:01:31 2008 +0100

    Merge branch '0.6'

commit 9a85d379f1a2a45fe2ef23468970739dca4ceed7
Author: Benjamin Otte <otte at gnome.org>
Date:   Fri Mar 21 22:01:14 2008 +0100

    include swfdec_script.h in the documentation

diff --git a/doc/Makefile.am b/doc/Makefile.am
index 371c562..1c54ba9 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -122,7 +122,6 @@ IGNORE_HFILES= \
 	swfdec_root_movie.h \
 	swfdec_root_sprite.h \
 	swfdec_sandbox.h \
-	swfdec_script.h \
 	swfdec_script_internal.h \
 	swfdec_shape.h \
 	swfdec_shape_parser.h \
diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt
index e0f6649..67bb023 100644
--- a/doc/swfdec-sections.txt
+++ b/doc/swfdec-sections.txt
@@ -542,7 +542,11 @@ SWFDEC_TYPE_AS_FRAME
 <TITLE>SwfdecAsDebugger</TITLE>
 SwfdecAsDebugger
 SwfdecAsDebuggerClass
+<SUBSECTION SwfdecScript>
 SwfdecScript
+swfdec_script_new
+swfdec_script_ref
+swfdec_script_unref
 <SUBSECTION Standard>
 swfdec_as_debugger_get_type
 SWFDEC_AS_DEBUGGER
diff --git a/swfdec/swfdec_player.c b/swfdec/swfdec_player.c
index e0e8ff9..5a50c52 100644
--- a/swfdec/swfdec_player.c
+++ b/swfdec/swfdec_player.c
@@ -241,6 +241,7 @@
 
 /**
  * SWFDEC_TYPE_TIME_VAL:
+ *
  * This type wraps a @GTimeVal object as a boxed type and makes it available 
  * for use in object properties.
  */
diff --git a/swfdec/swfdec_script.c b/swfdec/swfdec_script.c
index 852b799..66eeed0 100644
--- a/swfdec/swfdec_script.c
+++ b/swfdec/swfdec_script.c
@@ -255,6 +255,14 @@ swfdec_script_new_from_bits (SwfdecBits *bits, const char *name, guint version)
   return script;
 }
 
+/**
+ * swfdec_script_ref:
+ * @script: a script
+ *
+ * Increases the reference count of the given @script by one.
+ *
+ * Returns: The @script given as an argument
+ **/
 SwfdecScript *
 swfdec_script_ref (SwfdecScript *script)
 {
@@ -265,6 +273,13 @@ swfdec_script_ref (SwfdecScript *script)
   return script;
 }
 
+/**
+ * swfdec_script_unref:
+ * @script: a script
+ *
+ * Decreases the reference count of the given @script by one. If the count 
+ * reaches zero, it will automatically be destroyed.
+ **/
 void
 swfdec_script_unref (SwfdecScript *script)
 {


More information about the Swfdec-commits mailing list