[maemo-commits] [maemo-commits] r16670 - in projects/haf/trunk/hildon-thumbnail: . daemon daemon/plugins
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Thu Nov 13 17:59:35 EET 2008
- Previous message: [maemo-commits] r16669 - in projects/haf/trunk/gtk+: . gtk
- Next message: [maemo-commits] r16671 - projects/haf/trunk/hildon-thumbnail/daemon/plugins
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2008-11-13 17:59:32 +0200 (Thu, 13 Nov 2008) New Revision: 16670 Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/plugins/epeg-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/plugins/exec-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-jpeg-out-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-png-out-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/plugins/gstreamer-video-plugin.c projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c Log: 2008-11-13 Philip Van Hoof <philip at codeminded.be> * daemon/plugins/gdkpixbuf-plugin.c * daemon/plugins/exec-plugin.c * daemon/plugins/gdkpixbuf-png-out-plugin.c * daemon/plugins/gdkpixbuf-jpeg-out-plugin.c * daemon/plugins/gstreamer-video-plugin.c * daemon/plugins/epeg-plugin.c * daemon/thumbnailer.c * daemon/hildon-thumbnail-plugin.c: Actually unloading and loading of modules, taking into account resident modules if the module behaves as a resident one (currently only the gstreamer-video-plugin.c is a resident one, because it needs gst_init, and the function can't be executed twice without crashing ... when I last checked) Modified: projects/haf/trunk/hildon-thumbnail/ChangeLog =================================================================== --- projects/haf/trunk/hildon-thumbnail/ChangeLog 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/ChangeLog 2008-11-13 15:59:32 UTC (rev 16670) @@ -1,10 +1,25 @@ 2008-11-13 Philip Van Hoof <philip at codeminded.be> * daemon/plugins/gdkpixbuf-plugin.c + * daemon/plugins/exec-plugin.c * daemon/plugins/gdkpixbuf-png-out-plugin.c * daemon/plugins/gdkpixbuf-jpeg-out-plugin.c * daemon/plugins/gstreamer-video-plugin.c * daemon/plugins/epeg-plugin.c + * daemon/thumbnailer.c + * daemon/hildon-thumbnail-plugin.c: Actually unloading and loading of + modules, taking into account resident modules if the module behaves as + a resident one (currently only the gstreamer-video-plugin.c is a + resident one, because it needs gst_init, and the function can't be + executed twice without crashing ... when I last checked) + +2008-11-13 Philip Van Hoof <philip at codeminded.be> + + * daemon/plugins/gdkpixbuf-plugin.c + * daemon/plugins/gdkpixbuf-png-out-plugin.c + * daemon/plugins/gdkpixbuf-jpeg-out-plugin.c + * daemon/plugins/gstreamer-video-plugin.c + * daemon/plugins/epeg-plugin.c * daemon/hildon-thumbnail-plugin.c: Code cleanups 2008-11-13 Philip Van Hoof <philip at codeminded.be> Modified: projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/daemon/hildon-thumbnail-plugin.c 2008-11-13 15:59:32 UTC (rev 16670) @@ -27,22 +27,29 @@ #include "hildon-thumbnail-plugin.h" static GList *outplugs = NULL; +static GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT; typedef gboolean (*IsActiveFunc) (void); +typedef gboolean (*StopFunc) (void); -typedef void (*StopFunc) (void); - void hildon_thumbnail_outplugin_unload (GModule *module) { StopFunc stop_func; + gboolean resident = FALSE; + g_static_rec_mutex_lock (&mutex); + if (g_module_symbol (module, "hildon_thumbnail_outplugin_stop", (gpointer *) &stop_func)) { - stop_func (); + resident = stop_func (); } outplugs = g_list_remove (outplugs, module); - g_module_close (module); + + if (!resident) + g_module_close (module); + + g_static_rec_mutex_unlock (&mutex); } GModule* @@ -52,6 +59,8 @@ g_return_val_if_fail (module_name != NULL, NULL); + g_static_rec_mutex_lock (&mutex); + module = g_module_open (module_name, G_MODULE_BIND_LOCAL); if (!module) { @@ -59,10 +68,12 @@ module_name, g_module_error ()); } else { - g_module_make_resident (module); + /* g_module_make_resident (module); */ outplugs = g_list_prepend (outplugs, module); } + g_static_rec_mutex_unlock (&mutex); + return module; } @@ -87,6 +98,8 @@ GString *errors = NULL; GQuark domain; + g_static_rec_mutex_lock (&mutex); + while (copy) { GModule *module = copy->data; OutFunc out_func; @@ -119,6 +132,8 @@ g_set_error (error, domain, 0, errors->str); g_string_free (errors, TRUE); } + + g_static_rec_mutex_unlock (&mutex); } @@ -130,16 +145,20 @@ g_return_val_if_fail (module_name != NULL, NULL); + g_static_rec_mutex_lock (&mutex); + module = g_module_open (module_name, G_MODULE_BIND_LOCAL); if (!module) { g_warning ("Could not load thumbnailer module '%s', %s\n", module_name, g_module_error ()); - } else { + } /* else { g_module_make_resident (module); - } + } */ + g_static_rec_mutex_unlock (&mutex); + return module; } @@ -151,10 +170,14 @@ GStrv supported = NULL; SupportedFunc supported_func; + g_static_rec_mutex_lock (&mutex); + if (g_module_symbol (module, "hildon_thumbnail_plugin_supported", (gpointer *) &supported_func)) { supported = (supported_func) (); } + g_static_rec_mutex_unlock (&mutex); + return supported; } @@ -166,9 +189,14 @@ { InitFunc func; + g_static_rec_mutex_lock (&mutex); + if (g_module_symbol (module, "hildon_thumbnail_plugin_init", (gpointer *) &func)) { (func) (cropping, in_func, instance, module, error); } + + g_static_rec_mutex_unlock (&mutex); + } typedef void (*CreateFunc) (GStrv uris, gchar *mime_hint, GStrv *failed_uris, GError **error); @@ -177,18 +205,30 @@ hildon_thumbnail_plugin_do_create (GModule *module, GStrv uris, gchar *mime_hint, GStrv *failed_uris, GError **error) { CreateFunc func; + + g_static_rec_mutex_lock (&mutex); + if (g_module_symbol (module, "hildon_thumbnail_plugin_create", (gpointer *) &func)) { (func) (uris, mime_hint, failed_uris, error); } + + g_static_rec_mutex_unlock (&mutex); } void hildon_thumbnail_plugin_do_stop (GModule *module) { StopFunc func; + gboolean resident = FALSE; + g_static_rec_mutex_lock (&mutex); + if (g_module_symbol (module, "hildon_thumbnail_plugin_stop", (gpointer *) &func)) { - (func) (); + resident = (func) (); } - g_module_close (module); + + if (!resident) + g_module_close (module); + + g_static_rec_mutex_unlock (&mutex); } Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/epeg-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/epeg-plugin.c 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/epeg-plugin.c 2008-11-13 15:59:32 UTC (rev 16670) @@ -322,7 +322,7 @@ return; } -void +gboolean hildon_thumbnail_plugin_stop (void) { if (supported) @@ -330,6 +330,7 @@ supported = NULL; if (monitor) g_object_unref (monitor); + return FALSE; } static void Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/exec-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/exec-plugin.c 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/exec-plugin.c 2008-11-13 15:59:32 UTC (rev 16670) @@ -345,7 +345,7 @@ return; } -void +gboolean hildon_thumbnail_plugin_stop (void) { if (supported) @@ -355,6 +355,7 @@ g_object_unref (monitor); g_hash_table_unref (execs); execs = NULL; + return FALSE; } static void Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-jpeg-out-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-jpeg-out-plugin.c 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-jpeg-out-plugin.c 2008-11-13 15:59:32 UTC (rev 16670) @@ -126,11 +126,12 @@ } } -void +gboolean hildon_thumbnail_outplugin_stop (void) { if (monitor) g_object_unref (monitor); + return FALSE; } gboolean Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-plugin.c 2008-11-13 15:59:32 UTC (rev 16670) @@ -327,7 +327,7 @@ return; } -void +gboolean hildon_thumbnail_plugin_stop (void) { if (supported) @@ -335,6 +335,7 @@ if (monitor) g_object_unref (monitor); supported = NULL; + return FALSE; } static void Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-png-out-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-png-out-plugin.c 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gdkpixbuf-png-out-plugin.c 2008-11-13 15:59:32 UTC (rev 16670) @@ -152,11 +152,11 @@ } } -void -hildon_thumbnail_outplugin_stop (void) +gboolean hildon_thumbnail_outplugin_stop (void) { if (monitor) g_object_unref (monitor); + return FALSE; } gboolean Modified: projects/haf/trunk/hildon-thumbnail/daemon/plugins/gstreamer-video-plugin.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/plugins/gstreamer-video-plugin.c 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/daemon/plugins/gstreamer-video-plugin.c 2008-11-13 15:59:32 UTC (rev 16670) @@ -43,6 +43,7 @@ static gboolean do_cropped = TRUE; static gboolean do_vidthumbs = TRUE; static GFileMonitor *monitor = NULL; +static gboolean had_init = FALSE; typedef struct { const gchar *uri; @@ -468,11 +469,15 @@ } -void + +gboolean hildon_thumbnail_plugin_stop (void) { + /* gst_deinit (); */ + if (monitor) g_object_unref (monitor); + return TRUE; } static void @@ -518,13 +523,19 @@ GFile *file = g_file_new_for_path (config); guint i = 0; const gchar **supported; - + GError *nerror = NULL; /* TODO: Perhaps we can add a few remote ones here too (streaming media) */ const gchar *uri_schemes[2] = { "file", NULL }; - g_type_init (); + if (!had_init) { + g_type_init (); + gst_init_check (NULL, NULL, &nerror); - gst_init (NULL, NULL); + if (nerror) { + g_propagate_error (error, nerror); + } + had_init = TRUE; + } monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE, NULL, NULL); @@ -548,5 +559,4 @@ } g_free (config); - } Modified: projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c =================================================================== --- projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c 2008-11-13 15:44:33 UTC (rev 16669) +++ projects/haf/trunk/hildon-thumbnail/daemon/thumbnailer.c 2008-11-13 15:59:32 UTC (rev 16670) @@ -160,8 +160,11 @@ static gboolean do_delete_or_not (gpointer key, gpointer value, gpointer user_data) { - if (value == user_data) + PluginRegistration *reg = value; + + if (reg->plugin == user_data) return TRUE; + return FALSE; }
- Previous message: [maemo-commits] r16669 - in projects/haf/trunk/gtk+: . gtk
- Next message: [maemo-commits] r16671 - projects/haf/trunk/hildon-thumbnail/daemon/plugins
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]