[vlc-devel] A little coding advice needed for creating stream_t objects.
Bill C. Riemers
briemers at redhat.com
Mon Jul 7 19:10:06 CEST 2008
Opps. What I provided was a slight simplification of my actual code.
But I see I forgot to adjust to the void return type I specified in my
sample.
My actual code does return a value I can later use for a VLC_Destroy
function...
Here is the actual code I use:
void *VLC_Init() {
vlcmodule_t *p_vlcmodule = (vlcmodule_t *)calloc(1,sizeof(vlcmodule_t));
if(p_vlcmodule == NULL ) {
goto outofmemory;
}
p_vlcmodule->destroy = vlcmodule_destroy;
libvlc_exception_t *p_ex = &p_vlcmodule->ex;
libvlc_exception_t *p_dummy = &p_vlcmodule->dummy;
libvlc_exception_init (p_ex);
libvlc_exception_init (p_dummy);
static const char *args[] = {"cvlc","-I","dummy",NULL};
p_vlcmodule->vlc = libvlc_new(3,args,p_ex);
if (p_vlcmodule->vlc == NULL)
{
goto error;
}
libvlc_add_intf (p_vlcmodule->vlc, "signals", p_dummy);
libvlc_add_intf (p_vlcmodule->vlc, NULL, p_ex);
libvlc_vlm_init (p_vlcmodule->vlc, p_ex);
p_vlm = (vlc_object_t *)p_vlcmodule->vlc->p_vlm;
p_close_list = createDoubleLinkList(close_list_element_destroy);
return p_vlcmodule;
error:
VLC_Destroy((vlc_object_t *)p_vlcmodule);
return NULL;
outofmemory:
{
libvlc_exception_t ex;
libvlc_exception_init ( &ex );
libvlc_exception_raise( &ex, "Out of memory.");
}
return NULL;
}
More information about the vlc-devel
mailing list