X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcontrol%2Fcore.c;h=f4f5aeb76c83bfcc60a21f5e356e41939c555bf1;hb=12c291f038deb29afafc050b67b81df6786fc2b9;hp=2934e09ee2c9f3d774b0e7b9884441f568cda3f6;hpb=de277e80b5445affffbb17b8e2d16c6d525c0f7c;p=vlc diff --git a/src/control/core.c b/src/control/core.c index 2934e09ee2..f4f5aeb76c 100644 --- a/src/control/core.c +++ b/src/control/core.c @@ -4,7 +4,7 @@ * Copyright (C) 2005 the VideoLAN team * $Id$ * - * Authors: Cl�ent Stenac + * Authors: Clément Stenac * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,10 +21,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #include -#include +#include "libvlc_internal.h" #include -#include +#include /************************************************************************* * Exceptions handling @@ -45,7 +45,7 @@ void libvlc_exception_clear( libvlc_exception_t *p_exception ) inline int libvlc_exception_raised( libvlc_exception_t *p_exception ) { - return p_exception->b_raised; + return (NULL != p_exception) && p_exception->b_raised; } inline char* libvlc_exception_get_message( libvlc_exception_t *p_exception ) @@ -58,19 +58,18 @@ inline char* libvlc_exception_get_message( libvlc_exception_t *p_exception ) } inline void libvlc_exception_raise( libvlc_exception_t *p_exception, - char *psz_format, ... ) + const char *psz_format, ... ) { va_list args; /* does caller care about exceptions ? */ - if( p_exception == NULL ) - return; + if( p_exception == NULL ) return; /* remove previous exception if it wasn't cleared */ if( p_exception->b_raised && p_exception->psz_message ) { - free(p_exception->psz_message); - p_exception->psz_message = NULL; + free(p_exception->psz_message); + p_exception->psz_message = NULL; } va_start( args, psz_format ); @@ -81,59 +80,47 @@ inline void libvlc_exception_raise( libvlc_exception_t *p_exception, } libvlc_instance_t * libvlc_new( int argc, char **argv, - libvlc_exception_t *p_exception ) + libvlc_exception_t *p_e ) { - int i_vlc_id; libvlc_instance_t *p_new; - vlc_t *p_vlc; - i_vlc_id = VLC_Create(); - p_vlc = (vlc_t* ) vlc_current_object( i_vlc_id ); + libvlc_int_t *p_libvlc_int = libvlc_InternalCreate(); + if( !p_libvlc_int ) RAISENULL( "VLC initialization failed" ); - if( !p_vlc ) - { - libvlc_exception_raise( p_exception, "VLC initialization failed" ); - return NULL; - } p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) ); + if( !p_new ) RAISENULL( "Out of memory" ); /** \todo Look for interface settings. If we don't have any, add -I dummy */ - /* Because we probably don't want a GUI by default */ - - if( !p_new ) - { - libvlc_exception_raise( p_exception, "Out of memory" ); - return NULL; - } + /* Because we probably don't want a GUI by default */ - VLC_Init( i_vlc_id, argc, argv ); + if( libvlc_InternalInit( p_libvlc_int, argc, argv ) ) + RAISENULL( "VLC initialization failed" ); - p_new->p_vlc = p_vlc; - p_new->p_playlist = (playlist_t *)vlc_object_find( p_new->p_vlc, - VLC_OBJECT_PLAYLIST, FIND_CHILD ); + p_new->p_libvlc_int = p_libvlc_int; p_new->p_vlm = NULL; - - if( !p_new->p_playlist ) - { - libvlc_exception_raise( p_exception, "Playlist creation failed" ); - return NULL; - } - p_new->i_vlc_id = i_vlc_id; + p_new->b_playlist_locked = 0; + p_new->p_callback_list = NULL; + vlc_mutex_init(p_libvlc_int, &p_new->instance_lock); return p_new; } -void libvlc_destroy( libvlc_instance_t *p_instance ) +void libvlc_destroy( libvlc_instance_t *p_instance, libvlc_exception_t *p_e ) { - if( p_instance->p_playlist ) - vlc_object_release( p_instance->p_playlist ); - vlc_object_release( p_instance->p_vlc ); - VLC_CleanUp( p_instance->i_vlc_id ); - VLC_Destroy( p_instance->i_vlc_id ); + struct libvlc_callback_entry_list_t *p_listitem = p_instance->p_callback_list; + + while( p_listitem ) + { + struct libvlc_callback_entry_list_t *p_nextlistitem = p_listitem->next; + free( p_listitem ); + p_listitem = p_nextlistitem; + } + + libvlc_InternalCleanup( p_instance->p_libvlc_int ); + libvlc_InternalDestroy( p_instance->p_libvlc_int, VLC_FALSE ); } int libvlc_get_vlc_id( libvlc_instance_t *p_instance ) { - return p_instance->i_vlc_id; + return p_instance->p_libvlc_int->i_object_id; } -