[Xfce4-commits] <parole:master> Don't process uri before setting up the DBus interface to avoid zombie processes if the browser quickly unload us.
Ali Abdallah
noreply at xfce.org
Fri Nov 20 11:28:03 CET 2009
Updating branch refs/heads/master
to c3dcac56dd350beacd07bc72d2ba3f30e4c270fc (commit)
from 15a0daba86a6c6f4179f7cc1f7d0cf3d8228489b (commit)
commit c3dcac56dd350beacd07bc72d2ba3f30e4c270fc
Author: Ali Abdallah <ali at ali-xfce.org>
Date: Fri Nov 20 11:21:57 2009 +0100
Don't process uri before setting up the DBus interface to
avoid zombie processes if the browser quickly unload us.
browser-plugin/media-plugin/main.c | 4 ++
browser-plugin/media-plugin/parole-plugin-player.c | 12 +++-
browser-plugin/media-plugin/parole-plugin-player.h | 3 +
browser-plugin/plugin.cpp | 53 ++++++++++++-------
browser-plugin/plugin.h | 3 +
5 files changed, 52 insertions(+), 23 deletions(-)
diff --git a/browser-plugin/media-plugin/main.c b/browser-plugin/media-plugin/main.c
index 6722d4f..91b86d2 100644
--- a/browser-plugin/media-plugin/main.c
+++ b/browser-plugin/media-plugin/main.c
@@ -98,11 +98,15 @@ int main (int argc, char **argv)
player = parole_plugin_player_new (plug, url);
gtk_widget_show_all (plug);
+ parole_plugin_player_play (player);
+
gtk_main ();
gtk_widget_destroy (plug);
parole_dbus_release_name (dbus_name);
g_free (dbus_name);
+ g_debug ("Exiting");
+
gst_deinit ();
return EXIT_SUCCESS;
diff --git a/browser-plugin/media-plugin/parole-plugin-player.c b/browser-plugin/media-plugin/parole-plugin-player.c
index 7928a02..7f508f9 100644
--- a/browser-plugin/media-plugin/parole-plugin-player.c
+++ b/browser-plugin/media-plugin/parole-plugin-player.c
@@ -222,7 +222,7 @@ parole_plugin_player_media_state_cb (ParoleGst *gst, const ParoleStream *stream,
if ( player->priv->reload )
{
- parole_gst_play_uri (player->priv->gst, player->priv->url, NULL);
+ parole_plugin_player_play (player);
}
}
else if ( state == PAROLE_MEDIA_STATE_FINISHED )
@@ -486,8 +486,6 @@ parole_plugin_player_construct (GObject *object)
parole_plugin_player_change_range_value (player, 0);
gtk_widget_set_sensitive (player->priv->range, FALSE);
-
- parole_gst_play_uri (player->priv->gst, player->priv->url, NULL);
}
static void
@@ -602,6 +600,14 @@ parole_plugin_player_new (GtkWidget *plug, gchar *url)
return player;
}
+void parole_plugin_player_play (ParolePluginPlayer *player)
+{
+ if ( player->priv->terminate )
+ return;
+
+ parole_gst_play_uri (player->priv->gst, player->priv->url, NULL);
+}
+
static gboolean parole_plugin_player_dbus_quit (ParolePluginPlayer *player,
GError **error);
diff --git a/browser-plugin/media-plugin/parole-plugin-player.h b/browser-plugin/media-plugin/parole-plugin-player.h
index ec354c3..654f756 100644
--- a/browser-plugin/media-plugin/parole-plugin-player.h
+++ b/browser-plugin/media-plugin/parole-plugin-player.h
@@ -49,6 +49,9 @@ GType parole_plugin_player_get_type (void) G_GNUC_CONST;
ParolePluginPlayer *parole_plugin_player_new (GtkWidget *plug,
gchar *url);
+
+void parole_plugin_player_play (ParolePluginPlayer *player);
+
G_END_DECLS
#endif /* __PAROLE_PLUGIN_PLAYER_H */
diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp
index 877558f..6138a3e 100644
--- a/browser-plugin/plugin.cpp
+++ b/browser-plugin/plugin.cpp
@@ -81,16 +81,19 @@ CPlugin::CPlugin (NPP pNPInstance)
CPlugin::~CPlugin()
{
g_debug ("Destructor");
- if ( bus )
+
+ if ( !proxy )
+ GetProxy ();
+
+ if ( proxy )
{
- if ( proxy )
- {
- dbus_g_proxy_call_no_reply (proxy, "Quit",
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- }
+ dbus_g_proxy_call_no_reply (proxy, "Quit",
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ }
+
+ if ( bus )
dbus_g_connection_unref (bus);
- }
if ( url )
g_free (url);
@@ -128,6 +131,9 @@ void CPlugin::shut()
{
g_debug ("shut");
+ if ( !proxy )
+ GetProxy ();
+
if ( proxy )
{
dbus_g_proxy_call_no_reply (proxy, "Terminate",
@@ -141,6 +147,24 @@ NPBool CPlugin::isInitialized()
return mInitialized;
}
+void CPlugin::GetProxy ()
+{
+ g_return_if_fail (proxy == NULL);
+ g_return_if_fail (bus != NULL);
+
+ gchar *dbus_name;
+ dbus_name = g_strdup_printf ("org.Parole.Media.Plugin%ld", window);
+
+ proxy = dbus_g_proxy_new_for_name (bus,
+ dbus_name,
+ "/org/Parole/Media/Plugin",
+ "org.Parole.Media.Plugin");
+ if ( !proxy )
+ g_critical ("Unable to create proxy for %s", dbus_name);
+
+ g_free (dbus_name);
+}
+
NPError CPlugin::NewStream(NPMIMEType type, NPStream * stream, NPBool seekable, uint16 * stype)
{
g_debug ("New stream callback %s", stream->url);
@@ -151,7 +175,6 @@ NPError CPlugin::NewStream(NPMIMEType type, NPStream * stream, NPBool seekable,
gchar *socket;
gchar *app;
GError *error = NULL;
- gchar *dbus_name;
url = g_strdup (stream->url);
@@ -179,6 +202,7 @@ NPError CPlugin::NewStream(NPMIMEType type, NPStream * stream, NPBool seekable,
{
g_critical ("Failed to spawn command : %s", error->message);
g_error_free (error);
+ return NPERR_GENERIC_ERROR;
}
g_free (socket);
@@ -192,17 +216,6 @@ NPError CPlugin::NewStream(NPMIMEType type, NPStream * stream, NPBool seekable,
g_error_free (error);
return NPERR_GENERIC_ERROR;
}
-
- dbus_name = g_strdup_printf ("org.Parole.Media.Plugin%ld", window);
-
- proxy = dbus_g_proxy_new_for_name (bus,
- dbus_name,
- "/org/Parole/Media/Plugin",
- "org.Parole.Media.Plugin");
- if ( !proxy )
- g_critical ("Unable to create proxy for %s", dbus_name);
-
- g_free (dbus_name);
}
return NPERR_NO_ERROR;
}
diff --git a/browser-plugin/plugin.h b/browser-plugin/plugin.h
index f47d467..29234cc 100644
--- a/browser-plugin/plugin.h
+++ b/browser-plugin/plugin.h
@@ -74,6 +74,9 @@ class CPlugin {
NPError NewStream (NPMIMEType type, NPStream * stream, NPBool seekable, uint16 * stype);
NPError DestroyStream (NPStream * stream, NPError reason);
+
+ void GetProxy ();
+
private:
DBusGConnection *bus;
DBusGProxy *proxy;
More information about the Xfce4-commits
mailing list