static void CatalogAdd( xml_t *, const char *, const char *, const char * );
static int StreamRead( void *p_context, char *p_buffer, int i_buffer );
+static unsigned refs = 0;
+static vlc_mutex_t lock = VLC_STATIC_MUTEX;
+
/*****************************************************************************
* Module initialization
*****************************************************************************/
{
xml_t *p_xml = (xml_t *)p_this;
- xmlInitParser();
+ if( !xmlHasFeature( XML_WITH_THREAD ) )
+ return VLC_EGENERIC;
+
+ vlc_mutex_lock( &lock );
+ if( refs++ == 0 )
+ xmlInitParser();
+ vlc_mutex_unlock( &lock );
p_xml->pf_reader_create = ReaderCreate;
p_xml->pf_reader_delete = ReaderDelete;
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
- xmlCleanupParser();
+ vlc_mutex_lock( &lock );
+ if( --refs == 0 )
+ xmlCleanupParser();
+ vlc_mutex_unlock( &lock );
+
VLC_UNUSED(p_this);
return;
}