+ if( !b_fetch_art )
+ {
+ input_MetaFetch( p_playlist, p_item );
+ var_SetInteger( p_playlist, "item-change", p_item->i_id );
+ /* Fetch right now */
+ if( p_playlist->p_fetcher->i_art_policy == 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_fetcher->p_waiting,
+ p_playlist->p_fetcher->i_waiting,
+ 0, p );
+ PL_DEBUG("meta fetched for %s, get art", p_item->psz_name);
+ vlc_mutex_unlock( &p_obj->object_lock );
+ continue;
+ }
+ else
+ vlc_gc_decref( p_item );
+ }
+ else
+ {
+ int i_ret;
+
+ /* Check if it is not yet preparsed and if so wait for it (at most 0.5s)
+ * (This can happen if we fetch art on play)
+ * FIXME this doesn't work if we need to fetch meta before art ... */
+ for( i_ret = 0; i_ret < 10 && !input_item_IsPreparsed( p_item ); i_ret++ )
+ {
+ vlc_bool_t b_break;
+ PL_LOCK;
+ b_break = ( !p_playlist->p_input || input_GetItem(p_playlist->p_input) != p_item ||
+ p_playlist->p_input->b_die || p_playlist->p_input->b_eof || p_playlist->p_input->b_error );
+ PL_UNLOCK;
+ if( b_break )
+ break;
+ msleep( 50000 );
+ }
+
+ i_ret = input_ArtFind( p_playlist, p_item );
+ if( i_ret == 1 )
+ {
+ PL_DEBUG("downloading art for %s", p_item->psz_name );
+ if( input_DownloadAndCacheArt( p_playlist, p_item ) )
+ input_item_SetArtNotFound( p_item, VLC_TRUE );
+ else {
+ input_item_SetArtFetched( p_item, VLC_TRUE );
+ var_SetInteger( p_playlist, "item-change",
+ p_item->i_id );
+ }
+ }
+ else if( i_ret == 0 ) /* Was in cache */
+ {
+ PL_DEBUG("found art for %s in cache", p_item->psz_name );
+ input_item_SetArtFetched( p_item, VLC_TRUE );
+ var_SetInteger( p_playlist, "item-change", p_item->i_id );
+ }
+ else
+ {
+ PL_DEBUG("art not found for %s", p_item->psz_name );
+ input_item_SetArtNotFound( p_item, VLC_TRUE );
+ }
+ vlc_gc_decref( p_item );
+ }