telepathy: avoid flooding the bus when playing some special inputs.
authorRafaël Carré <funman@videolan.org>
Fri, 28 Sep 2007 21:11:01 +0000 (21:11 +0000)
committerRafaël Carré <funman@videolan.org>
Fri, 28 Sep 2007 21:11:01 +0000 (21:11 +0000)
modules/misc/notify/notify.c
modules/misc/notify/telepathy.c

index aa1e556..5319c1b 100644 (file)
@@ -193,7 +193,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
                   psz_title, psz_artist );
     else
         snprintf( psz_tmp, MAX_LENGTH, "<b>%s</b>", psz_title );
+
     free( psz_title );
     free( psz_artist );
     free( psz_album );
index 25c0275..6d093ad 100644 (file)
@@ -40,6 +40,7 @@ struct intf_sys_t
     char            *psz_format;
     DBusConnection  *p_conn;
     int             i_id;
+    int             i_item-changes;
 };
 
 /*****************************************************************************
@@ -162,9 +163,18 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     if( !strncmp( "playlist-current", psz_var, 16 ) )
     { /* stores the current input item id */
         p_intf->p_sys->i_id = newval.i_int;
+        p_intf->p_sys->i_item-changes = 0;
+    }
+    else
+    {
+        if( newval.i_int != p_intf->p_sys->i_id ) /* "item-change" */
+            return VLC_SUCCESS;
+        /* some variable bitrate inputs call "item-change callbacks each time
+         * their length is updated, that is several times per second. */
+        if( p_intf->p_sys->i_item-changes > 5 )
+            return VLC_SUCCESS;
+        p_intf->p_sys->i_item-changes++;
     }
-    else if( newval.i_int != p_intf->p_sys->i_id ) /* "item-change" */
-        return VLC_SUCCESS;
 
 
     playlist_t *p_playlist = pl_Yield( p_this );