changeset 797:19e08e104ba6 trunk

[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
author giacomo
date Thu, 08 Mar 2007 09:24:04 -0800
parents f3ce11fad729
children a1d56f2c8bb1
files ChangeLog src/madplug/input.c src/madplug/plugin.h
diffstat 3 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 08 04:20:23 2007 -0800
+++ b/ChangeLog	Thu Mar 08 09:24:04 2007 -0800
@@ -1,3 +1,10 @@
+2007-03-08 12:20:23 +0000  Giacomo Lozito <james@develia.org>
+  revision [1690]
+  statusicon: improvements in title changes detection while the popup is being displayed
+  trunk/src/statusicon/si_ui.c |   17 ++++++++++++++---
+  1 file changed, 14 insertions(+), 3 deletions(-)
+
+
 2007-03-08 00:45:38 +0000  Giacomo Lozito <james@develia.org>
   revision [1688]
   - statusicon: re-display statusicon popup with updated information when song (or title) changes, closes bug #846
--- a/src/madplug/input.c	Thu Mar 08 04:20:23 2007 -0800
+++ b/src/madplug/input.c	Thu Mar 08 09:24:04 2007 -0800
@@ -92,6 +92,7 @@
     info->mode = 0;
     info->title = 0;
     info->offset = 0;
+    info->prev_title = NULL;
 
     info->replaygain_album_str = 0;
     info->replaygain_track_str = 0;
@@ -485,9 +486,18 @@
         else
             tmp = g_strdup(g_basename(info->filename));
 
-        mad_plugin->set_info(tmp,
-                             -1, // indicate the stream is unseekable
-                             info->bitrate, info->freq, info->channels);
+        /* call set_info only if tmp is different from prev_tmp */
+        if ( ( ( info->prev_title != NULL ) && ( strcmp(info->prev_title,tmp) ) ) ||
+             ( info->prev_title == NULL ) )
+        {
+            mad_plugin->set_info(tmp,
+                                 -1, // indicate the stream is unseekable
+                                 info->bitrate, info->freq, info->channels);
+            if (info->prev_title)
+                g_free(info->prev_title);
+            info->prev_title = g_strdup(tmp);
+        }
+
         g_free(tmp);
     }
 }
@@ -610,6 +620,9 @@
         info->tuple = NULL;
     }
 
+    if (info->prev_title)
+        g_free(info->prev_title);
+
     /* set everything to zero in case it gets used again. */
     memset(info, 0, sizeof(struct mad_info_t));
 #ifdef DEBUG
--- a/src/madplug/plugin.h	Thu Mar 08 04:20:23 2007 -0800
+++ b/src/madplug/plugin.h	Thu Mar 08 09:24:04 2007 -0800
@@ -75,6 +75,7 @@
     struct id3_file *id3file;
     struct xing xing;
     TitleInput *tuple;          /* audacious tuple data */
+    gchar *prev_title;           /* used to optimize set_info calls */
 
     /* replay parameters */
     gboolean has_replaygain;