Commit b28313ac authored by Anatoliy Anischovich's avatar Anatoliy Anischovich Committed by Rafaël Carré

taglib: use iterator-based approach for APE's tag processing

Signed-off-by: Rafaël Carré's avatarRafaël Carré <funman@videolan.org>
parent cfa3c0ea
...@@ -135,14 +135,17 @@ static void ExtractTrackNumberValues( vlc_meta_t* p_meta, const char *psz_value ...@@ -135,14 +135,17 @@ static void ExtractTrackNumberValues( vlc_meta_t* p_meta, const char *psz_value
*/ */
static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta ) static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta_t* p_meta )
{ {
APE::Item item; APE::ItemListMap fields ( tag->itemListMap() );
APE::ItemListMap::Iterator iter;
item = tag->itemListMap()["COVER ART (FRONT)"]; iter = fields.find("COVER ART (FRONT)");
if( !item.isEmpty() && item.type() == APE::Item::Binary) if( iter != fields.end()
&& !iter->second.isEmpty()
&& !iter->second.type() == APE::Item::Binary)
{ {
input_attachment_t *p_attachment; input_attachment_t *p_attachment;
const ByteVector picture = item.binaryData(); const ByteVector picture = iter->second.binaryData();
const char *p_data = picture.data(); const char *p_data = picture.data();
unsigned i_data = picture.size(); unsigned i_data = picture.size();
...@@ -174,15 +177,23 @@ static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta ...@@ -174,15 +177,23 @@ static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta
} }
} }
} }
fields.erase(iter);
} }
#define SET( keyName, metaName ) \ #define SET( keyName, metaName ) \
item = tag->itemListMap()[keyName]; \ iter = fields.find(keyName); \
if( !item.isEmpty() ) vlc_meta_Set##metaName( p_meta, item.toString().toCString( true ) ); if( iter != fields.end() && !iter->second.isEmpty() ) { \
vlc_meta_Set##metaName( p_meta, iter->second.toString().toCString( true ) ); \
fields.erase(iter); \
}
#define SET_EXTRA( keyName, metaName ) \ #define SET_EXTRA( keyName, metaName ) \
item = tag->itemListMap()[keyName]; \ iter = fields.find( keyName ); \
if( !item.isEmpty() ) vlc_meta_AddExtra( p_meta, metaName, item.toString().toCString( true ) ); if( iter != fields.end() && !iter->second.isEmpty() ) { \
vlc_meta_AddExtra( p_meta, metaName, iter->second.toString().toCString( true ) ); \
fields.erase(iter); \
}
SET( "ALBUM", Album ); SET( "ALBUM", Album );
SET( "ARTIST", Artist ); SET( "ARTIST", Artist );
...@@ -200,10 +211,25 @@ static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta ...@@ -200,10 +211,25 @@ static void ReadMetaFromAPE( APE::Tag* tag, demux_meta_t* p_demux_meta, vlc_meta
#undef SET_EXTRA #undef SET_EXTRA
/* */ /* */
item = tag->itemListMap()["TRACK"]; iter = fields.find( "TRACK" );
if( !item.isEmpty() ) if( iter != fields.end() && !iter->second.isEmpty() )
{
ExtractTrackNumberValues( p_meta, iter->second.toString().toCString( true ) );
fields.erase( iter );
}
/* Remainings */
for( iter = fields.begin(); iter != fields.end(); ++iter )
{ {
ExtractTrackNumberValues( p_meta, item.toString().toCString( true ) ); if( iter->second.isEmpty() )
continue;
if( iter->second.type() != APE::Item::Text )
continue;
vlc_meta_AddExtra( p_meta,
iter->first.toCString( true ),
iter->second.toString().toCString( true ) );
} }
} }
......
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