X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcontrol%2Fmedia_library.c;h=9b4d63012e52c4f594a923d06566352b6f38056e;hb=dacbb93b54623c1fbabdc4c4ebcb0b0a430f197f;hp=17dae9efc468fe50087a050c9e14228b61331473;hpb=ce15679f87cbf14c9d1cbdbcafb3b5ca9c6c220c;p=vlc diff --git a/src/control/media_library.c b/src/control/media_library.c index 17dae9efc4..9b4d63012e 100644 --- a/src/control/media_library.c +++ b/src/control/media_library.c @@ -1,6 +1,6 @@ /***************************************************************************** * tree.c: libvlc tags tree functions - * Create a tree of the 'tags' of a media_list's media_descriptors. + * Create a tree of the 'tags' of a media_list's medias. ***************************************************************************** * Copyright (C) 2007 the VideoLAN team * $Id$ @@ -21,9 +21,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ -#include "libvlc_internal.h" + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include -#include "vlc_arrays.h" +#include +#include +#include +#include + +#include + +#include "libvlc_internal.h" + +struct libvlc_media_library_t +{ + libvlc_event_manager_t * p_event_manager; + libvlc_instance_t * p_libvlc_instance; + int i_refcount; + libvlc_media_list_t * p_mlist; +}; + /* * Private functions @@ -40,21 +60,21 @@ libvlc_media_library_t * libvlc_media_library_new( libvlc_instance_t * p_inst, libvlc_exception_t * p_e ) { - (void)p_e; + (void)p_e; libvlc_media_library_t * p_mlib; - p_mlib = malloc(sizeof(libvlc_media_library_t)); + p_mlib = malloc(sizeof(libvlc_media_library_t)); - if( !p_mlib ) - return NULL; + if( !p_mlib ) + return NULL; - p_mlib->p_libvlc_instance = p_inst; + p_mlib->p_libvlc_instance = p_inst; p_mlib->i_refcount = 1; p_mlib->p_mlist = NULL; p_mlib->p_event_manager = libvlc_event_manager_new( p_mlib, p_inst, p_e ); - return p_mlib; + return p_mlib; } /************************************************************************** @@ -67,7 +87,8 @@ void libvlc_media_library_release( libvlc_media_library_t * p_mlib ) if( p_mlib->i_refcount > 0 ) return; - free( p_mlib ); + libvlc_event_manager_release( p_mlib->p_event_manager ); + free( p_mlib ); } /************************************************************************** @@ -75,7 +96,7 @@ void libvlc_media_library_release( libvlc_media_library_t * p_mlib ) **************************************************************************/ void libvlc_media_library_retain( libvlc_media_library_t * p_mlib ) { - p_mlib->i_refcount++; + p_mlib->i_refcount++; } /************************************************************************** @@ -87,21 +108,22 @@ void libvlc_media_library_load( libvlc_media_library_t * p_mlib, libvlc_exception_t * p_e ) { - const char *psz_homedir = p_mlib->p_libvlc_instance->p_libvlc_int->psz_homedir; + char *psz_datadir = config_GetUserDir( VLC_DATA_DIR ); char * psz_uri; - if( !psz_homedir ) - { - libvlc_exception_raise( p_e, "Can't get HOME DIR" ); - return; - } + if( psz_datadir == NULL + || asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp", + psz_datadir ) == -1 ) + psz_uri = NULL; + free( psz_datadir ); - if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP CONFIG_DIR DIR_SEP - "ml.xsp", psz_homedir ) == -1 ) + if( psz_uri == NULL ) { - libvlc_exception_raise( p_e, "Can't get create the path" ); + libvlc_exception_raise( p_e ); + libvlc_printerr( "Not enough memory" ); return; } + if( p_mlib->p_mlist ) libvlc_media_list_release( p_mlib->p_mlist ); @@ -121,7 +143,9 @@ void libvlc_media_library_save( libvlc_media_library_t * p_mlib, libvlc_exception_t * p_e ) { - libvlc_exception_raise( p_e, "Not supported" ); + (void)p_mlib; + libvlc_exception_raise( p_e ); + libvlc_printerr( "Function not implemented" ); } /************************************************************************** @@ -131,22 +155,8 @@ libvlc_media_list_t * libvlc_media_library_media_list( libvlc_media_library_t * p_mlib, libvlc_exception_t * p_e ) { - (void)p_e; + (void)p_e; if( p_mlib->p_mlist ) libvlc_media_list_retain( p_mlib->p_mlist ); return p_mlib->p_mlist; } - -/************************************************************************** - * media_list (Public) - **************************************************************************/ -libvlc_media_list_t * -libvlc_media_library_media_list( libvlc_media_library_t * p_mlib, - libvlc_exception_t * p_e ) -{ - (void)p_e; - if( p_mlib->p_mlist ) - libvlc_media_list_retain( p_mlib->p_mlist ); - return p_mlib->p_mlist; -} -