X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fmisc%2Fnotify%2Ftelepathy.c;h=f2fff326dfebe723482837764c8e843fcce1fa98;hb=bf099fea1fbc4f6290daf9ebe0365451455ded82;hp=91950fae38f2f141194982abecbfefdf9e60d825;hpb=ba6501f3084682844e7ee87bad3986bced5f3652;p=vlc diff --git a/modules/misc/notify/telepathy.c b/modules/misc/notify/telepathy.c index 91950fae38..f2fff326df 100644 --- a/modules/misc/notify/telepathy.c +++ b/modules/misc/notify/telepathy.c @@ -74,18 +74,18 @@ static int SendToTelepathy( intf_thread_t *, const char * ); "$I Video Title, $L Time Remaining, $N Name, $O Audio language, $P Position, " \ "$R Rate, $S Sample rate, $T Time elapsed, $U Publisher, $V Volume") -vlc_module_begin(); - set_category( CAT_INTERFACE ); - set_subcategory( SUBCAT_INTERFACE_CONTROL ); - set_shortname( "Telepathy" ); - set_description( N_("Telepathy \"Now Playing\" using MissionControl") ); +vlc_module_begin () + set_category( CAT_INTERFACE ) + set_subcategory( SUBCAT_INTERFACE_CONTROL ) + set_shortname( "Telepathy" ) + set_description( N_("Telepathy \"Now Playing\" (MissionControl)") ) add_string( "telepathy-format", FORMAT_DEFAULT, NULL, - FORMAT_TEXT, FORMAT_LONGTEXT, false ); + FORMAT_TEXT, FORMAT_LONGTEXT, false ) - set_capability( "interface", 0 ); - set_callbacks( Open, Close ); -vlc_module_end(); + set_capability( "interface", 0 ) + set_callbacks( Open, Close ) +vlc_module_end () /***************************************************************************** * Open: initialize and create stuff @@ -97,7 +97,9 @@ static int Open( vlc_object_t *p_this ) DBusConnection *p_conn; DBusError error; - MALLOC_ERR( p_intf->p_sys, intf_sys_t ); + p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); + if( !p_intf->p_sys ) + return VLC_ENOMEM; /* connect to the session bus */ dbus_error_init( &error ); @@ -124,7 +126,7 @@ static int Open( vlc_object_t *p_this ) p_playlist = pl_Hold( p_intf ); var_AddCallback( p_playlist, "item-change", ItemChange, p_intf ); - var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); + var_AddCallback( p_playlist, "item-current", ItemChange, p_intf ); pl_Release( p_intf ); return VLC_SUCCESS; @@ -137,13 +139,15 @@ static void Close( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; playlist_t *p_playlist = pl_Hold( p_this ); + input_thread_t *p_input = NULL; - PL_LOCK; var_DelCallback( p_playlist, "item-change", ItemChange, p_intf ); - var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf ); - if( p_playlist->p_input ) - var_DelCallback( p_playlist->p_input, "state", StateChange, p_intf ); - PL_UNLOCK; + var_DelCallback( p_playlist, "item-current", ItemChange, p_intf ); + if( (p_input = playlist_CurrentInput( p_playlist )) ) + { + var_DelCallback( p_input, "state", StateChange, p_intf ); + vlc_object_release( p_input ); + } pl_Release( p_this ); /* Clears the Presence message ... else it looks like we're still playing @@ -173,7 +177,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, input_thread_t *p_input; /* Don't update Telepathy presence each time an item has been preparsed */ - if( !strncmp( "playlist-current", psz_var, 16 ) ) + if( !strncmp( "item-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; @@ -190,10 +194,9 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, p_intf->p_sys->i_item_changes++; } - p_input = p_playlist->p_input; + p_input = playlist_CurrentInput( p_playlist ); if( !p_input ) return VLC_SUCCESS; - vlc_object_hold( p_input ); if( p_input->b_dead || !input_GetItem(p_input)->psz_name ) { @@ -208,7 +211,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, } } - if( !strncmp( "playlist-current", psz_var, 16 ) ) + if( !strncmp( "item-current", psz_var, 16 ) ) var_AddCallback( p_input, "state", StateChange, p_intf ); /* We format the string to be displayed */