*****************************************************************************/
struct intf_sys_t
{
- char *psz_format;
+ char *psz_format;
DBusConnection *p_conn;
+ int i_id;
+ int i_item-changes;
};
/*****************************************************************************
#define FORMAT_DEFAULT "$a - $t"
#define FORMAT_TEXT N_("Title format string")
#define FORMAT_LONGTEXT N_("Format of the string to send to Telepathy." \
-"Defaults to \"Artist - Title\" ($a - $t)." \
+"Defaults to \"Artist - Title\" ($a - $t). " \
"You can use the following substitutions: " \
-"$a Artist, $b Album, $c, Copyright, $d Description, $e Encoder, $g Genre, " \
+"$a Artist, $b Album, $c Copyright, $d Description, $e Encoder, $g Genre, " \
"$l Language, $n number, $p Now Playing, $r Rating, $s Subtitles language, " \
"$t Title, $u URL, $A Date, $B Bitrate, $C Chapter, $D Duration, $F URI, " \
"$I Video Title, $L Time Remaining, $N Name, $O Audio language, $P Position, " \
}
msg_Dbg( p_intf, "using format: %s", p_intf->p_sys->psz_format );
+ p_intf->p_sys->i_id = -1;
+
p_playlist = pl_Yield( p_intf );
var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );
var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
pl_Release( p_intf );
- dbus_threads_init_default();
-
dbus_error_init( &error );
/* connect to the session bus */
intf_thread_t *p_intf = (intf_thread_t *)param;
char *psz_buf = NULL;
input_thread_t *p_input;
+
+ /* Don't update Telepathy presence each time an item has been preparsed */
+ 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++;
+ }
+
+
playlist_t *p_playlist = pl_Yield( p_this );
p_input = p_playlist->p_input;
return VLC_ENOMEM;
p_reply = dbus_connection_send_with_reply_and_block( p_conn, p_msg,
- 1000, &error );
+ 50, &error ); /* blocks 50ms maximum */
dbus_message_unref( p_msg );
if( p_reply == NULL )