changeset 883:e6d51d079a46 trunk

[svn] - aosd: use a single ghosd object for all of the osd showups; this will be a lot gentler to XLib and should definitely help with stability
author giacomo
date Tue, 20 Mar 2007 18:55:57 -0700
parents d58c48b014ed
children 4fd90f2d1832
files ChangeLog src/aosd/aosd.c src/aosd/aosd_osd.c src/aosd/aosd_osd.h src/aosd/aosd_trigger.c src/aosd/aosd_ui.c src/aosd/ghosd.c
diffstat 7 files changed, 66 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 20 14:01:54 2007 -0700
+++ b/ChangeLog	Tue Mar 20 18:55:57 2007 -0700
@@ -1,3 +1,12 @@
+2007-03-20 21:01:54 +0000  Michael Farber <01mf02@gmail.com>
+  revision [1864]
+  - integrated SndStretch into build process
+  
+  
+  trunk/configure.ac |    3 ++-
+  1 file changed, 2 insertions(+), 1 deletion(-)
+
+
 2007-03-20 19:22:25 +0000  Michael Farber <01mf02@gmail.com>
   revision [1862]
   - Made port of XMMS plugin SndStretch
--- a/src/aosd/aosd.c	Tue Mar 20 14:01:54 2007 -0700
+++ b/src/aosd/aosd.c	Tue Mar 20 18:55:57 2007 -0700
@@ -27,7 +27,7 @@
 
 
 aosd_cfg_t * global_config = NULL;
-static gboolean plugin_is_active = FALSE;
+gboolean plugin_is_active = FALSE;
 
 
 /* ***************** */
@@ -48,6 +48,8 @@
   global_config = aosd_cfg_new();
   aosd_cfg_load( global_config );
 
+  aosd_osd_init();
+
   aosd_trigger_start( &global_config->osd->trigger );
 
   return;
@@ -61,17 +63,18 @@
   {
     aosd_trigger_stop( &global_config->osd->trigger );
 
-    aosd_shutdown();
+    aosd_osd_shutdown();
+    aosd_osd_cleanup();
 
     if ( global_config != NULL )
     {
       aosd_cfg_delete( global_config );
       global_config = NULL;
     }
-    
+
     plugin_is_active = FALSE;
   }
-  
+
   return;
 }
 
--- a/src/aosd/aosd_osd.c	Tue Mar 20 14:01:54 2007 -0700
+++ b/src/aosd/aosd_osd.c	Tue Mar 20 18:55:57 2007 -0700
@@ -99,9 +99,7 @@
 {
   if ( osd_data->fade_data.surface != NULL )
   {
-    /* by using XCloseDisplay in ghosd_destroy, this free is not needed
-       anymore (doing it will result in double free and segfault)
-      cairo_surface_destroy( osd_data->fade_data.surface ); */
+    cairo_surface_destroy( osd_data->fade_data.surface );
     osd_data->fade_data.surface = NULL;
   }
 
@@ -134,14 +132,12 @@
 
 
 static void
-aosd_osd_hideanddestroy ( void )
+aosd_osd_hide ( void )
 {
   if ( osd != NULL )
   {
     ghosd_hide( osd );
     ghosd_main_iterations( osd );
-    ghosd_destroy( osd );
-    osd = NULL;
   }
   return;
 }
@@ -233,8 +229,6 @@
   pango_layout_set_width( osd_data->pango_layout , PANGO_SCALE * max_width );
   pango_layout_get_pixel_size( osd_data->pango_layout , &layout_width , &layout_height );
 
-  osd = ghosd_new();
-
   /* osd position */
   switch ( osd_data->cfg_osd->position.placement )
   {
@@ -370,7 +364,7 @@
 
     case AOSD_STATUS_DESTROY:
     {
-      aosd_osd_hideanddestroy();
+      aosd_osd_hide();
       aosd_osd_data_free();
 
       osd_status = AOSD_STATUS_HIDDEN; /* reset status */
@@ -384,7 +378,7 @@
 
 
 gint
-aosd_display ( gchar * markup_string , aosd_cfg_osd_t * cfg_osd , gboolean copy_cfg )
+aosd_osd_display ( gchar * markup_string , aosd_cfg_osd_t * cfg_osd , gboolean copy_cfg )
 {
   if ( osd_status == AOSD_STATUS_HIDDEN )
   {
@@ -398,7 +392,7 @@
   {
     g_source_remove( osd_source_id ); /* remove timer */
     osd_source_id = 0;
-    aosd_osd_hideanddestroy();
+    aosd_osd_hide();
     aosd_osd_data_free();
     osd_status = AOSD_STATUS_HIDDEN;
     /* now display new OSD */
@@ -413,15 +407,40 @@
 
 
 void
-aosd_shutdown ( void )
+aosd_osd_shutdown ( void )
 {
   if ( osd_status != AOSD_STATUS_HIDDEN ) /* osd is being displayed */
   {
     g_source_remove( osd_source_id ); /* remove timer */
     osd_source_id = 0;
-    aosd_osd_hideanddestroy();
+    aosd_osd_hide();
     aosd_osd_data_free();
     osd_status = AOSD_STATUS_HIDDEN;
   }
   return;
 }
+
+
+void
+aosd_osd_init ( void )
+{
+  if ( osd == NULL )
+  {
+    /* create Ghosd object */
+    osd = ghosd_new();
+  }
+  return;
+}
+
+
+void 
+aosd_osd_cleanup ( void )
+{
+  if ( osd != NULL )
+  {
+    /* destroy Ghosd object */
+    ghosd_destroy( osd );
+    osd = NULL;
+  }
+  return;
+}
--- a/src/aosd/aosd_osd.h	Tue Mar 20 14:01:54 2007 -0700
+++ b/src/aosd/aosd_osd.h	Tue Mar 20 18:55:57 2007 -0700
@@ -26,7 +26,9 @@
 #include <glib.h>
 
 
-gint aosd_display ( gchar * markup_string , aosd_cfg_osd_t * cfg_osd , gboolean copy_cfg );
-void aosd_shutdown ( void );
+gint aosd_osd_display ( gchar * markup_string , aosd_cfg_osd_t * cfg_osd , gboolean copy_cfg );
+void aosd_osd_shutdown ( void );
+void aosd_osd_init ( void ); /* to be called before any OSD usage */
+void aosd_osd_cleanup ( void ); /* to be called when done with OSD usage */
 
 #endif /* !_I_AOSD_OSD_H */
--- a/src/aosd/aosd_trigger.c	Tue Mar 20 14:01:54 2007 -0700
+++ b/src/aosd/aosd_trigger.c	Tue Mar 20 18:55:57 2007 -0700
@@ -168,7 +168,7 @@
     {
       gchar *utf8_title_markup = g_markup_printf_escaped(
         "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
-      aosd_display( utf8_title_markup , global_config->osd , FALSE );
+      aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
       g_free( utf8_title_markup );
     }
     g_free( utf8_title );
@@ -235,7 +235,7 @@
           {
             gchar *utf8_title_markup = g_markup_printf_escaped(
               "<span font_desc='%s'>%s</span>" , global_config->osd->text.fonts_name[0] , utf8_title );
-            aosd_display( utf8_title_markup , global_config->osd , FALSE );
+            aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
             g_free( utf8_title_markup );
           }
           g_free( utf8_title );
@@ -290,7 +290,7 @@
   gchar *utf8_title_markup = g_markup_printf_escaped(
     "<span font_desc='%s'>Volume Change - L: %i , R: %i</span>" ,
     global_config->osd->text.fonts_name[0] , bucket->h_vol[0] , bucket->h_vol[1] );
-  aosd_display( utf8_title_markup , global_config->osd , FALSE );
+  aosd_osd_display( utf8_title_markup , global_config->osd , FALSE );
   g_free( utf8_title_markup );
   bucket->sid = 0; /* reset source id value */
   return FALSE;
--- a/src/aosd/aosd_ui.c	Tue Mar 20 14:01:54 2007 -0700
+++ b/src/aosd/aosd_ui.c	Tue Mar 20 18:55:57 2007 -0700
@@ -30,6 +30,7 @@
 
 
 extern aosd_cfg_t * global_config;
+extern gboolean plugin_is_active;
 
 
 /*************************************************************/
@@ -771,7 +772,9 @@
 #endif
   markup_message = g_markup_printf_escaped(
     "<span font_desc='%s'>Audacious OSD</span>" , cfg->osd->text.fonts_name[0] );
-  aosd_display( markup_message , cfg->osd , TRUE );
+  if ( plugin_is_active != TRUE )
+    aosd_osd_init();
+  aosd_osd_display( markup_message , cfg->osd , TRUE );
   g_free( markup_message );
   aosd_cfg_delete( cfg );
   return;
@@ -783,7 +786,9 @@
 {
   GList *cb_list = g_object_get_data( G_OBJECT(cfg_win) , "cblist" );
   aosd_callback_list_free( cb_list );
-  aosd_shutdown(); /* stop any displayed osd */
+  aosd_osd_shutdown(); /* stop any displayed osd */
+  if ( plugin_is_active != TRUE )
+    aosd_osd_cleanup();
   gtk_widget_destroy( GTK_WIDGET(cfg_win) );
   return;
 }
@@ -797,7 +802,10 @@
   GList *cb_list = g_object_get_data( G_OBJECT(cfg_win) , "cblist" );
   aosd_callback_list_run( cb_list , cfg );
   cfg->set = TRUE;
-  aosd_shutdown(); /* stop any displayed osd */
+  aosd_osd_shutdown(); /* stop any displayed osd */
+  if ( plugin_is_active != TRUE )
+    aosd_osd_cleanup();
+
   if ( global_config != NULL )
   {
     /* plugin is active */
--- a/src/aosd/ghosd.c	Tue Mar 20 14:01:54 2007 -0700
+++ b/src/aosd/ghosd.c	Tue Mar 20 18:55:57 2007 -0700
@@ -291,7 +291,6 @@
   if (ghosd->background)
     XFreePixmap(ghosd->dpy, ghosd->background);
   XDestroyWindow(ghosd->dpy, ghosd->win);
-  XCloseDisplay(ghosd->dpy);
 }
 
 int