]> git.sesse.net Git - vlc/blobdiff - modules/misc/notify/growl.m
Use var_InheritString for --decklink-video-connection.
[vlc] / modules / misc / notify / growl.m
index 32abcb58f79fba9123775ceea327b0e6947688fb..71ecdd1033e078797f4c26102bf55b7b56210358 100644 (file)
@@ -58,6 +58,7 @@
 #include <vlc_playlist.h>
 #include <vlc_meta.h>
 #include <vlc_interface.h>
+#include <vlc_url.h>
 
 
 /*****************************************************************************
@@ -114,14 +115,13 @@ static int Open( vlc_object_t *p_this )
     p_sys->app_name = CFSTR( "VLC media player" );
     p_sys->notification_type = CFSTR( "New input playing" );
 
-    const char *data_path = config_GetDataDir ();
+    char *data_path = config_GetDataDir ( p_this );
     char buf[strlen (data_path) + sizeof ("/vlc48x48.png")];
     snprintf (buf, sizeof (buf), "%s/vlc48x48.png", data_path);
+    free( data_path );
     p_sys->default_icon = (CFDataRef) readFile( buf );
 
-    playlist_t *p_playlist = pl_Hold( p_intf );
-    var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
-    pl_Release( p_intf );
+    var_AddCallback( pl_Get( p_intf ), "item-current", ItemChange, p_intf );
 
     RegisterToGrowl( p_this );
     return VLC_SUCCESS;
@@ -134,15 +134,13 @@ static void Close( vlc_object_t *p_this )
 {
     intf_sys_t *p_sys = ((intf_thread_t*)p_this)->p_sys;
 
+    var_DelCallback( pl_Get( p_this ), "item-current", ItemChange, p_this );
+
     CFRelease( p_sys->default_icon );
     CFRelease( p_sys->app_name );
     CFRelease( p_sys->notification_type );
     [p_sys->p_pool release];
     free( p_sys );
-
-    playlist_t *p_playlist = pl_Hold( p_this );
-    var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this );
-    pl_Release( p_this );
 }
 
 /*****************************************************************************
@@ -159,13 +157,9 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     char *psz_artist        = NULL;
     char *psz_album         = NULL;
     input_thread_t *p_input;
-    playlist_t *p_playlist = pl_Hold( p_this );
-
-    p_input = p_playlist->p_input;
-    pl_Release( p_this );
+    p_input = playlist_CurrentInput( (playlist_t*)p_this );
 
     if( !p_input ) return VLC_SUCCESS;
-    vlc_object_hold( p_input );
 
     char *psz_name = input_item_GetName( input_GetItem( p_input ) );
     if( p_input->b_dead || !psz_name )
@@ -180,17 +174,12 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     /* Playing something ... */
     input_item_t *p_item = input_GetItem( p_input );
 
-    psz_title = input_item_GetTitle( p_item );
-    if( psz_title == NULL || EMPTY_STR( psz_title ) )
+    psz_title = input_item_GetTitleFbName( p_item );
+    if( EMPTY_STR( psz_title ) )
     {
         free( psz_title );
-        psz_title = input_item_GetName( input_GetItem( p_input ) );
-        if( psz_title == NULL || EMPTY_STR( psz_title ) )
-        {
-            free( psz_title );
-            vlc_object_release( p_input );
-            return VLC_SUCCESS;
-        }
+        vlc_object_release( p_input );
+        return VLC_SUCCESS;
     }
 
     psz_artist = input_item_GetArtist( p_item );
@@ -205,7 +194,11 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     else if( psz_artist )
         i_ret = asprintf( &psz_tmp, "%s\n%s", psz_title, psz_artist );
     else
-        i_ret = asprintf( &psz_tmp, "%s", psz_title );
+    {
+        psz_tmp = strdup( psz_title );
+        if( psz_tmp == NULL )
+           i_ret = -1;
+    }
 
     if( i_ret == -1 )
     {
@@ -217,10 +210,15 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     }
 
     char *psz_arturl = input_item_GetArtURL( p_item );
+    if( psz_arturl )
+    {
+        char *psz = make_path( psz_arturl );
+        free( psz_arturl );
+        psz_arturl = psz;
+    }
     CFDataRef art = NULL;
-    if( psz_arturl && !strncmp( psz_arturl, "file://", 7 ) &&
-                    strlen( psz_arturl ) > 7 )
-        art = (CFDataRef) readFile( psz_arturl + 7 );
+    if( psz_arturl )
+        art = (CFDataRef) readFile( psz_arturl );
 
     free( psz_title );
     free( psz_artist );
@@ -230,6 +228,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     NotifyToGrowl( p_intf, psz_tmp, art );
 
     if( art ) CFRelease( art );
+    free( psz_tmp );
 
     vlc_object_release( p_input );
     return VLC_SUCCESS;