[Swfdec] 11 commits - libswfdec-gtk/swfdec_gtk_loader.c
libswfdec-gtk/swfdec_playback_alsa.c
libswfdec-gtk/swfdec_source.c libswfdec/swfdec_cached.c
libswfdec/swfdec_font.c libswfdec/swfdec_morphshape.c
libswfdec/swfdec_net_stream.c libswfdec/swfdec_script.c
libswfdec/swfdec_video.c
Benjamin Otte
company at kemper.freedesktop.org
Tue Apr 3 01:07:10 PDT 2007
libswfdec-gtk/swfdec_gtk_loader.c | 10 ++++++++--
libswfdec-gtk/swfdec_playback_alsa.c | 3 +--
libswfdec-gtk/swfdec_source.c | 32 ++++++++++++++++++++++++--------
libswfdec/swfdec_cached.c | 3 +--
libswfdec/swfdec_font.c | 19 ++++++++++++++-----
libswfdec/swfdec_morphshape.c | 10 ++++++++--
libswfdec/swfdec_net_stream.c | 3 ++-
libswfdec/swfdec_script.c | 8 +++++---
libswfdec/swfdec_video.c | 9 ++++++---
9 files changed, 69 insertions(+), 28 deletions(-)
New commits:
diff-tree 7495e883f55098c1b6cb22873cb6ac2bd99052e7 (from 35b8ff9083919b168d2090d4ccf72aa5cec99538)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Apr 3 10:06:59 2007 +0200
get rid of the constant pool in swfdec_script_interpret, since we allocate it there
diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index 21c1fff..d8ce1ad 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -3022,6 +3022,10 @@ no_catch:
/* Reset sp before freeing stack slots, because our caller may GC soon. */
fp->sp = fp->spbase;
fp->spbase = NULL;
+ if (fp->constant_pool) {
+ swfdec_constant_pool_free (fp->constant_pool);
+ fp->constant_pool = NULL;
+ }
js_FreeRawStack(cx, mark);
cx->interpLevel--;
swfdec_script_unref (script);
@@ -3123,8 +3127,6 @@ swfdec_script_execute (SwfdecScript *scr
ok = swfdec_script_interpret (script, cx, &frame.rval);
js_FreeRawStack (cx, mark);
- if (frame.constant_pool)
- swfdec_constant_pool_free (frame.constant_pool);
cx->fp = oldfp;
if (oldfp) {
diff-tree 35b8ff9083919b168d2090d4ccf72aa5cec99538 (from 23af06e2fcd39f80bd13b10ee02d57eb7b0e9aee)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Mar 22 19:58:07 2007 +0000
Free the glyph array along with the font.
==24359== 580 (260 direct, 320 indirect) bytes in 3 blocks are definitely lost in loss record 70 of 101
==24359== at 0x4021620: malloc (vg_replace_malloc.c:149)
==24359== by 0x4E7BCB5: g_malloc (gmem.c:131)
==24359== by 0x4E8B887: g_slice_alloc (gslice.c:777)
==24359== by 0x4E56E38: g_array_sized_new (garray.c:94)
==24359== by 0x4E56F56: g_array_new (garray.c:86)
==24359== by 0x4044B2D: swfdec_font_init (swfdec_font.c:61)
==24359== by 0x4E35838: g_type_create_instance (gtype.c:1569)
==24359== by 0x4E1C901: g_object_constructor (gobject.c:1041)
==24359== by 0x4E1AC0A: g_object_newv (gobject.c:937)
==24359== by 0x4E1B74E: g_object_new_valist (gobject.c:981)
==24359== by 0x4E1B8FF: g_object_new (gobject.c:795)
==24359== by 0x406CE47: swfdec_swf_decoder_create_character (swfdec_swf_decoder.c:385)
Slightly misleading as the leak resolution wasn't high enough to distinguish
between g_slice_allocs.
diff --git a/libswfdec/swfdec_font.c b/libswfdec/swfdec_font.c
index 6794e0f..1b032d8 100644
--- a/libswfdec/swfdec_font.c
+++ b/libswfdec/swfdec_font.c
@@ -37,14 +37,23 @@ swfdec_font_dispose (GObject *object)
SwfdecFont * font = SWFDEC_FONT (object);
guint i;
- for (i = 0; i < font->glyphs->len; i++) {
- g_object_unref (g_array_index (font->glyphs, SwfdecFontEntry, i).shape);
+ if (font->glyphs) {
+ for (i = 0; i < font->glyphs->len; i++) {
+ g_object_unref (g_array_index (font->glyphs, SwfdecFontEntry, i).shape);
+ }
+ g_array_free (font->glyphs, TRUE);
+ font->glyphs = NULL;
}
- if (font->desc)
+ if (font->desc) {
pango_font_description_free (font->desc);
- g_free (font->name);
+ font->desc = NULL;
+ }
+ if (font->name) {
+ g_free (font->name);
+ font->name = NULL;
+ }
- G_OBJECT_CLASS (swfdec_font_parent_class)->dispose (G_OBJECT (font));
+ G_OBJECT_CLASS (swfdec_font_parent_class)->dispose (object);
}
static void
diff-tree 23af06e2fcd39f80bd13b10ee02d57eb7b0e9aee (from 9068d5785dee8a9575cbf88e8b8813a0a69d9d89)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Apr 3 09:44:35 2007 +0200
Unref the cached value when disposing the SwfdecCached.
diff --git a/libswfdec/swfdec_cached.c b/libswfdec/swfdec_cached.c
index aa6a694..b7216e6 100644
--- a/libswfdec/swfdec_cached.c
+++ b/libswfdec/swfdec_cached.c
@@ -32,7 +32,7 @@ swfdec_cached_dispose (GObject *object)
{
SwfdecCached * cached = SWFDEC_CACHED (object);
- swfdec_cached_unload (cached);
+ swfdec_cached_set_cache (cached, NULL);
G_OBJECT_CLASS (swfdec_cached_parent_class)->dispose (object);
}
@@ -54,7 +54,6 @@ void
swfdec_cached_set_cache (SwfdecCached *cached, SwfdecCache *cache)
{
g_return_if_fail (SWFDEC_IS_CACHED (cached));
- g_return_if_fail (cache != NULL);
if (cached->cache) {
if (cached->handle.unload)
diff-tree 9068d5785dee8a9575cbf88e8b8813a0a69d9d89 (from 079bedb48b51463f22ccd91ddf24a8a5a1f18618)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Mar 22 19:35:11 2007 +0000
Free the path data when disposing the morph shape.
==18759== 2,048 bytes in 2 blocks are definitely lost in loss record 83 of 101
==18759== at 0x402171B: realloc (vg_replace_malloc.c:306)
==18759== by 0x4E7BB7A: g_realloc (gmem.c:168)
==18759== by 0x40664FA: swfdec_path_ensure_size (swfdec_shape.c:72)
==18759== by 0x4066B48: swfdec_path_append (swfdec_shape.c:128)
==18759== by 0x4066C29: swfdec_shape_accumulate_one_polygon (swfdec_shape.c:472)
==18759== by 0x4067159: swfdec_shape_accumulate_one_fill (swfdec_shape.c:529)
==18759== by 0x4067583: swfdec_shape_initialize_from_sub_paths (swfdec_shape.c:580)
==18759== by 0x40680B9: tag_define_morph_shape (swfdec_shape.c:995)
==18759== by 0x406D5C2: swfdec_swf_decoder_parse (swfdec_swf_decoder.c:298)
==18759== by 0x40507DE: swfdec_loader_target_parse_default (swfdec_loadertarget.c:109)
==18759== by 0x4050ADA: swfdec_loader_target_parse (swfdec_loadertarget.c:160)
==18759== by 0x404E858: swfdec_loader_parse (swfdec_loader.c:409)
diff --git a/libswfdec/swfdec_morphshape.c b/libswfdec/swfdec_morphshape.c
index 06e8a9d..623e790 100644
--- a/libswfdec/swfdec_morphshape.c
+++ b/libswfdec/swfdec_morphshape.c
@@ -52,9 +52,15 @@ swfdec_graphic_create_movie (SwfdecGraph
static void
swfdec_morph_shape_dispose (GObject *object)
{
- SwfdecMorphShape *shape = SWFDEC_MORPH_SHAPE (object);
+ SwfdecMorphShape *morph = SWFDEC_MORPH_SHAPE (object);
+ guint i;
- g_array_free (shape->end_vecs, TRUE);
+ if (morph->end_vecs != NULL) {
+ for (i = 0; i < morph->end_vecs->len; i++)
+ g_free (g_array_index (morph->end_vecs, SwfdecShapeVec, i).path.data);
+ g_array_free (morph->end_vecs, TRUE);
+ morph->end_vecs = NULL;
+ }
G_OBJECT_CLASS (swfdec_morph_shape_parent_class)->dispose (object);
}
diff-tree 079bedb48b51463f22ccd91ddf24a8a5a1f18618 (from 0598ab8797606c967fb2087d9cfffd4be175e432)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Apr 3 09:38:33 2007 +0200
Fix minor leak of function_name.
diff --git a/libswfdec/swfdec_script.c b/libswfdec/swfdec_script.c
index 0aff14c..21c1fff 100644
--- a/libswfdec/swfdec_script.c
+++ b/libswfdec/swfdec_script.c
@@ -1680,7 +1680,7 @@ swfdec_action_define_function (JSContext
gboolean v2 = (action == 0x8e);
swfdec_bits_init_data (&bits, data, len);
- function_name = swfdec_bits_get_string (&bits);
+ function_name = swfdec_bits_skip_string (&bits);
if (function_name == NULL) {
SWFDEC_ERROR ("could not parse function name");
return JS_FALSE;
diff-tree 0598ab8797606c967fb2087d9cfffd4be175e432 (from 06570fb5489008d491213428b25be15716f6e448)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Apr 3 09:16:30 2007 +0200
fix a leak which caused whole videos to be leaked
You notice 5MB per leak at some point...
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 681e401..b0bcd4d 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -395,6 +395,7 @@ swfdec_net_stream_set_url (SwfdecNetStre
/* FIXME: use the connection once connections are implemented */
loader = swfdec_player_load (stream->player, url);
swfdec_net_stream_set_loader (stream, loader);
+ g_object_unref (loader);
}
void
diff-tree 06570fb5489008d491213428b25be15716f6e448 (from c9974a9671427543b289eb19eb556d4b890aa8c1)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Apr 3 09:03:14 2007 +0200
fix a memleak
diff --git a/libswfdec/swfdec_video.c b/libswfdec/swfdec_video.c
index f163ffd..a044606 100644
--- a/libswfdec/swfdec_video.c
+++ b/libswfdec/swfdec_video.c
@@ -119,16 +119,19 @@ swfdec_video_input_disconnect (SwfdecVid
static SwfdecVideoMovieInput *
swfdec_video_input_new (SwfdecVideo *video)
{
- SwfdecVideoInput *input = g_new0 (SwfdecVideoInput, 1);
-
+ SwfdecVideoInput *input;
+
if (video->n_frames == 0)
return NULL;
if (video->codec == NULL)
return NULL;
+ input = g_new0 (SwfdecVideoInput, 1);
if (video->codec)
input->decoder = swfdec_video_codec_init (video->codec);
- if (input->decoder == NULL)
+ if (input->decoder == NULL) {
+ g_free (input);
return NULL;
+ }
input->input.connect = swfdec_video_input_connect;
input->input.iterate = swfdec_video_input_iterate;
input->input.disconnect = swfdec_video_input_disconnect;
diff-tree c9974a9671427543b289eb19eb556d4b890aa8c1 (from 2bd12763b607d0729b0c97b7900599220d4f479c)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Apr 3 09:01:47 2007 +0200
include the file name in error messages
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index 643fb3e..4b1e57f 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -105,7 +105,10 @@ swfdec_gtk_loader_read_cb (GnomeVFSAsync
gtk->handle = NULL;
return;
} else if (result != GNOME_VFS_OK) {
- swfdec_loader_error (loader, gnome_vfs_result_to_string (result));
+ char *err = g_strdup_printf ("%s: %s", loader->url,
+ gnome_vfs_result_to_string (result));
+ swfdec_loader_error (loader, err);
+ g_free (err);
swfdec_buffer_unref (gtk->current_buffer);
gtk->current_buffer = NULL;
gnome_vfs_async_cancel (gtk->handle);
@@ -141,7 +144,10 @@ swfdec_gtk_loader_open_cb (GnomeVFSAsync
SwfdecLoader *loader = loaderp;
if (result != GNOME_VFS_OK) {
- swfdec_loader_error (loader, gnome_vfs_result_to_string (result));
+ char *err = g_strdup_printf ("%s: %s", loader->url,
+ gnome_vfs_result_to_string (result));
+ swfdec_loader_error (loader, err);
+ g_free (err);
gnome_vfs_async_cancel (gtk->handle);
gtk->handle = NULL;
return;
diff-tree 2bd12763b607d0729b0c97b7900599220d4f479c (from b3030fd82079172d16451d6c265077cc21a60802)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Apr 3 09:01:23 2007 +0200
Do not ref the player anymore
Using a refcount was a good idea when SwfdecSource was seperate. Now it's
used from the player itself, so it'll get into a refcount loop.
We use weak references instead, so it's theoretically possible to use the
source outside of a player. It'll remove itself when the player goes away.
diff --git a/libswfdec-gtk/swfdec_source.c b/libswfdec-gtk/swfdec_source.c
index f001de3..10d0f0e 100644
--- a/libswfdec-gtk/swfdec_source.c
+++ b/libswfdec-gtk/swfdec_source.c
@@ -34,7 +34,7 @@ my_time_val_difference (const GTimeVal *
typedef struct _SwfdecIterateSource SwfdecIterateSource;
struct _SwfdecIterateSource {
GSource source;
- SwfdecPlayer * player;
+ SwfdecPlayer * player; /* player we manage or NULL if player was deleted */
double speed; /* inverse playback speed (so 0.5 means double speed) */
gulong notify; /* set for iterate notifications */
GTimeVal last; /* last time */
@@ -47,6 +47,7 @@ swfdec_iterate_get_msecs_to_next_event (
GTimeVal now;
glong diff;
+ g_assert (source->player);
diff = swfdec_player_get_next_event (source->player);
if (diff == 0)
return G_MAXLONG;
@@ -62,7 +63,13 @@ swfdec_iterate_get_msecs_to_next_event (
static gboolean
swfdec_iterate_prepare (GSource *source, gint *timeout)
{
- glong diff = swfdec_iterate_get_msecs_to_next_event (source);
+ glong diff;
+
+ diff = swfdec_iterate_get_msecs_to_next_event (source);
+ if (((SwfdecIterateSource *) source)->player == NULL) {
+ *timeout = 0;
+ return TRUE;
+ }
if (diff == G_MAXLONG) {
*timeout = -1;
@@ -79,8 +86,11 @@ swfdec_iterate_prepare (GSource *source,
static gboolean
swfdec_iterate_check (GSource *source)
{
- glong diff = swfdec_iterate_get_msecs_to_next_event (source);
-
+ glong diff;
+
+ if (((SwfdecIterateSource *) source)->player == NULL)
+ return 0;
+ diff = swfdec_iterate_get_msecs_to_next_event (source);
return diff < 0;
}
@@ -88,8 +98,11 @@ static gboolean
swfdec_iterate_dispatch (GSource *source_, GSourceFunc callback, gpointer user_data)
{
SwfdecIterateSource *source = (SwfdecIterateSource *) source_;
- glong diff = swfdec_iterate_get_msecs_to_next_event (source_);
-
+ glong diff;
+
+ if (source->player == NULL)
+ return FALSE;
+ diff = swfdec_iterate_get_msecs_to_next_event (source_);
if (diff > 0)
return TRUE;
diff = swfdec_player_get_next_event (source->player) - diff;
@@ -105,7 +118,9 @@ swfdec_iterate_finalize (GSource *source
if (source->notify) {
g_signal_handler_disconnect (source->player, source->notify);
}
- g_object_unref (source->player);
+ if (source->player) {
+ g_object_remove_weak_pointer (G_OBJECT (source->player), (gpointer *) &source->player);
+ }
}
GSourceFuncs swfdec_iterate_funcs = {
@@ -132,7 +147,8 @@ swfdec_iterate_source_new (SwfdecPlayer
source = (SwfdecIterateSource *) g_source_new (&swfdec_iterate_funcs,
sizeof (SwfdecIterateSource));
- source->player = g_object_ref (player);
+ source->player = player;
+ g_object_add_weak_pointer (G_OBJECT (source->player), (gpointer *) &source->player);
source->speed = 1.0 / speed;
source->notify = g_signal_connect (player, "advance",
G_CALLBACK (swfdec_iterate_source_advance_cb), source);
diff-tree b3030fd82079172d16451d6c265077cc21a60802 (from ea7b64b68489721b867fef1edf55c809de2e2b8a)
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Apr 3 09:00:34 2007 +0200
Do not ref the player anymore
Using a refcount was a good idea when SwfdecPlayback was seperate. Now it's
used from the player itself, so it'll get into a refcount loop.
diff --git a/libswfdec-gtk/swfdec_playback_alsa.c b/libswfdec-gtk/swfdec_playback_alsa.c
index b6a2f1a..ee4da3e 100644
--- a/libswfdec-gtk/swfdec_playback_alsa.c
+++ b/libswfdec-gtk/swfdec_playback_alsa.c
@@ -318,7 +318,7 @@ swfdec_playback_open (SwfdecPlayer *play
g_return_val_if_fail (context != NULL, NULL);
sound = g_new0 (SwfdecPlayback, 1);
- sound->player = g_object_ref (player);
+ sound->player = player;
g_signal_connect (player, "advance", G_CALLBACK (advance_before), sound);
g_signal_connect (player, "audio-added", G_CALLBACK (audio_added), sound);
g_signal_connect (player, "audio-removed", G_CALLBACK (audio_removed), sound);
@@ -346,7 +346,6 @@ swfdec_playback_close (SwfdecPlayback *s
REMOVE_HANDLER (sound->player, advance_before, sound);
REMOVE_HANDLER (sound->player, audio_added, sound);
REMOVE_HANDLER (sound->player, audio_removed, sound);
- g_object_unref (sound->player);
g_main_context_unref (sound->context);
g_free (sound);
}
diff-tree ea7b64b68489721b867fef1edf55c809de2e2b8a (from cba7ba2518e522d3f695d41a7f4c8dc4d1d19da8)
Author: Benjamin Otte <otte at gnome.org>
Date: Mon Apr 2 17:38:29 2007 +0200
this debugging message is not that important
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 99363f9..681e401 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -225,7 +225,7 @@ swfdec_net_stream_loader_target_parse (S
return;
}
if (!loader->eof && swfdec_buffer_queue_get_depth (loader->queue) == 0) {
- SWFDEC_WARNING ("nothing to parse?!");
+ SWFDEC_INFO ("nothing to do");
return;
}
if (stream->flvdecoder == NULL) {
More information about the Swfdec
mailing list