[Xfce4-commits] <parole:master> On SIGKILL setup an timeout function to check if we manager to shutdown the backend, if not just exit.
Ali Abdallah
noreply at xfce.org
Sat Nov 21 14:34:04 CET 2009
Updating branch refs/heads/master
to 57bcece4f0389963d6d8e91983017adfcf497c57 (commit)
from b4082d0e84e1f47ca48d1ca03d5990a1aac7a48c (commit)
commit 57bcece4f0389963d6d8e91983017adfcf497c57
Author: Ali Abdallah <ali at ali-xfce.org>
Date: Sat Nov 21 14:05:47 2009 +0100
On SIGKILL setup an timeout function to check if we manager to shutdown the backend,
if not just exit.
browser-plugin/media-plugin/main.c | 37 ++++++++++++++++++-
browser-plugin/media-plugin/parole-plugin-player.c | 10 ++++-
browser-plugin/media-plugin/parole-plugin-player.h | 2 +
browser-plugin/plugin.cpp | 26 ++++++++------
4 files changed, 60 insertions(+), 15 deletions(-)
diff --git a/browser-plugin/media-plugin/main.c b/browser-plugin/media-plugin/main.c
index 91b86d2..a3a8761 100644
--- a/browser-plugin/media-plugin/main.c
+++ b/browser-plugin/media-plugin/main.c
@@ -30,7 +30,8 @@
#include <signal.h>
#include <gtk/gtk.h>
-#include <glib/gi18n.h>
+
+#include <libxfcegui4/libxfcegui4.h>
#include <gst/gst.h>
@@ -38,6 +39,23 @@
#include "dbus/parole-dbus.h"
+static gulong exit_source_id = 0;
+
+static void G_GNUC_NORETURN
+force_exit (gpointer data)
+{
+ g_debug ("Forcing exit");
+ exit (0);
+}
+
+static void
+posix_signal_handler (gint sig, ParolePluginPlayer *player)
+{
+ parole_plugin_player_exit (player);
+
+ exit_source_id = g_timeout_add_seconds (4, (GSourceFunc) force_exit, NULL);
+}
+
int main (int argc, char **argv)
{
ParolePluginPlayer *player;
@@ -98,6 +116,19 @@ int main (int argc, char **argv)
player = parole_plugin_player_new (plug, url);
gtk_widget_show_all (plug);
+ if ( xfce_posix_signal_handler_init (&error))
+ {
+ xfce_posix_signal_handler_set_handler (SIGKILL,
+ (XfcePosixSignalHandler) posix_signal_handler,
+ player, NULL);
+ }
+ else
+ {
+ g_warning ("Unable to set up POSIX signal handlers: %s", error->message);
+ g_error_free (error);
+ }
+
+
parole_plugin_player_play (player);
gtk_main ();
@@ -105,8 +136,10 @@ int main (int argc, char **argv)
parole_dbus_release_name (dbus_name);
g_free (dbus_name);
- g_debug ("Exiting");
+ if ( exit_source_id != 0 )
+ g_source_remove (exit_source_id);
+ 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 bf3b9c6..fc6067f 100644
--- a/browser-plugin/media-plugin/parole-plugin-player.c
+++ b/browser-plugin/media-plugin/parole-plugin-player.c
@@ -295,6 +295,7 @@ parole_plugin_player_media_state_cb (ParoleGst *gst, const ParoleStream *stream,
static gboolean
parole_plugin_player_terminate (GtkWidget *widget, GdkEvent *ev, ParolePluginPlayer *player)
{
+ g_debug ("Delete event");
parole_gst_terminate (player->priv->gst);
g_signal_handler_disconnect (player->priv->plug, player->priv->sig);
player->priv->terminate = TRUE;
@@ -741,6 +742,12 @@ void parole_plugin_player_play (ParolePluginPlayer *player)
parole_gst_play_uri (player->priv->gst, player->priv->url, NULL);
}
+void parole_plugin_player_exit (ParolePluginPlayer *player)
+{
+ player->priv->terminate = TRUE;
+ parole_gst_terminate (player->priv->gst);
+}
+
static gboolean parole_plugin_player_dbus_quit (ParolePluginPlayer *player,
GError **error);
@@ -787,7 +794,6 @@ static gboolean
parole_plugin_player_dbus_terminate (ParolePluginPlayer *player, GError **error)
{
g_debug ("Terminate message received");
- player->priv->terminate = TRUE;
- parole_gst_terminate (player->priv->gst);
+ parole_plugin_player_exit (player);
return TRUE;
}
diff --git a/browser-plugin/media-plugin/parole-plugin-player.h b/browser-plugin/media-plugin/parole-plugin-player.h
index 654f756..d92dbf0 100644
--- a/browser-plugin/media-plugin/parole-plugin-player.h
+++ b/browser-plugin/media-plugin/parole-plugin-player.h
@@ -52,6 +52,8 @@ ParolePluginPlayer *parole_plugin_player_new (GtkWidget *plu
void parole_plugin_player_play (ParolePluginPlayer *player);
+void parole_plugin_player_exit (ParolePluginPlayer *player);
+
G_END_DECLS
#endif /* __PAROLE_PLUGIN_PLAYER_H */
diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp
index dc81e0a..8623ad1 100644
--- a/browser-plugin/plugin.cpp
+++ b/browser-plugin/plugin.cpp
@@ -178,19 +178,23 @@ NPBool CPlugin::isInitialized()
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);
+ if ( child_spawned )
+ {
+ g_return_if_fail (bus != NULL);
- g_free (dbus_name);
+ 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)
More information about the Xfce4-commits
mailing list