Commit 7bc28eeb authored by Rafaël Carré's avatar Rafaël Carré

meta-data handling cleanup

Remove VLC_META_ENGINE_*
Don't use VLC_META_INFO_CAT
Avoid using input_Item{Add,Get}Info
Remove disabled code in cdda
Remove "meta fetcher":
    There was only 1 module (not) implementing it (musicbrainz)
    Reduces complexity in playlist core
Use a more consistent naming
Factorize QT4 sorting and column display code
Remove unused members
parent f864df7f
......@@ -258,12 +258,6 @@ static inline bool input_item_IsPreparsed( input_item_t *p_i )
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_PREPARSED : false ;
}
static inline bool input_item_IsMetaFetched( input_item_t *p_i )
{
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_META_FETCHED : false ;
}
static inline bool input_item_IsArtFetched( input_item_t *p_i )
{
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_ART_FETCHED : false ;
......
......@@ -30,11 +30,9 @@
#include <vlc_arrays.h>
#define VLC_META_TYPE_COUNT 17
typedef enum vlc_meta_type_t
{
vlc_meta_Title = 0,
vlc_meta_Title,
vlc_meta_Artist,
vlc_meta_Genre,
vlc_meta_Copyright,
......@@ -53,14 +51,15 @@ typedef enum vlc_meta_type_t
vlc_meta_TrackID
} vlc_meta_type_t;
#define VLC_META_TYPE_COUNT 17
/* Returns a localizes string describing the meta */
VLC_EXPORT(const char *, input_MetaTypeToLocalizedString, ( vlc_meta_type_t meta_type ) );
#define ITEM_PREPARSED 0x01
#define ITEM_META_FETCHED 0x02
#define ITEM_ARTURL_FETCHED 0x04
#define ITEM_ART_FETCHED 0x08
#define ITEM_ART_NOTFOUND 0x10
#define ITEM_ARTURL_FETCHED 0x02
#define ITEM_ART_FETCHED 0x04
#define ITEM_ART_NOTFOUND 0x08
struct vlc_meta_t
{
......@@ -69,7 +68,6 @@ struct vlc_meta_t
vlc_dictionary_t extra_tags;
int i_status;
};
/* Setters for meta.
......@@ -163,15 +161,12 @@ static inline void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src )
free( ppsz_all_keys );
}
/* Shortcuts for the AddInfo */
#define VLC_META_INFO_CAT N_("Meta-information")
#define VLC_META_TITLE input_MetaTypeToLocalizedString( vlc_meta_Title )
#define VLC_META_DURATION N_( "Duration" )
#define VLC_META_ARTIST input_MetaTypeToLocalizedString( vlc_meta_Artist )
#define VLC_META_GENRE input_MetaTypeToLocalizedString( vlc_meta_Genre )
#define VLC_META_COPYRIGHT input_MetaTypeToLocalizedString( vlc_meta_Copyright )
#define VLC_META_COLLECTION input_MetaTypeToLocalizedString( vlc_meta_Album )
#define VLC_META_SEQ_NUM input_MetaTypeToLocalizedString( vlc_meta_TrackNumber )
#define VLC_META_ALBUM input_MetaTypeToLocalizedString( vlc_meta_Album )
#define VLC_META_TRACK_NUMBER input_MetaTypeToLocalizedString( vlc_meta_TrackNumber )
#define VLC_META_DESCRIPTION input_MetaTypeToLocalizedString( vlc_meta_Description )
#define VLC_META_RATING input_MetaTypeToLocalizedString( vlc_meta_Rating )
#define VLC_META_DATE input_MetaTypeToLocalizedString( vlc_meta_Date )
......@@ -196,43 +191,4 @@ struct meta_export_t
const char *psz_file;
};
#define VLC_META_ENGINE_TRACKID 0x00000001
#define VLC_META_ENGINE_TITLE 0x00000002
#define VLC_META_ENGINE_DURATION 0x00000004
#define VLC_META_ENGINE_ARTIST 0x00000008
#define VLC_META_ENGINE_GENRE 0x00000010
#define VLC_META_ENGINE_COPYRIGHT 0x00000020
#define VLC_META_ENGINE_COLLECTION 0x00000040
#define VLC_META_ENGINE_SEQ_NUM 0x00000080
#define VLC_META_ENGINE_DESCRIPTION 0x00000100
#define VLC_META_ENGINE_RATING 0x00000200
#define VLC_META_ENGINE_DATE 0x00000400
#define VLC_META_ENGINE_URL 0x00000800
#define VLC_META_ENGINE_LANGUAGE 0x00001000
#define VLC_META_ENGINE_ART_URL 0x00002000
#if 0 /* unused (yet?) */
#define VLC_META_ENGINE_MB_ARTIST_ID 0x00002000
#define VLC_META_ENGINE_MB_RELEASE_ID 0x00004000
#define VLC_META_ENGINE_MB_TRACK_ID 0x00008000
#define VLC_META_ENGINE_MB_TRM_ID 0x00010000
#endif
typedef struct meta_engine_sys_t meta_engine_sys_t;
struct meta_engine_t
{
VLC_COMMON_MEMBERS
module_t *p_module;
uint32_t i_mandatory; /**< Stuff which we really need to get */
uint32_t i_optional; /**< Stuff which we'd like to have */
input_item_t *p_item;
};
VLC_EXPORT(uint32_t, input_CurrentMetaFlags,( const vlc_meta_t *p_meta ) );
#endif
......@@ -807,16 +807,6 @@ CDDAFormatTitle( const access_t *p_access, track_t i_track )
return(NULL);
}
/* Adds a string-valued entry to the playlist information under "Track"
if the string is not null or the null string.
*/
#define add_playlist_track_info_str(TITLE, FIELD) \
if (FIELD && strlen(FIELD)) \
{ \
input_ItemAddInfo( &p_item->input, _("Track"), _(TITLE), \
"%s", FIELD); \
}
static playlist_item_t *
CDDACreatePlaylistItem( const access_t *p_access, cdda_data_t *p_cdda,
playlist_t *p_playlist, playlist_item_t *p_item,
......@@ -849,58 +839,6 @@ CDDACreatePlaylistItem( const access_t *p_access, cdda_data_t *p_cdda,
return p_child;
}
int CDDAAddMetaToItem( access_t *p_access, cdda_data_t *p_cdda,
playlist_item_t *p_item, int i_track,
bool b_single )
{
#if 0
add_playlist_track_info_str("Source", p_cdda->psz_source);
input_ItemAddInfo( &p_item->input, _("Track"), _("Track Number"),
"%d", i_track );
if (p_cdda->p_cdtext[i_track])
{
const cdtext_t *p = p_cdda->p_cdtext[i_track];
add_playlist_track_info_str("Arranger (CD-Text)",
p->field[CDTEXT_ARRANGER]);
add_playlist_track_info_str("Composer (CD-Text)",
p->field[CDTEXT_COMPOSER]);
add_playlist_track_info_str("Genre (CD-Text)",
p->field[CDTEXT_GENRE]);
add_playlist_track_info_str("Message (CD-Text)",
p->field[CDTEXT_MESSAGE]);
add_playlist_track_info_str("Performer (CD-Text)",
p->field[CDTEXT_PERFORMER]);
add_playlist_track_info_str("Songwriter (CD-Text)",
p->field[CDTEXT_SONGWRITER]);
add_playlist_track_info_str("Title (CD-Text)",
p->field[CDTEXT_TITLE]);
}
#ifdef HAVE_LIBCDDB
if (p_cdda->b_cddb_enabled)
{
cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
i_track-p_cdda->i_first_track);
if (t)
{
if (cddb_track_get_artist(t))
add_playlist_track_info_str("Artist (CDDB)",
cddb_track_get_artist(t));
if (cddb_track_get_title(t))
add_playlist_track_info_str("Title (CDDB)",
cddb_track_get_title(t));
if (cddb_track_get_ext_data(t))
add_playlist_track_info_str("Extended information (CDDB)",
cddb_track_get_ext_data(t));
}
}
#endif /*HAVE_LIBCDDB*/
#endif
return VLC_SUCCESS;
}
/*
Fixes up playlist.
*/
......@@ -973,7 +911,6 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
if( p_item )
{
CDDAAddMetaToItem( p_access, p_cdda, p_item, i_track, false );
input_item_SetDuration( p_item->p_input, (mtime_t) i_track_frames
* (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC) );
input_item_SetURI( p_item->p_input,
......@@ -1009,8 +946,6 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
p_child = CDDACreatePlaylistItem( p_access, p_cdda, p_playlist,
p_item,
i_track );
CDDAAddMetaToItem( p_access, p_cdda, p_child, i_track,
true );
}
}
......
......@@ -653,10 +653,6 @@ static void ParseVorbisComments( decoder_t *p_dec )
if( psz_value && ( *psz_value != '\0' ) )
{
input_item_SetArtist( p_item, psz_value );
input_ItemAddInfo( p_item,
_(VLC_META_INFO_CAT),
_(VLC_META_ARTIST),
"%s", psz_value );
}
}
else if( !strcasecmp( psz_name, "title" ) )
......
......@@ -983,30 +983,21 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars,
#define p_item input_GetItem( p_sys->p_input )
if( !strcmp( psz_meta, "ARTIST" ) )
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), _(VLC_META_ARTIST) );
psz_val = input_item_GetArtist( p_item );
}
else if( !strcmp( psz_meta, "TITLE" ) )
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), _(VLC_META_TITLE) );
if( psz_val == NULL )
psz_val = strdup( p_item->psz_name );
psz_val = input_item_GetTitle( p_item );
if( !psz_val )
psz_val = input_item_GetName( p_item );
}
else if( !strcmp( psz_meta, "ALBUM" ) )
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), _(VLC_META_COLLECTION) );
psz_val = input_item_GetAlbum( p_item );
}
else if( !strcmp( psz_meta, "GENRE" ) )
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), _(VLC_META_GENRE) );
}
else
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), psz_meta );
psz_val = input_item_GetGenre( p_item );
}
#undef p_item
}
......
......@@ -184,9 +184,11 @@ static int Demux( demux_t *p_demux )
p_input = input_ItemNewExt( p_playlist, psz_mrl, psz_name,
0, NULL, i_duration );
if ( psz_artist && *psz_artist )
input_ItemAddInfo( p_input, _(VLC_META_INFO_CAT),
_(VLC_META_ARTIST), "%s", psz_artist );
input_item_SetArtist( p_input, psz_artist );
free( psz_artist );
input_ItemAddSubItem( p_current_input, p_input );
for( unsigned i = 0; i < i_options; i++ )
input_ItemAddOpt( p_input, ppsz_options[i], 0 );
......
......@@ -78,8 +78,8 @@ static VLCInfo *_o_sharedInstance = nil;
/* constants defined in vlc_meta.h */
[o_genre_lbl setStringValue: _NS(VLC_META_GENRE)];
[o_copyright_lbl setStringValue: _NS(VLC_META_COPYRIGHT)];
[o_collection_lbl setStringValue: _NS(VLC_META_COLLECTION)];
[o_seqNum_lbl setStringValue: _NS(VLC_META_SEQ_NUM)];
[o_collection_lbl setStringValue: _NS(VLC_META_ALBUM)];
[o_seqNum_lbl setStringValue: _NS(VLC_META_TRACK_NUMBER)];
[o_description_lbl setStringValue: _NS(VLC_META_DESCRIPTION)];
[o_date_lbl setStringValue: _NS(VLC_META_DATE)];
[o_language_lbl setStringValue: _NS(VLC_META_LANGUAGE)];
......
......@@ -1787,14 +1787,8 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
/* Meta data box */
int l = 0;
int i_len = strlen( VLC_META_INFO_CAT );
char psz_title[i_len + 3];
psz_title[0] = ' ';
psz_title[1] = '\0';
strcat( &psz_title[1], VLC_META_INFO_CAT );
psz_title[i_len + 1] = ' ';
psz_title[i_len + 2] = '\0';
DrawBox( p_sys->w, y++, 0, h, COLS, psz_title, p_sys->b_color );
DrawBox( p_sys->w, y++, 0, h, COLS, _("Meta-information"),
p_sys->b_color );
if( p_input )
{
......@@ -1819,9 +1813,9 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
case 3:
psz_meta_title = VLC_META_COPYRIGHT; break;
case 4:
psz_meta_title = VLC_META_COLLECTION; break;
psz_meta_title = VLC_META_ALBUM; break;
case 5:
psz_meta_title = VLC_META_SEQ_NUM; break;
psz_meta_title = VLC_META_TRACK_NUMBER; break;
case 6:
psz_meta_title = VLC_META_DESCRIPTION; break;
case 7:
......
......@@ -149,6 +149,7 @@ noinst_HEADERS = \
components/playlist/panels.hpp \
components/playlist/playlist.hpp \
components/playlist/selector.hpp \
components/playlist/sorting.h \
util/input_slider.hpp \
util/customwidgets.hpp \
util/qvlcframe.hpp \
......
......@@ -67,7 +67,7 @@ MetaPanel::MetaPanel( QWidget *parent,
/* Title, artist and album*/
ADD_META( VLC_META_TITLE, title_text ); /* OK */
ADD_META( VLC_META_ARTIST, artist_text ); /* OK */
ADD_META( VLC_META_COLLECTION, collection_text ); /* OK */
ADD_META( VLC_META_ALBUM, collection_text ); /* OK */
/* Genre Name */
/* TODO List id3genres.h is not includable yet ? */
......@@ -76,7 +76,7 @@ MetaPanel::MetaPanel( QWidget *parent,
metaLayout->addWidget( genre_text, line, 1, 1, 3 );
/* Number - on the same line */
metaLayout->addWidget( new QLabel( qtr( "Track Number" ) + " :" ),
metaLayout->addWidget( new QLabel( qtr( VLC_META_TRACK_NUMBER ) + " :" ),
line, 5, 1, 2 );
seqnum_text = new QLineEdit;
seqnum_text->setInputMask("0000");
......
......@@ -36,6 +36,8 @@
#include <QSettings>
#include "sorting.h"
/*************************************************************************
* Playlist item implementation
*************************************************************************/
......@@ -109,40 +111,12 @@ void PLItem::updateColumnHeaders()
{
item_col_strings.clear();
for( int i_index=1; i_index <= VLC_META_ENGINE_ART_URL; i_index *= 2 )
assert( i_showflags < COLUMN_END );
for( uint32_t i_index=1; i_index < COLUMN_END; i_index <<= 1 )
{
if( i_showflags & i_index )
{
switch( i_index )
{
case VLC_META_ENGINE_TRACKID:
item_col_strings.append( qtr( VLC_META_TRACKID ) );
break;
case VLC_META_ENGINE_ARTIST:
item_col_strings.append( qtr( VLC_META_ARTIST ) );
break;
case VLC_META_ENGINE_TITLE:
item_col_strings.append( qtr( VLC_META_TITLE ) );
break;
case VLC_META_ENGINE_DESCRIPTION:
item_col_strings.append( qtr( VLC_META_DESCRIPTION ) );
break;
case VLC_META_ENGINE_DURATION:
item_col_strings.append( qtr( VLC_META_DURATION ) );
break;
case VLC_META_ENGINE_GENRE:
item_col_strings.append( qtr( VLC_META_GENRE ) );
break;
case VLC_META_ENGINE_COLLECTION:
item_col_strings.append( qtr( VLC_META_COLLECTION ) );
break;
case VLC_META_ENGINE_SEQ_NUM:
item_col_strings.append( qtr( VLC_META_SEQ_NUM ) );
break;
default:
break;
}
}
item_col_strings.append( psz_column_title( i_index ) );
}
}
......@@ -206,63 +180,15 @@ void PLItem::update( playlist_item_t *p_item, bool iscurrent )
return;
}
#define ADD_META( item, meta ) \
psz_meta = input_item_Get ## meta ( item->p_input ); \
item_col_strings.append( qfu( psz_meta ) ); \
free( psz_meta );
assert( parentItem->i_showflags < COLUMN_END );
for( int i_index=1; i_index <= VLC_META_ENGINE_ART_URL; i_index *= 2 )
for( uint32_t i_index=1; i_index < COLUMN_END; i_index <<= 1 )
{
if( parentItem->i_showflags & i_index )
{
switch( i_index )
{
case VLC_META_ENGINE_ARTIST:
ADD_META( p_item, Artist );
break;
case VLC_META_ENGINE_TITLE:
char *psz_title;
psz_title = input_item_GetTitle( p_item->p_input );
if( psz_title )
{
ADD_META( p_item, Title );
free( psz_title );
}
else
{
psz_title = input_item_GetName( p_item->p_input );
if( psz_title )
{
item_col_strings.append( qfu( psz_title ) );
}
free( psz_title );
}
break;
case VLC_META_ENGINE_DESCRIPTION:
ADD_META( p_item, Description );
break;
case VLC_META_ENGINE_DURATION:
secstotimestr( psz_duration,
input_item_GetDuration( p_item->p_input ) / 1000000 );
item_col_strings.append( QString( psz_duration ) );
break;
case VLC_META_ENGINE_GENRE:
ADD_META( p_item, Genre );
break;
case VLC_META_ENGINE_COLLECTION:
ADD_META( p_item, Album );
break;
case VLC_META_ENGINE_SEQ_NUM:
ADD_META( p_item, TrackNum );
break;
case VLC_META_ENGINE_TRACKID:
item_col_strings.append( QString::number( p_item->i_id ) );
break;
default:
break;
}
char *psz = psz_column_meta( p_item->p_input, i_index );
item_col_strings.append( psz );
free( psz );
}
}
#undef ADD_META
}
......@@ -39,6 +39,8 @@
#include <QApplication>
#include <QSettings>
#include "sorting.h"
QIcon PLModel::icons[ITEM_TYPE_NUMBER];
static int PlaylistChanged( vlc_object_t *, const char *,
......@@ -72,8 +74,6 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
assert( i_depth == DEPTH_SEL || i_depth == DEPTH_PL );
p_intf = _p_intf;
p_playlist = _p_playlist;
i_items_to_append = 0;
b_need_update = false;
i_cached_id = -1;
i_cached_input_id = -1;
i_popup_item = i_popup_parent = -1;
......@@ -539,8 +539,6 @@ void PLModel::ProcessItemAppend( playlist_add_t *p_add )
{
playlist_item_t *p_item = NULL;
PLItem *newItem = NULL;
i_items_to_append--;
if( b_need_update ) return;
PLItem *nodeItem = FindById( rootItem, p_add->i_node );
PL_LOCK;
......@@ -719,23 +717,23 @@ void PLModel::sort( int column, Qt::SortOrder order )
#define CHECK_COLUMN( meta ) \
{ \
if( ( shownFlags() & VLC_META_ENGINE_##meta ) ) \
if( ( shownFlags() & meta ) ) \
i_index++; \
if( column == i_index ) \
{ \
i_flag = VLC_META_ENGINE_##meta; \
i_flag = meta; \
goto next; \
} \
}
CHECK_COLUMN( TRACKID );
CHECK_COLUMN( TITLE );
CHECK_COLUMN( DURATION );
CHECK_COLUMN( ARTIST );
CHECK_COLUMN( GENRE );
CHECK_COLUMN( COLLECTION );
CHECK_COLUMN( SEQ_NUM );
CHECK_COLUMN( DESCRIPTION );
CHECK_COLUMN( COLUMN_NUMBER );
CHECK_COLUMN( COLUMN_TITLE );
CHECK_COLUMN( COLUMN_DURATION );
CHECK_COLUMN( COLUMN_ARTIST );
CHECK_COLUMN( COLUMN_GENRE );
CHECK_COLUMN( COLUMN_ALBUM );
CHECK_COLUMN( COLUMN_TRACK_NUMBER );
CHECK_COLUMN( COLUMN_DESCRIPTION );
#undef CHECK_COLUMN
......@@ -745,22 +743,10 @@ next:
playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
rootItem->i_id,
true );
int i_mode;
switch( i_flag )
{
case VLC_META_ENGINE_TRACKID: i_mode = SORT_ID; break;
case VLC_META_ENGINE_TITLE: i_mode = SORT_TITLE_NODES_FIRST;break;
case VLC_META_ENGINE_DURATION: i_mode = SORT_DURATION; break;
case VLC_META_ENGINE_ARTIST: i_mode = SORT_ARTIST; break;
case VLC_META_ENGINE_GENRE: i_mode = SORT_GENRE; break;
case VLC_META_ENGINE_COLLECTION: i_mode = SORT_ALBUM; break;
case VLC_META_ENGINE_SEQ_NUM: i_mode = SORT_TRACK_NUMBER; break;
case VLC_META_ENGINE_DESCRIPTION:i_mode = SORT_DESCRIPTION; break;
default: i_mode = SORT_TITLE_NODES_FIRST;break;
}
if( p_root )
{
playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
playlist_RecursiveNodeSort( p_playlist, p_root,
i_column_sorting( i_flag ),
order == Qt::AscendingOrder ?
ORDER_NORMAL : ORDER_REVERSE );
p_playlist->b_reset_currently_playing = true;
......@@ -826,32 +812,16 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
void PLModel::viewchanged( int meta )
{
assert( meta );
if( rootItem )
{
int index=0;
switch( meta )
int index=-1;
while( meta )
{
case VLC_META_ENGINE_TRACKID:
index=0; break;
case VLC_META_ENGINE_TITLE:
index=1; break;
case VLC_META_ENGINE_DURATION:
index=2; break;
case VLC_META_ENGINE_ARTIST:
index=3; break;
case VLC_META_ENGINE_GENRE:
index=4; break;
case VLC_META_ENGINE_COPYRIGHT:
index=5; break;
case VLC_META_ENGINE_COLLECTION:
index=6; break;
case VLC_META_ENGINE_SEQ_NUM:
index=7; break;
case VLC_META_ENGINE_DESCRIPTION:
index=8; break;
default:
break;
index++;
meta >>= 1;
}
/* UNUSED emit layoutAboutToBeChanged(); */
index = __MIN( index, rootItem->item_col_strings.count() );
QModelIndex parent = createIndex( 0, 0, rootItem );
......@@ -969,11 +939,6 @@ static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
playlist_add_t *p_add = (playlist_add_t *)malloc( sizeof( playlist_add_t));
memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) );
if( ++p_model->i_items_to_append >= 50 )
{
// p_model->b_need_update = true;
// return VLC_SUCCESS;
}
PLEvent *event = new PLEvent( p_add );
QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
return VLC_SUCCESS;
......
......@@ -96,9 +96,6 @@ public:
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
bool b_need_update;
int i_items_to_append;
void rebuild(); void rebuild( playlist_item_t * );
bool hasRandom(); bool hasLoop(); bool hasRepeat();
......
/*****************************************************************************
* sorting.h : commun sorting & column display code
****************************************************************************
* Copyright © 2008 the VideoLAN team
* $Id$
*
* Authors: Rafaël Carré <funman@videolanorg>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* You can use these numbers with | and & to determine what you want to show */
enum
{
COLUMN_NUMBER = 0x0001,
COLUMN_TITLE = 0x0002,
COLUMN_DURATION = 0x0004,
COLUMN_ARTIST = 0x0008,
COLUMN_GENRE = 0x0010,
COLUMN_ALBUM = 0x0020,
COLUMN_TRACK_NUMBER = 0x0040,
COLUMN_DESCRIPTION = 0x0080,
/* Add new entries here */
COLUMN_END
};
/* Return the title of a column */
static const char * psz_column_title( uint32_t i_column )
{
switch( i_column )
{
case COLUMN_NUMBER: return "";
case COLUMN_TITLE: return VLC_META_TITLE;
case COLUMN_DURATION: return _("Duration");
case COLUMN_ARTIST: return VLC_META_ARTIST;
case COLUMN_GENRE: return VLC_META_GENRE;
case COLUMN_ALBUM: return VLC_META_ALBUM;
case COLUMN_TRACK_NUMBER: return VLC_META_TRACK_NUMBER;
case COLUMN_DESCRIPTION: return VLC_META_DESCRIPTION;
default: abort();
}
}
/* Return the meta data associated with an item for a column
* Returned value has to be freed */
static char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
{
char *psz;
int i_duration;
char psz_duration[MSTRTIME_MAX_SIZE];
switch( i_column )
{
case COLUMN_NUMBER:
return NULL;
case COLUMN_TITLE:
psz = input_item_GetTitle( p_item );
if( !psz )
psz = input_item_GetName( p_item );
return psz;
case COLUMN_DURATION:
i_duration = input_item_GetDuration( p_item ) / 1000000;
secstotimestr( psz_duration, i_duration );
return strdup( psz_duration );
case COLUMN_ARTIST:
return input_item_GetArtist( p_item );
case COLUMN_GENRE:
return input_item_GetGenre( p_item );
case COLUMN_ALBUM:
return input_item_GetAlbum( p_item );
case COLUMN_TRACK_NUMBER:
return input_item_GetTrackNum( p_item );
case COLUMN_DESCRIPTION:
return input_item_GetDescription( p_item );
default:
abort();
}
}
/* Return the playlist sorting mode for a given column */
static inline int i_column_sorting( uint32_t i_column )
{
switch( i_column )
{
case COLUMN_NUMBER: return SORT_ID;
case COLUMN_TITLE: return SORT_TITLE_NODES_FIRST;
case COLUMN_DURATION: return SORT_DURATION;
case COLUMN_ARTIST: return SORT_ARTIST;
case COLUMN_GENRE: return SORT_GENRE;
case COLUMN_ALBUM: return SORT_ALBUM;
case COLUMN_TRACK_NUMBER: return SORT_TRACK_NUMBER;
case COLUMN_DESCRIPTION: return SORT_DESCRIPTION;
default: abort();
}
}
......@@ -47,6 +47,8 @@
#include <assert.h>
#include "sorting.h"
StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
intf_thread_t *_p_intf,
playlist_t *p_playlist,
......@@ -265,24 +267,25 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
QMenu selectColMenu;
#define ADD_META_ACTION( meta ) { \
QAction* option = selectColMenu.addAction( qfu(VLC_META_##meta) ); \
option->setCheckable( true ); \
option->setChecked( model->shownFlags() & VLC_META_ENGINE_##meta ); \
ContextUpdateMapper->setMapping( option, VLC_META_ENGINE_##meta ); \
CONNECT( option, triggered(), ContextUpdateMapper, map() ); \
char *psz_title;
#define ADD_META_ACTION( meta ) { \
QAction* option = selectColMenu.addAction( psz_column_title( meta ) ); \
option->setCheckable( true ); \
option->setChecked( model->shownFlags() & meta ); \
ContextUpdateMapper->setMapping( option, meta ); \
CONNECT( option, triggered(), ContextUpdateMapper, map() ); \
}
CONNECT( ContextUpdateMapper, mapped( int ), model, viewchanged( int ) );
ADD_META_ACTION( TRACKID );
ADD_META_ACTION( TITLE );
ADD_META_ACTION( DURATION );
ADD_META_ACTION( ARTIST );
ADD_META_ACTION( GENRE );
ADD_META_ACTION( COLLECTION );
ADD_META_ACTION( SEQ_NUM );
ADD_META_ACTION( DESCRIPTION );
ADD_META_ACTION( COLUMN_NUMBER );
ADD_META_ACTION( COLUMN_TITLE );
ADD_META_ACTION( COLUMN_DURATION );
ADD_META_ACTION( COLUMN_ARTIST );
ADD_META_ACTION( COLUMN_GENRE );
ADD_META_ACTION( COLUMN_ALBUM );
ADD_META_ACTION( COLUMN_TRACK_NUMBER );
ADD_META_ACTION( COLUMN_DESCRIPTION );
#undef ADD_META_ACTION
......
......@@ -90,8 +90,8 @@ MetaDataPanel::MetaDataPanel( intf_thread_t *_p_intf,
ADD_META( VLC_META_ARTIST, artist_text );
ADD_META( VLC_META_GENRE, genre_text );
ADD_META( VLC_META_COPYRIGHT, copyright_text );
ADD_META( VLC_META_COLLECTION, collection_text );
ADD_META( VLC_META_SEQ_NUM, seqnum_text );
ADD_META( VLC_META_ALBUM, collection_text );
ADD_META( VLC_META_TRACK_NUMBER, seqnum_text );
ADD_META( VLC_META_DESCRIPTION, description_text );
ADD_META( VLC_META_RATING, rating_text );
ADD_META( VLC_META_DATE, date_text );
......
......@@ -41,7 +41,6 @@
* Local prototypes
*****************************************************************************/
static int FindArt( vlc_object_t * );
static int FindMetaMBId( vlc_object_t *p_this );
/*****************************************************************************
* Module descriptor
......@@ -51,22 +50,13 @@ vlc_module_begin();
set_shortname( N_( "MusicBrainz" ) );
set_description( _("MusicBrainz meta data") );
set_capability( "meta fetcher", 10 );
/* This meta fetcher module only retrieves the musicbrainz track id
* and stores it
* TODO:
* - Actually do it
* - Also store the album id
* */
set_callbacks( FindMetaMBId, NULL );
add_submodule();
/* This art finder module fetches the album ID from musicbrainz and
* uses it to fetch the amazon ASIN from musicbrainz.
* TODO:
* - Add ability to reuse MB album ID if we already have it
*/
set_capability( "art finder", 80 );
set_callbacks( FindArt, NULL );
/* This art finder module fetches the album ID from musicbrainz and
* uses it to fetch the amazon ASIN from musicbrainz.
* TODO:
* - Add ability to reuse MB album ID if we already have it
*/
set_capability( "art finder", 80 );
set_callbacks( FindArt, NULL );
vlc_module_end();
/*****************************************************************************
......@@ -169,23 +159,6 @@ static int GetData( vlc_object_t *p_obj, input_item_t *p_item,
return b_art_found ? VLC_SUCCESS : VLC_EGENERIC;
}
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;
int i_ret = GetData( VLC_OBJECT(p_me), p_item,
p_me->i_mandatory & VLC_META_ENGINE_ART_URL );
if( !i_ret )
{
uint32_t i_meta = input_CurrentMetaFlags( input_item_GetMetaObject( p_item ) );
p_me->i_mandatory &= ~i_meta;
p_me->i_optional &= ~i_meta;
return p_me->i_mandatory ? VLC_EGENERIC : VLC_SUCCESS;
}
return VLC_EGENERIC;
}
static int FindArt( vlc_object_t *p_this )
{
playlist_t *p_playlist = (playlist_t *)p_this;
......
......@@ -278,20 +278,6 @@ static int fetch_meta( vlc_object_t *p_this, const char * psz_filename,
return VLC_EGENERIC;
}
/*****************************************************************************
* Module entry point for meta.
*****************************************************************************/
int E_(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;
lua_State *L = vlclua_meta_init( p_this, p_item );
int i_ret = vlclua_scripts_batch_execute( p_this, "meta", &fetch_meta, L, p_item );
lua_close( L );
return i_ret;
}
/*****************************************************************************
* Module entry point for art.
*****************************************************************************/
......
......@@ -55,12 +55,6 @@
#define CONFIG_LONGTEXT N_("Lua interface configuration string. Format is: '[\"<interface module name>\"] = { <option> = <value>, ...}, ...'.")
vlc_module_begin();
add_submodule();
add_shortcut( "luameta" );
set_shortname( N_( "Lua Meta" ) );
set_description( _("Fetch metadata using lua scripts") );
set_capability( "meta fetcher", 10 );
set_callbacks( E_(FindMeta), NULL );
add_submodule();
set_shortname( N_( "Lua Art" ) );
set_description( _("Fetch artwork using lua scripts") );
......
......@@ -49,7 +49,6 @@
* Module entry points
*****************************************************************************/
int E_(FindArt)( vlc_object_t * );
int E_(FindMeta)( vlc_object_t * );
int E_(Import_LuaPlaylist)( vlc_object_t * );
void E_(Close_LuaPlaylist)( vlc_object_t * );
......
......@@ -884,8 +884,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
psz_value = GetAttribute( p_sap->p_sdp->pp_attributes, p_sap->p_sdp->i_attributes, "tool" );
if( psz_value != NULL )
{
input_ItemAddInfo( p_input, _("Session"), _("Tool"), "%s",
psz_value );
input_ItemAddInfo( p_input, _("Session"), _("Tool"), "%s", psz_value );
}
if( strcmp( p_sdp->username, "-" ) )
{
......
......@@ -285,9 +285,6 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
}
/* Remove 'Now playing' info as it is probably outdated */
input_Control( p_input, INPUT_DEL_INFO,
_(VLC_META_INFO_CAT),
_(VLC_META_NOW_PLAYING) );
input_item_SetNowPlaying( p_item, NULL );
/* */
......@@ -2633,7 +2630,6 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
input_item_t *p_item = p_input->p->input.p_item;
char * psz_arturl = NULL;
char *psz_title = NULL;
int i;
int i_arturl_event = false;
if( !p_meta )
......@@ -2697,19 +2693,6 @@ static void InputUpdateMeta( input_thread_t *p_input, vlc_meta_t *p_meta )
free( psz_title );
}
if( p_meta )
{
char ** ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags );
for( i = 0; ppsz_all_keys[i]; i++ )
{
input_Control( p_input, INPUT_ADD_INFO, _(VLC_META_INFO_CAT), _(ppsz_all_keys[i]),
vlc_dictionary_value_for_key( &p_meta->extra_tags, ppsz_all_keys[i] ) );
free( ppsz_all_keys[i] );
}
free( ppsz_all_keys );
vlc_meta_Delete( p_meta );
}
/** \todo handle sout meta */
}
......
......@@ -251,17 +251,6 @@ static inline void input_item_SetPreparsed( input_item_t *p_i, bool preparsed )
}
}
static inline void input_item_SetMetaFetched( input_item_t *p_i, bool metafetched )
{
if( !p_i->p_meta )
p_i->p_meta = vlc_meta_New();
if( metafetched )
p_i->p_meta->i_status |= ITEM_META_FETCHED;
else
p_i->p_meta->i_status &= ~ITEM_META_FETCHED;
}
static inline void input_item_SetArtNotFound( input_item_t *p_i, bool notfound )
{
if( !p_i->p_meta )
......@@ -296,10 +285,7 @@ typedef struct playlist_album_t
bool b_found;
} playlist_album_t;
int input_MetaFetch ( playlist_t *, input_item_t * );
int input_ArtFind ( playlist_t *, input_item_t * );
bool input_MetaSatisfied ( playlist_t*, input_item_t*,
uint32_t*, uint32_t* );
int input_DownloadAndCacheArt ( playlist_t *, input_item_t * );
/* Becarefull; p_item lock HAS to be taken */
......
......@@ -44,79 +44,35 @@
#include "../libvlc.h"
static const char * meta_type_to_string[VLC_META_TYPE_COUNT] =
{
[vlc_meta_Title] = N_("Title"),
[vlc_meta_Artist] = N_("Artist"),
[vlc_meta_Genre] = N_("Genre"),
[vlc_meta_Copyright] = N_("Copyright"),
[vlc_meta_Album] = N_("Album"),
[vlc_meta_TrackNumber] = N_("Track number"),
[vlc_meta_Description] = N_("Description"),
[vlc_meta_Rating] = N_("Rating"),
[vlc_meta_Date] = N_("Date"),
[vlc_meta_Setting] = N_("Setting"),
[vlc_meta_URL] = N_("URL"),
[vlc_meta_Language] = N_("Language"),
[vlc_meta_NowPlaying] = N_("Now Playing"),
[vlc_meta_Publisher] = N_("Publisher"),
[vlc_meta_EncodedBy] = N_("Encoded by"),
[vlc_meta_ArtworkURL] = N_("Artwork URL"),
[vlc_meta_TrackID] = N_("Track ID"),
};
const char *
input_MetaTypeToLocalizedString( vlc_meta_type_t meta_type )
{
return _(meta_type_to_string[meta_type]);
}
#define input_FindArtInCache(a,b) __input_FindArtInCache(VLC_OBJECT(a),b)
static int __input_FindArtInCache( vlc_object_t *, input_item_t *p_item );
bool input_MetaSatisfied( playlist_t *p_playlist, input_item_t *p_item,
uint32_t *pi_mandatory, uint32_t *pi_optional )
{
VLC_UNUSED(p_playlist);
*pi_mandatory = VLC_META_ENGINE_TITLE | VLC_META_ENGINE_ARTIST;
uint32_t i_meta = input_CurrentMetaFlags( p_item->p_meta );
*pi_mandatory &= ~i_meta;
*pi_optional = 0; /// Todo
return *pi_mandatory ? false:true;
}
int input_MetaFetch( playlist_t *p_playlist, input_item_t *p_item )
{
struct meta_engine_t *p_me;
uint32_t i_mandatory, i_optional;
input_MetaSatisfied( p_playlist, p_item, &i_mandatory, &i_optional );
// Meta shouldn't magically appear
assert( i_mandatory );
/* FIXME: object creation is overkill, use p_private */
p_me = vlc_custom_create( VLC_OBJECT(p_playlist), sizeof( *p_me ),
VLC_OBJECT_GENERIC, "meta engine" );
p_me->i_flags |= OBJECT_FLAGS_NOINTERACT;
p_me->i_flags |= OBJECT_FLAGS_QUIET;
p_me->i_mandatory = i_mandatory;
p_me->i_optional = i_optional;
p_me->p_item = p_item;
p_me->p_module = module_Need( p_me, "meta fetcher", 0, false );
if( !p_me->p_module )
switch( meta_type )
{
vlc_object_release( p_me );
return VLC_EGENERIC;
case vlc_meta_Title: return _("Title");
case vlc_meta_Artist: return _("Artist");
case vlc_meta_Genre: return _("Genre");
case vlc_meta_Copyright: return _("Copyright");
case vlc_meta_Album: return _("Album");
case vlc_meta_TrackNumber: return _("Track number");
case vlc_meta_Description: return _("Description");
case vlc_meta_Rating: return _("Rating");
case vlc_meta_Date: return _("Date");
case vlc_meta_Setting: return _("Setting");
case vlc_meta_URL: return _("URL");
case vlc_meta_Language: return _("Language");
case vlc_meta_NowPlaying: return _("Now Playing");
case vlc_meta_Publisher: return _("Publisher");
case vlc_meta_EncodedBy: return _("Encoded by");
case vlc_meta_ArtworkURL: return _("Artwork URL");
case vlc_meta_TrackID: return _("Track ID");
default: abort();
}
module_Unneed( p_me, p_me->p_module );
vlc_object_release( p_me );
input_item_SetMetaFetched( p_item, true );
};
return VLC_SUCCESS;
}
#define input_FindArtInCache(a,b) __input_FindArtInCache(VLC_OBJECT(a),b)
static int __input_FindArtInCache( vlc_object_t *, input_item_t *p_item );
/* Return codes:
* 0 : Art is in cache or is a local file
......@@ -576,35 +532,3 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input )
fclose( f );
}
}
uint32_t input_CurrentMetaFlags( const vlc_meta_t *p_meta )
{
uint32_t i_meta = 0;
if( !p_meta )
return 0;
#define CHECK( a, b ) \
if( !EMPTY_STR( vlc_meta_Get( p_meta, vlc_meta_ ## a ) ) ) \
i_meta |= VLC_META_ENGINE_ ## b;
CHECK( Title, TITLE )
CHECK( Artist, ARTIST )
CHECK( Album, COLLECTION )
#if 0
/* As this is not used at the moment, don't uselessly check for it.
* Re-enable this when it is used */
CHECK( Genre, GENRE )
CHECK( Copyright, COPYRIGHT )
CHECK( Tracknum, SEQ_NUM )
CHECK( Description, DESCRIPTION )
CHECK( Rating, RATING )
CHECK( Date, DATE )
CHECK( URL, URL )
CHECK( Language, LANGUAGE )
#endif
CHECK( ArtworkURL, ART_URL )
return i_meta;
}
......@@ -1074,11 +1074,6 @@ static const char *ppsz_clock_descriptions[] =
"Automatically preparse files added to the playlist " \
"(to retrieve some metadata)." )
#define FETCH_META_TEXT N_( "Authorise meta information fetching" )
#define FETCH_META_LONGTEXT N_( \
"Specify if you want to attempt to fetch files'"\
"meta informations using the network." )
#define ALBUM_ART_TEXT N_( "Album art policy" )
#define ALBUM_ART_LONGTEXT N_( \
"Choose how album art will be downloaded." )
......@@ -1872,9 +1867,6 @@ vlc_module_begin();
add_bool( "auto-preparse", true, NULL, PREPARSE_TEXT,
PREPARSE_LONGTEXT, false );
add_integer( "fetch-meta", true, NULL, FETCH_META_TEXT,
FETCH_META_LONGTEXT, false );
add_integer( "album-art", ALBUM_ART_WHEN_ASKED, NULL, ALBUM_ART_TEXT,
ALBUM_ART_LONGTEXT, false );
change_integer_list( pi_albumart_values,
......
......@@ -123,7 +123,6 @@ InitMD5
input_AddSubtitles
input_Control
__input_CreateThread
input_CurrentMetaFlags
input_DecoderDecode
input_DecoderDelete
input_DecoderNew
......
......@@ -202,18 +202,13 @@ int playlist_AskForArtEnqueue( playlist_t *p_playlist,
input_item_t *p_item )
{
int i;
preparse_item_t p;
p.p_item = p_item;
p.b_fetch_art = true;
vlc_object_lock( p_playlist->p_fetcher );
for( i = 0; i < p_playlist->p_fetcher->i_waiting &&
p_playlist->p_fetcher->p_waiting->b_fetch_art == true;
i++ );
for( i = 0; i < p_playlist->p_fetcher->i_waiting ; i++ );
vlc_gc_incref( p_item );
INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
INSERT_ELEM( p_playlist->p_fetcher->pp_waiting,
p_playlist->p_fetcher->i_waiting,
i, p );
i, p_item );
vlc_object_signal_unlocked( p_playlist->p_fetcher );
vlc_object_unlock( p_playlist->p_fetcher );
return VLC_SUCCESS;
......
......@@ -499,7 +499,6 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
input_item_t *p_current;
int i_activity;
uint32_t i_m, i_o;
while( !p_playlist->b_die )
{
......@@ -544,31 +543,14 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
*/
char *psz_arturl = input_item_GetArtURL( p_current );
char *psz_name = input_item_GetName( p_current );
if( !input_MetaSatisfied( p_playlist, p_current, &i_m, &i_o ) )
{
preparse_item_t p;
PL_DEBUG( "need to fetch meta for %s", p_current->psz_name );
p.p_item = p_current;
p.b_fetch_art = false;
vlc_object_lock( p_playlist->p_fetcher );
INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
p_playlist->p_fetcher->i_waiting,
p_playlist->p_fetcher->i_waiting, p);
vlc_object_signal_unlocked( p_playlist->p_fetcher );
vlc_object_unlock( p_playlist->p_fetcher );
}
/* We already have all needed meta, but we need art right now */
else if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
( !psz_arturl || strncmp( psz_arturl, "file://", 7 ) ) )
{
preparse_item_t p;
PL_DEBUG("meta ok for %s, need to fetch art", psz_name );
p.p_item = p_current;
p.b_fetch_art = true;
vlc_object_lock( p_playlist->p_fetcher );
INSERT_ELEM( p_playlist->p_fetcher->p_waiting,
INSERT_ELEM( p_playlist->p_fetcher->pp_waiting,
p_playlist->p_fetcher->i_waiting,
p_playlist->p_fetcher->i_waiting, p);
p_playlist->p_fetcher->i_waiting, p_current);
vlc_object_signal_unlocked( p_playlist->p_fetcher );
vlc_object_unlock( p_playlist->p_fetcher );
}
......@@ -604,7 +586,6 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
void playlist_FetcherLoop( playlist_fetcher_t *p_obj )
{
playlist_t *p_playlist = (playlist_t *)p_obj->p_parent;
bool b_fetch_art;
input_item_t *p_item;
int i_activity;
......@@ -621,83 +602,52 @@ void playlist_FetcherLoop( playlist_fetcher_t *p_obj )
}
}
b_fetch_art = p_obj->p_waiting->b_fetch_art;
p_item = p_obj->p_waiting->p_item;
REMOVE_ELEM( p_obj->p_waiting, p_obj->i_waiting, 0 );
p_item = p_obj->pp_waiting[0];
REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
vlc_mutex_unlock( &p_obj->object_lock );
if( p_item )
{
if( !b_fetch_art )
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++ )
{
/* If the user doesn't want us to fetch meta automatically
* abort here. */
if( p_playlist->p_fetcher->b_fetch_meta )
{
input_MetaFetch( p_playlist, p_item );
var_SetInteger( p_playlist, "item-change", p_item->i_id );
}
bool 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 );
}
/* 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 = 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;
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, true );
else {
input_item_SetArtFetched( p_item, true );
var_SetInteger( p_playlist, "item-change",
p_item->i_id );
}
else
vlc_gc_decref( p_item );
}
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, true );
var_SetInteger( p_playlist, "item-change", p_item->i_id );
}
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++ )
{
bool 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, true );
else {
input_item_SetArtFetched( p_item, 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, 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, true );
}
vlc_gc_decref( p_item );
}
PL_DEBUG( "art not found for %s", p_item->psz_name );
input_item_SetArtNotFound( p_item, true );
}
vlc_gc_decref( p_item );
}
vlc_object_lock( p_obj );
i_activity = var_GetInteger( p_playlist, "activity" );
......
......@@ -44,20 +44,13 @@ struct playlist_preparse_t
input_item_t **pp_waiting;
};
typedef struct preparse_item_t
{
input_item_t *p_item;
bool b_fetch_art;
} preparse_item_t;
struct playlist_fetcher_t
{
VLC_COMMON_MEMBERS
vlc_mutex_t lock;
int i_art_policy;
bool b_fetch_meta;
int i_waiting;
preparse_item_t *p_waiting;
input_item_t **pp_waiting;
DECL_ARRAY(playlist_album_t) albums;
};
......
......@@ -93,9 +93,7 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent )
return;
}
p_playlist->p_fetcher->i_waiting = 0;
p_playlist->p_fetcher->p_waiting = NULL;
p_playlist->p_fetcher->b_fetch_meta = var_CreateGetInteger( p_playlist,
"fetch-meta" );
p_playlist->p_fetcher->pp_waiting = NULL;
p_playlist->p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist,
"album-art" );
......@@ -203,5 +201,5 @@ static void PreparseDestructor( vlc_object_t * p_this )
static void FetcherDestructor( vlc_object_t * p_this )
{
playlist_fetcher_t * p_fetcher = (playlist_fetcher_t *)p_this;
free( p_fetcher->p_waiting );
free( p_fetcher->pp_waiting );
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment