Commit f36f4152 authored by Thomas Guillem's avatar Thomas Guillem

dialog: change dialog_provider init/deinit functions

In order to behave like libvlc_Internal* functions.
parent 144ebc43
......@@ -28,12 +28,12 @@ typedef struct vlc_dialog_id vlc_dialog_id;
typedef struct extension_dialog_t extension_dialog_t;
/* Called from src/libvlc.c */
vlc_dialog_provider *
vlc_dialog_provider_new(void);
int
libvlc_dialog_provider_init(libvlc_int_t *p_libvlc);
/* Called from src/libvlc.c */
void
vlc_dialog_provider_release(vlc_dialog_provider *p_provider);
libvlc_dialog_provider_deinit(libvlc_int_t *p_libvlc);
/**
* @defgroup vlc_dialog VLC dialog
......
......@@ -145,12 +145,13 @@ dialog_id_release(vlc_dialog_id *p_id)
free(p_id);
}
vlc_dialog_provider *
vlc_dialog_provider_new(void)
int
libvlc_dialog_provider_init(libvlc_int_t *p_libvlc)
{
assert(p_libvlc != NULL);
vlc_dialog_provider *p_provider = malloc(sizeof(*p_provider));
if( p_provider == NULL )
return NULL;
if (p_provider == NULL)
return VLC_EGENERIC;
vlc_mutex_init(&p_provider->lock);
vlc_array_init(&p_provider->dialog_array);
......@@ -160,8 +161,9 @@ vlc_dialog_provider_new(void)
p_provider->pf_ext_update = NULL;
p_provider->p_ext_data = NULL;
libvlc_priv(p_libvlc)->p_dialog_provider = p_provider;
return p_provider;
return VLC_SUCCESS;
}
static int
......@@ -239,9 +241,10 @@ dialog_clear_all_locked(vlc_dialog_provider *p_provider)
}
void
vlc_dialog_provider_release(vlc_dialog_provider *p_provider)
libvlc_dialog_provider_deinit(libvlc_int_t *p_libvlc)
{
assert(p_provider != NULL);
assert(p_libvlc != NULL);
vlc_dialog_provider *p_provider = libvlc_priv(p_libvlc)->p_dialog_provider;
vlc_mutex_lock(&p_provider->lock);
dialog_clear_all_locked(p_provider);
......@@ -249,6 +252,7 @@ vlc_dialog_provider_release(vlc_dialog_provider *p_provider)
vlc_mutex_destroy(&p_provider->lock);
free(p_provider);
libvlc_priv(p_libvlc)->p_dialog_provider = NULL;
}
#undef vlc_dialog_provider_set_callbacks
......
......@@ -235,8 +235,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
}
#endif
priv->p_dialog_provider = vlc_dialog_provider_new();
if( priv->p_dialog_provider == NULL )
if( libvlc_dialog_provider_init( p_libvlc ) != VLC_SUCCESS )
{
vlc_LogDeinit (p_libvlc);
module_EndBank (true);
......@@ -511,7 +510,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
libvlc_Quit( p_libvlc );
intf_DestroyAll( p_libvlc );
vlc_dialog_provider_release( priv->p_dialog_provider );
libvlc_dialog_provider_deinit( p_libvlc );
#ifdef ENABLE_VLM
/* Destroy VLM if created in libvlc_InternalInit */
......
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