X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finput%2Fmeta.c;h=5d7e9804426613be57c54f230a287626ddd1134c;hb=8b69f37b61ff8a729ace73b2ee16fe29d877f7a6;hp=3e43899d4f3b0bb7496187593b7c0b7dda742286;hpb=b470029af29b0d5595fc6e83d64421997de75ce9;p=vlc diff --git a/src/input/meta.c b/src/input/meta.c index 3e43899d4f..5d7e980442 100644 --- a/src/input/meta.c +++ b/src/input/meta.c @@ -26,10 +26,13 @@ # include "config.h" #endif +#include + #include #include #include #include +#include #include "input_internal.h" #include "../playlist/art.h" @@ -46,28 +49,29 @@ struct vlc_meta_t /* FIXME bad name convention */ const char * vlc_meta_TypeToLocalizedString( vlc_meta_type_t meta_type ) { - switch( meta_type ) + static const char posix_names[][16] = { - 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(); - } + [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"), + }; + + assert (meta_type < (sizeof(posix_names) / sizeof(posix_names[0]))); + return vlc_gettext (posix_names[meta_type]); }; @@ -205,13 +209,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,48 +257,39 @@ void input_ExtractAttachmentAndCacheArt( input_thread_t *p_input ) vlc_input_attachment_Delete( p_attachment ); exit: - pl_Release( p_input ); free( psz_arturl ); } int input_item_WriteMeta( vlc_object_t *obj, input_item_t *p_item ) { meta_export_t *p_export = - vlc_custom_create( obj, sizeof( *p_export ), VLC_OBJECT_GENERIC, - "meta writer" ); + vlc_custom_create( obj, sizeof( *p_export ), "meta writer" ); if( p_export == NULL ) return VLC_ENOMEM; - vlc_object_attach( p_export, obj ); p_export->p_item = p_item; int type; 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; }