changeset 598:e83e6fb3ebfa trunk

[svn] - aosd: stability fixes for triggers (handle situation where a plentry exists but plentry->title is null)
author giacomo
date Fri, 02 Feb 2007 04:34:35 -0800
parents 05bc0456fabb
children f242442e5680
files ChangeLog src/aosd/aosd_trigger.c
diffstat 2 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Feb 01 16:46:20 2007 -0800
+++ b/ChangeLog	Fri Feb 02 04:34:35 2007 -0800
@@ -1,3 +1,12 @@
+2007-02-02 00:46:20 +0000  Giacomo Lozito <james@develia.org>
+  revision [1280]
+  - aosd: add missing aosd_trigger* sources
+  trunk/src/aosd/aosd_trigger.c         |  233 ++++++++++++++++++++++++++++++++++
+  trunk/src/aosd/aosd_trigger.h         |   37 +++++
+  trunk/src/aosd/aosd_trigger_private.h |   45 ++++++
+  3 files changed, 315 insertions(+)
+
+
 2007-02-02 00:45:47 +0000  Giacomo Lozito <james@develia.org>
   revision [1278]
   - aosd: replaced polling with hooks; added trigger options as well, working triggers are playback start and title changes
--- a/src/aosd/aosd_trigger.c	Thu Feb 01 16:46:20 2007 -0800
+++ b/src/aosd/aosd_trigger.c	Fri Feb 02 04:34:35 2007 -0800
@@ -139,14 +139,28 @@
 aosd_trigger_func_pb_start_cb ( gpointer plentry_gp , gpointer unused )
 {
   PlaylistEntry *pl_entry = plentry_gp;
-  if (( plentry_gp != NULL ) && ( pl_entry->title != NULL ))
+  if ( plentry_gp != NULL )
   {
-    gchar *utf8_title = str_to_utf8( pl_entry->title );
+    gchar *title;
+    if ( pl_entry->title != NULL )
+    {
+      /* if there is a proper title, use it */
+      title = g_strdup(pl_entry->title);
+    }
+    else
+    {
+      /* pick what we have as song title */
+      Playlist *active = playlist_get_active();
+      gint pos = playlist_get_position(active);
+      title = playlist_get_songtitle(active, pos);
+    }
+    gchar *utf8_title = str_to_utf8( title );
     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 );
     g_free( utf8_title_markup );
     g_free( utf8_title );
+    g_free( title );
   }
   return;
 }
@@ -199,9 +213,9 @@
 
     if ( ( prevs->title != NULL ) && ( prevs->filename != NULL ) )
     {
-      if ( !strcmp(pl_entry->filename,prevs->filename) )
+      if ( ( pl_entry->filename != NULL ) && ( !strcmp(pl_entry->filename,prevs->filename) ) )
       {
-        if ( strcmp(pl_entry->title,prevs->title) )
+        if ( ( pl_entry->title != NULL ) && ( strcmp(pl_entry->title,prevs->title) ) )
         {
           /* string formatting is done here a.t.m. - TODO - improve this area */
           gchar *utf8_title = str_to_utf8( pl_entry->title );