+static void AppendAttachment( int *pi_attachment, input_attachment_t ***ppp_attachment,
+ int i_new, input_attachment_t **pp_new )
+{
+ int i_attachment = *pi_attachment;
+ input_attachment_t **attachment = *ppp_attachment;
+ int i;
+
+ attachment = realloc( attachment,
+ sizeof(input_attachment_t**) * ( i_attachment + i_new ) );
+ for( i = 0; i < i_new; i++ )
+ attachment[i_attachment++] = pp_new[i];
+ if( pp_new )
+ free( pp_new );
+
+ /* */
+ *pi_attachment = i_attachment;
+ *ppp_attachment = attachment;
+}
+
+static void DemuxMeta( input_thread_t *p_input, vlc_meta_t *p_meta, demux_t *p_demux )
+{
+ vlc_bool_t b_bool;
+ module_t *p_id3;
+
+
+#if 0
+ /* XXX I am not sure it is a great idea, besides, there is more than that
+ * if we want to do it right */
+ vlc_mutex_lock( &p_item->lock );
+ if( p_item->p_meta && (p_item->p_meta->i_status & ITEM_PREPARSED ) )
+ {
+ vlc_mutex_unlock( &p_item->lock );
+ return;
+ }
+ vlc_mutex_unlock( &p_item->lock );
+#endif
+
+ demux2_Control( p_demux, DEMUX_GET_META, p_meta );
+ if( demux2_Control( p_demux, DEMUX_HAS_UNSUPPORTED_META, &b_bool ) )
+ return;
+ if( !b_bool )
+ return;
+
+ p_demux->p_private = malloc( sizeof( demux_meta_t ) );
+ if(! p_demux->p_private )
+ return;
+
+ p_id3 = module_Need( p_demux, "meta reader", NULL, 0 );
+ if( p_id3 )
+ {
+ demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
+
+ if( p_demux_meta->p_meta )
+ {
+ vlc_meta_Merge( p_meta, p_demux_meta->p_meta );
+ vlc_meta_Delete( p_demux_meta->p_meta );
+ }
+
+ if( p_demux_meta->i_attachments > 0 )
+ {
+ vlc_mutex_lock( &p_input->p->input.p_item->lock );
+ AppendAttachment( &p_input->p->i_attachment, &p_input->p->attachment,
+ p_demux_meta->i_attachments, p_demux_meta->attachments );
+ vlc_mutex_unlock( &p_input->p->input.p_item->lock );
+ }
+ module_Unneed( p_demux, p_id3 );
+ }
+ free( p_demux->p_private );
+}
+