[Swfdec] 2 commits - libswfdec-gtk/swfdec_gtk_loader.c player/swfplay.c

Benjamin Otte company at kemper.freedesktop.org
Thu Nov 15 06:38:44 PST 2007


 libswfdec-gtk/swfdec_gtk_loader.c |   35 +++++++++++++++++------------------
 player/swfplay.c                  |    5 ++++-
 2 files changed, 21 insertions(+), 19 deletions(-)

New commits:
commit 78b95d4dd8818ce8ee8f6c3a01a56178d6f20f40
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Nov 15 15:35:11 2007 +0100

    add max-runtime switch to set maximum runtime. Set default runtime to 0

diff --git a/player/swfplay.c b/player/swfplay.c
index 7a0985b..79978be 100644
--- a/player/swfplay.c
+++ b/player/swfplay.c
@@ -103,6 +103,7 @@ main (int argc, char *argv[])
 {
   int delay = 0;
   int speed = 100;
+  int max_runtime = 0;
   SwfdecLoader *loader;
   SwfdecPlayer *player;
   GError *error = NULL;
@@ -117,6 +118,7 @@ main (int argc, char *argv[])
     { "always-gc", 'g', 0, G_OPTION_ARG_NONE, &gc, "run the garbage collector as often as possible", NULL },
     { "delay", 'd', 0, G_OPTION_ARG_INT, &delay, "make loading of resources take time", "SECS" },
     { "image", 'i', 0, G_OPTION_ARG_NONE, &use_image, "use an intermediate image surface for drawing", NULL },
+    { "max-runtime", 0, 0, G_OPTION_ARG_INT, &max_runtime, "maximum time scripts run before aborting the player", "SECS" },
     { "no-scripts", 0, 0, G_OPTION_ARG_NONE, &no_scripts, "don't execute scripts affecting the application", NULL },
     { "no-sound", 'n', 0, G_OPTION_ARG_NONE, &no_sound, "don't play sound", NULL },
     { "redraws", 'r', 0, G_OPTION_ARG_NONE, &redraws, "show redraw regions", NULL },
@@ -157,7 +159,8 @@ main (int argc, char *argv[])
   loop = g_main_loop_new (NULL, TRUE);
   player = swfdec_gtk_player_new (NULL);
   /* this allows the player to continue fine when running in gdb */
-  swfdec_player_set_maximum_runtime (player, 0);
+  if (max_runtime >= 0)
+    swfdec_player_set_maximum_runtime (player, max_runtime * 1000);
   if (gc)
     g_object_set (player, "memory-until-gc", (gulong) 0, NULL);
   if (trace)
commit 2fdcae01caf5f937d99b0205273778d70ac998cb
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Nov 15 15:33:24 2007 +0100

    set size only once

diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index fb93cf9..92f01f7 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -75,6 +75,22 @@ G_DEFINE_TYPE (SwfdecGtkLoader, swfdec_gtk_loader, SWFDEC_TYPE_FILE_LOADER)
 
 #ifdef HAVE_HTTP
 static void
+swfdec_gtk_loader_set_size (SwfdecGtkLoader *gtk)
+{
+  const char *s = soup_message_get_header (gtk->message->response_headers, "Content-Length");
+  unsigned long l;
+  char *end;
+
+  if (s == NULL)
+    return;
+
+  errno = 0;
+  l = strtoul (s, &end, 10);
+  if (errno == 0 && *end == 0 && l <= G_MAXLONG)
+    swfdec_loader_set_size (SWFDEC_LOADER (gtk), l);
+}
+
+static void
 swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk)
 {
   char *real_uri;
@@ -83,6 +99,7 @@ swfdec_gtk_loader_ensure_open (SwfdecGtkLoader *gtk)
     return;
 
   real_uri = soup_uri_to_string (soup_message_get_uri (gtk->message), FALSE);
+  swfdec_gtk_loader_set_size (gtk);
   swfdec_loader_open (SWFDEC_LOADER (gtk), real_uri);
   gtk->opened = TRUE;
   g_free (real_uri);
@@ -101,22 +118,6 @@ swfdec_gtk_loader_push (SoupMessage *msg, gpointer loader)
 }
 
 static void
-swfdec_gtk_loader_headers (SoupMessage *msg, gpointer loader)
-{
-  const char *s = soup_message_get_header (msg->response_headers, "Content-Length");
-  unsigned long l;
-  char *end;
-
-  if (s == NULL)
-    return;
-
-  errno = 0;
-  l = strtoul (s, &end, 10);
-  if (errno == 0 && *end == 0 && l <= G_MAXLONG)
-    swfdec_loader_set_size (loader, l);
-}
-
-static void
 swfdec_gtk_loader_finished (SoupMessage *msg, gpointer loader)
 {
   if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
@@ -136,7 +137,6 @@ swfdec_gtk_loader_dispose (GObject *object)
 
   if (gtk->message) {
     g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_push, gtk);
-    g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_headers, gtk);
     g_signal_handlers_disconnect_by_func (gtk->message, swfdec_gtk_loader_finished, gtk);
     g_object_unref (gtk->message);
     gtk->message = NULL;
@@ -166,7 +166,6 @@ swfdec_gtk_loader_load (SwfdecLoader *loader, SwfdecLoader *parent,
 	swfdec_url_get_url (url));
     soup_message_set_flags (gtk->message, SOUP_MESSAGE_OVERWRITE_CHUNKS);
     g_signal_connect (gtk->message, "got-chunk", G_CALLBACK (swfdec_gtk_loader_push), gtk);
-    g_signal_connect (gtk->message, "got-headers", G_CALLBACK (swfdec_gtk_loader_headers), gtk);
     g_signal_connect (gtk->message, "finished", G_CALLBACK (swfdec_gtk_loader_finished), gtk);
     if (data)
       soup_message_set_request (gtk->message, "appliation/x-www-urlencoded",


More information about the Swfdec mailing list