Re-enable art fetching when in "ALL" mode
authorClément Stenac <zorglub@videolan.org>
Sat, 30 Sep 2006 17:08:48 +0000 (17:08 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 30 Sep 2006 17:08:48 +0000 (17:08 +0000)
Todo: we should recheck cache just before downloading in case it has been downloaded while we were in the queue

modules/meta_engine/folder.c
modules/meta_engine/musicbrainz.c
modules/mux/mp4.c
src/input/input.c
src/input/meta.c
src/playlist/engine.c

index b7b6881..b8927a8 100644 (file)
@@ -50,8 +50,6 @@ static int FindMeta( vlc_object_t * );
  *****************************************************************************/
 
 vlc_module_begin();
  *****************************************************************************/
 
 vlc_module_begin();
-/*    set_category( CAT_INTERFACE );
-    set_subcategory( SUBCAT_INTERFACE_CONTROL );*/
     set_shortname( N_( "Folder" ) );
     set_description( _("Folder meta data") );
 
     set_shortname( N_( "Folder" ) );
     set_description( _("Folder meta data") );
 
@@ -63,71 +61,59 @@ vlc_module_end();
  *****************************************************************************/
 static int FindMeta( vlc_object_t *p_this )
 {
  *****************************************************************************/
 static int FindMeta( vlc_object_t *p_this )
 {
-    meta_engine_t *p_me = (meta_engine_t *)p_this;
-    input_item_t *p_item = p_me->p_item;
+    playlist_t *p_playlist = (playlist_t *)p_this;
+    input_item_t *p_item = (input_item_t *)(p_playlist->p_private);
     vlc_bool_t b_have_art = VLC_FALSE;
     uint32_t i_meta;
 
     vlc_bool_t b_have_art = VLC_FALSE;
     uint32_t i_meta;
 
-    if( !p_item->p_meta ) return VLC_EGENERIC;
-
+    int i = 0;
+    struct stat a;
+    char psz_filename[MAX_PATH];
+    char *psz_dir = strdup( p_item->psz_uri );
+    char *psz_buf = strrchr( psz_dir, '/' );
 
 
-    if( p_me->i_mandatory & VLC_META_ENGINE_ART_URL
-        || p_me->i_optional & VLC_META_ENGINE_ART_URL )
+    if( !p_item->p_meta ) return VLC_EGENERIC;
+    if( psz_buf )
     {
     {
-        int i = 0;
-        struct stat a;
-        char psz_filename[MAX_PATH];
-        char *psz_dir = strdup( p_item->psz_uri );
-        char *psz_buf = strrchr( psz_dir, '/' );
+        psz_buf++;
+        *psz_buf = '\0';
+    }
+    else
+    {
+        *psz_dir = '\0';
+    }
 
 
-        if( psz_buf )
-        {
-            psz_buf++;
-            *psz_buf = '\0';
-        }
-        else
+    for( i = 0; b_have_art == VLC_FALSE && i < 3; i++ )
+    {
+        switch( i )
         {
         {
-            *psz_dir = '\0';
+            case 0:
+            /* Windows Folder.jpg */
+            snprintf( psz_filename, MAX_PATH,
+                      "file://%sFolder.jpg", psz_dir );
+            break;
+
+            case 1:
+            /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
+            snprintf( psz_filename, MAX_PATH,
+                  "file://%sAlbumArtSmall.jpg", psz_dir );
+            break;
+
+            case 2:
+            /* KDE (?) .folder.png */
+            snprintf( psz_filename, MAX_PATH,
+                  "file://%s.folder.png", psz_dir );
+            break;
         }
 
         }
 
-        for( i = 0; b_have_art == VLC_FALSE && i < 3; i++ )
+        if( utf8_stat( psz_filename+7, &a ) != -1 )
         {
         {
-            switch( i )
-            {
-                case 0:
-                /* Windows Folder.jpg */
-                snprintf( psz_filename, MAX_PATH,
-                          "file://%sFolder.jpg", psz_dir );
-                break;
-
-                case 1:
-                /* Windows AlbumArtSmall.jpg == small version of Folder.jpg */
-                snprintf( psz_filename, MAX_PATH,
-                      "file://%sAlbumArtSmall.jpg", psz_dir );
-                break;
-
-                case 2:
-                /* KDE (?) .folder.png */
-                snprintf( psz_filename, MAX_PATH,
-                      "file://%s.folder.png", psz_dir );
-                break;
-            }
-
-            if( utf8_stat( psz_filename+7, &a ) != -1 )
-            {
-                vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
-                b_have_art = VLC_TRUE;
-            }
+            vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
+            b_have_art = VLC_TRUE;
         }
         }
-
-        free( psz_dir );
     }
 
     }
 
-    i_meta = input_CurrentMetaFlags( p_item->p_meta );
-    p_me->i_mandatory &= ~i_meta;
-    p_me->i_optional &= ~i_meta;
-    if( p_me->i_mandatory )
-        return VLC_EGENERIC;
-    else
-        return VLC_SUCCESS;
+    free( psz_dir );
+
+    return b_have_art ? VLC_SUCCESS : VLC_EGENERIC;
 }
 }
index cbb3a69..d0db9d8 100644 (file)
@@ -162,7 +162,8 @@ static int FindMetaMBId( vlc_object_t *p_this )
 {
     meta_engine_t *p_me = (meta_engine_t *)p_this;
     input_item_t *p_item = p_me->p_item;
 {
     meta_engine_t *p_me = (meta_engine_t *)p_this;
     input_item_t *p_item = p_me->p_item;
-    int i_ret = GetData( VLC_OBJECT(p_me), p_item, VLC_FALSE );
+    int i_ret = GetData( VLC_OBJECT(p_me), p_item,
+                         p_me->i_mandatory & VLC_META_ENGINE_ART_URL );
 
     if( !i_ret )
     {
 
     if( !i_ret )
     {
@@ -176,9 +177,9 @@ static int FindMetaMBId( vlc_object_t *p_this )
 
 static int FindArt( vlc_object_t *p_this )
 {
 
 static int FindArt( vlc_object_t *p_this )
 {
-    playlist_t *p_playlist;
-    input_item_t *p_item = (input_item_t *)p_playlist->p_private;
+    playlist_t *p_playlist = (playlist_t *)p_this;
+    input_item_t *p_item = (input_item_t *)(p_playlist->p_private);
     assert( p_item );
 
     assert( p_item );
 
-    return GetData( p_playlist, p_item, VLC_TRUE );
+    return GetData( VLC_OBJECT(p_playlist), p_item, VLC_TRUE );
 }
 }
index c9c7319..50f496b 100644 (file)
@@ -1047,7 +1047,6 @@ static bo_t *GetUdtaTag( sout_mux_t *p_mux )
         } }
 
         ADD_META_BOX( title, "nam" );
         } }
 
         ADD_META_BOX( title, "nam" );
-        ADD_META_BOX( author, "aut" );
         ADD_META_BOX( artist, "ART" );
         ADD_META_BOX( genre, "gen" );
         ADD_META_BOX( copyright, "cpy" );
         ADD_META_BOX( artist, "ART" );
         ADD_META_BOX( genre, "gen" );
         ADD_META_BOX( copyright, "cpy" );
index e0c9e4c..658bfdc 100644 (file)
@@ -2249,7 +2249,6 @@ static void InputMetaUser( input_thread_t *p_input )
     free( val.psz_string )
 
     GET_META( title, "meta-title" );
     free( val.psz_string )
 
     GET_META( title, "meta-title" );
-    GET_META( author, "meta-author" );
     GET_META( artist, "meta-artist" );
     GET_META( genre, "meta-genre" );
     GET_META( copyright, "meta-copyright" );
     GET_META( artist, "meta-artist" );
     GET_META( genre, "meta-genre" );
     GET_META( copyright, "meta-copyright" );
index f0664b3..3b1891a 100644 (file)
@@ -102,10 +102,12 @@ int input_ArtFetch( playlist_t *p_playlist, input_item_t *p_item )
         if( !p_module )
         {
             msg_Dbg( p_playlist, "unable to find art" );
         if( !p_module )
         {
             msg_Dbg( p_playlist, "unable to find art" );
+            PL_UNLOCK;
             return VLC_EGENERIC;
         }
         module_Unneed( p_playlist, p_module );
         p_playlist->p_private = NULL;
             return VLC_EGENERIC;
         }
         module_Unneed( p_playlist, p_module );
         p_playlist->p_private = NULL;
+        PL_UNLOCK;
 
         if( !p_item->p_meta->psz_arturl || !*p_item->p_meta->psz_arturl )
             return VLC_EGENERIC;
 
         if( !p_item->p_meta->psz_arturl || !*p_item->p_meta->psz_arturl )
             return VLC_EGENERIC;
@@ -141,8 +143,6 @@ int input_FindArtInCache( playlist_t *p_playlist, input_item_t *p_item )
         /* Check if file exists */
         if( utf8_stat( psz_filename+7, &a ) == 0 )
         {
         /* Check if file exists */
         if( utf8_stat( psz_filename+7, &a ) == 0 )
         {
-            msg_Dbg( p_playlist, "album art %s already exists in cache"
-                             , psz_filename );
             vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
             return VLC_SUCCESS;
         }
             vlc_meta_SetArtURL( p_item->p_meta, psz_filename );
             return VLC_SUCCESS;
         }
@@ -211,7 +211,7 @@ int input_DownloadAndCacheArt( playlist_t *p_playlist, input_item_t *p_item )
         free( p_buffer );
         fclose( p_file );
         stream_Delete( p_stream );
         free( p_buffer );
         fclose( p_file );
         stream_Delete( p_stream );
-        msg_Dbg( p_playlist, "Album art saved to %s\n", psz_filename );
+        msg_Dbg( p_playlist, "album art saved to %s\n", psz_filename );
         free( p_item->p_meta->psz_arturl );
         p_item->p_meta->psz_arturl = strdup( psz_filename );
         i_status = VLC_SUCCESS;
         free( p_item->p_meta->psz_arturl );
         p_item->p_meta->psz_arturl = strdup( psz_filename );
         i_status = VLC_SUCCESS;
@@ -228,7 +228,6 @@ uint32_t input_CurrentMetaFlags( vlc_meta_t *p_meta )
         i_meta |= VLC_META_ENGINE_ ## b;
 
     CHECK( title, TITLE )
         i_meta |= VLC_META_ENGINE_ ## b;
 
     CHECK( title, TITLE )
-    CHECK( author, AUTHOR )
     CHECK( artist, ARTIST )
     CHECK( genre, GENRE )
     CHECK( copyright, COPYRIGHT )
     CHECK( artist, ARTIST )
     CHECK( genre, GENRE )
     CHECK( copyright, COPYRIGHT )
index 39b09c1..b44ab2a 100644 (file)
@@ -565,14 +565,28 @@ void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj )
             {
                 input_MetaFetch( p_playlist, p_item );
                 p_item->p_meta->i_status |= ITEM_META_FETCHED;
             {
                 input_MetaFetch( p_playlist, p_item );
                 p_item->p_meta->i_status |= ITEM_META_FETCHED;
+                var_SetInteger( p_playlist, "item-change", p_item->i_id );
+                /*  Fetch right now */
+                if( var_GetInteger( p_playlist, "album-art" ) == ALBUM_ART_ALL )
+                {
+                    vlc_mutex_lock( &p_obj->object_lock );
+                    preparse_item_t p;
+                    p.p_item = p_item;
+                    p.b_fetch_art = VLC_TRUE;
+                    INSERT_ELEM( p_playlist->p_secondary_preparse->p_waiting,
+                                 p_playlist->p_secondary_preparse->i_waiting,
+                                 0, p );
+                    vlc_mutex_unlock( &p_obj->object_lock );
+                }
+                else
+                    vlc_gc_decref( p_item );
             }
             else
             {
                 input_ArtFetch( p_playlist, p_item );
                 p_item->p_meta->i_status |= ITEM_ART_FETCHED;
             }
             else
             {
                 input_ArtFetch( p_playlist, p_item );
                 p_item->p_meta->i_status |= ITEM_ART_FETCHED;
-            }
-            var_SetInteger( p_playlist, "item-change", p_item->i_id );
-            vlc_gc_decref( p_item );
+                vlc_gc_decref( p_item );
+           }
         }
         vlc_mutex_lock( &p_obj->object_lock );
         i_activity = var_GetInteger( p_playlist, "activity" );
         }
         vlc_mutex_lock( &p_obj->object_lock );
         i_activity = var_GetInteger( p_playlist, "activity" );