From 62bd7af887b612e9c8e2b5805dd57a3b2027560c Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sun, 23 Aug 2009 19:20:44 +0300 Subject: [PATCH] Use a VLC object for meta reader --- include/vlc_common.h | 1 - include/vlc_demux.h | 6 ++++-- modules/meta_engine/id3tag.c | 6 +++--- modules/meta_engine/taglib.cpp | 12 ++++++------ src/input/input.c | 9 ++++++--- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/vlc_common.h b/include/vlc_common.h index 668df55179..488057fdda 100644 --- a/include/vlc_common.h +++ b/include/vlc_common.h @@ -184,7 +184,6 @@ typedef struct access_sys_t access_sys_t; typedef struct stream_t stream_t; typedef struct stream_sys_t stream_sys_t; typedef struct demux_t demux_t; -typedef struct demux_meta_t demux_meta_t; typedef struct demux_sys_t demux_sys_t; typedef struct es_out_t es_out_t; typedef struct es_out_id_t es_out_id_t; diff --git a/include/vlc_demux.h b/include/vlc_demux.h index 9abdee0831..68204d144b 100644 --- a/include/vlc_demux.h +++ b/include/vlc_demux.h @@ -78,13 +78,15 @@ struct demux_t /* demux_meta_t is returned by "meta reader" module to the demuxer */ -struct demux_meta_t +typedef struct demux_meta_t { + VLC_COMMON_MEMBERS + demux_t *p_demux; /** FIXME: use stream_t instead? */ vlc_meta_t *p_meta; /**< meta data */ int i_attachments; /**< number of attachments */ input_attachment_t **attachments; /**< array of attachments */ -}; +} demux_meta_t; enum demux_query_e { diff --git a/modules/meta_engine/id3tag.c b/modules/meta_engine/id3tag.c index 5de5ca45b8..bc49eca7e4 100644 --- a/modules/meta_engine/id3tag.c +++ b/modules/meta_engine/id3tag.c @@ -485,12 +485,12 @@ static void CheckHeader( demux_t *p_demux ) ****************************************************************************/ static int ParseTags( vlc_object_t *p_this ) { - demux_t *p_demux = (demux_t *)p_this; - demux_meta_t *p_demux_meta = (demux_meta_t*)p_demux->p_private; + demux_meta_t *p_demux_meta = (demux_meta_t *)p_this; + demux_t *p_demux = (demux_t *)p_demux_meta->p_demux; bool b_seekable; int64_t i_init; - msg_Dbg( p_demux, "checking for ID3v1/2 and APEv1/2 tags" ); + msg_Dbg( p_demux_meta, "checking for ID3v1/2 and APEv1/2 tags" ); stream_Control( p_demux->s, STREAM_CAN_FASTSEEK, &b_seekable ); if( !b_seekable ) return VLC_EGENERIC; diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp index 227ed04f75..724fcfc50d 100644 --- a/modules/meta_engine/taglib.cpp +++ b/modules/meta_engine/taglib.cpp @@ -224,7 +224,7 @@ static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_t* p_demux, demux_meta_t* if( !strncmp( psz_mime, "PNG", 3 ) || !strncmp( psz_name, "\xC2\x89PNG", 5 ) ) { - msg_Warn( p_demux, "Invalid picture embedded by broken iTunes version" ); + msg_Warn( p_demux_meta, "Invalid picture embedded by broken iTunes version" ); free( psz_description ); continue; } @@ -233,7 +233,7 @@ static void ReadMetaFromId3v2( ID3v2::Tag* tag, demux_t* p_demux, demux_meta_t* const char *p_data = picture.data(); const unsigned i_data = picture.size(); - msg_Dbg( p_demux, "Found embedded art: %s (%s) is %u bytes", + msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %u bytes", psz_name, psz_mime, i_data ); p_attachment = vlc_input_attachment_New( psz_name, psz_mime, @@ -282,7 +282,7 @@ static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_t* p_demux, demux_met // We get only the first covert art if( mime_list.size() > 1 || art_list.size() > 1 ) - msg_Warn( p_demux, "Found %i embedded arts, so using only the first one", + msg_Warn( p_demux_meta, "Found %i embedded arts, so using only the first one", art_list.size() ); else if( mime_list.size() == 0 || art_list.size() == 0 ) return; @@ -296,7 +296,7 @@ static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_t* p_demux, demux_met uint8_t *p_data; int i_data = vlc_b64_decode_binary( &p_data, art_list[0].toCString(true) ); - msg_Dbg( p_demux, "Found embedded art: %s (%s) is %i bytes", + msg_Dbg( p_demux_meta, "Found embedded art: %s (%s) is %i bytes", psz_name, psz_mime, i_data ); TAB_INIT( p_demux_meta->i_attachments, p_demux_meta->attachments ); @@ -320,8 +320,8 @@ static void ReadMetaFromXiph( Ogg::XiphComment* tag, demux_t* p_demux, demux_met */ static int ReadMeta( vlc_object_t* p_this) { - demux_t* p_demux = (demux_t*)p_this; - demux_meta_t* p_demux_meta = (demux_meta_t*)p_demux->p_private; + demux_meta_t* p_demux_meta = (demux_meta_t *)p_this; + demux_t* p_demux = p_demux_meta->p_demux; vlc_meta_t* p_meta; FileRef f; diff --git a/src/input/input.c b/src/input/input.c index 2de863f701..f179a6711e 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -2749,11 +2749,14 @@ static void InputSourceMeta( input_thread_t *p_input, if( !b_bool ) return; - demux_meta_t *p_demux_meta = p_demux->p_private = calloc( 1, sizeof(*p_demux_meta) ); + demux_meta_t *p_demux_meta = + vlc_custom_create( p_demux, sizeof( *p_demux_meta ), + VLC_OBJECT_GENERIC, "demux meta" ); if( !p_demux_meta ) return; + p_demux_meta->p_demux = p_demux; - module_t *p_id3 = module_need( p_demux, "meta reader", NULL, false ); + module_t *p_id3 = module_need( p_demux_meta, "meta reader", NULL, false ); if( p_id3 ) { if( p_demux_meta->p_meta ) @@ -2771,7 +2774,7 @@ static void InputSourceMeta( input_thread_t *p_input, } module_unneed( p_demux, p_id3 ); } - free( p_demux_meta ); + vlc_object_release( p_demux_meta ); } -- 2.39.2