]> git.sesse.net Git - vlc/commitdiff
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 aa1e5569696cc6281f78cec49c1e2cc8b01608c7..5319c1b179dc48d9a2b04d40a4ec9e115b9c68de 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 25c0275a00ebd1a999497a13560e7823aefb1ae8..6d093adf6dea0770a891888ffdd4e6ee966f32a3 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 );