]> git.sesse.net Git - vlc/blobdiff - src/input/meta.c
Simplification (make_path always returns an absolute path)
[vlc] / src / input / meta.c
index b550e1fa56b9e4b88ce569db251bbac6ffa700b0..f6eaed6fa6123dc3c60520c611a5ba79fb96f238 100644 (file)
@@ -146,12 +146,12 @@ char** vlc_meta_CopyExtraNames( const vlc_meta_t *m )
 /**
  * vlc_meta status (see vlc_meta_status_e)
  */
-vlc_meta_status_e vlc_meta_GetStatus( vlc_meta_t *m )
+int vlc_meta_GetStatus( vlc_meta_t *m )
 {
     return m->i_status;
 }
 
-void vlc_meta_SetStatus( vlc_meta_t *m, vlc_meta_status_e status )
+void vlc_meta_SetStatus( vlc_meta_t *m, int status )
 {
     m->i_status = status;
 }
@@ -205,13 +205,7 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
         return;
     }
 
-    playlist_t *p_playlist = pl_Hold( p_input );
-    if( !p_playlist )
-    {
-        free( psz_arturl );
-        return;
-    }
-
+    playlist_t *p_playlist = pl_Get( p_input );
 
     if( input_item_IsArtFetched( p_item ) )
     {
@@ -259,7 +253,6 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
     vlc_input_attachment_Delete( p_attachment );
 
 exit:
-    pl_Release( p_input );
     free( psz_arturl );
 }
 
@@ -277,30 +270,24 @@ int input_item_WriteMeta( vlc_object_t *obj, input_item_t *p_item )
     vlc_mutex_lock( &p_item->lock );
     type = p_item->i_type;
     vlc_mutex_unlock( &p_item->lock );
-    if( type == ITEM_TYPE_FILE )
-    {
-        char *psz_uri = input_item_GetURI( p_item );
+    if( type != ITEM_TYPE_FILE )
+        goto error;
 
-#warning FIXME: function for URI->path conversion!
-        decode_URI( psz_uri );
-        if( !strncmp( psz_uri, "file://", 7 ) )
-        {
-            p_export->psz_file = strdup( psz_uri + 7 );
-            free( psz_uri );
-        }
-        else
-#warning This should not happen!
-            p_export->psz_file = psz_uri;
-    }
-    else
-    {
-        vlc_object_release( p_export );
-        return VLC_EGENERIC;
-    }
+    char *psz_uri = input_item_GetURI( p_item );
+    p_export->psz_file = make_path( psz_uri );
+    if( p_export->psz_file == NULL )
+        msg_Err( p_export, "cannot write meta to remote media %s", psz_uri );
+    free( psz_uri );
+    if( p_export->psz_file == NULL )
+        goto error;
 
     module_t *p_mod = module_need( p_export, "meta writer", NULL, false );
     if( p_mod )
         module_unneed( p_export, p_mod );
     vlc_object_release( p_export );
     return VLC_SUCCESS;
+
+error:
+    vlc_object_release( p_export );
+    return VLC_EGENERIC;
 }