# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <vlc_playlist.h>
#include <vlc_events.h>
#include "playlist_internal.h"
/* Prepare the playlist_export_t structure */
p_export = (playlist_export_t *)malloc( sizeof(playlist_export_t) );
if( !p_export)
- {
- msg_Err( p_playlist, "out of memory" );
return VLC_ENOMEM;
- }
p_export->psz_filename = NULL;
if ( psz_filename )
p_export->psz_filename = strdup( psz_filename );
p_export->p_root = p_export_root;
/* Lock the playlist */
- vlc_mutex_lock( &p_playlist->object_lock );
+ vlc_object_lock( p_playlist );
p_playlist->p_private = (void *)p_export;
/* And call the module ! All work is done now */
if( !p_module )
{
msg_Warn( p_playlist, "exporting playlist failed" );
- vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_unlock( p_playlist );
return VLC_ENOOBJ;
}
module_Unneed( p_playlist , p_module );
free( p_export->psz_filename );
free ( p_export );
p_playlist->p_private = NULL;
- vlc_mutex_unlock( &p_playlist->object_lock );
+ vlc_object_unlock( p_playlist );
return VLC_SUCCESS;
}
/* playlist_AddInput() can fail, but we have no way to report that ..
* Any way when it has failed, either the playlist is dying, either OOM */
playlist_AddInput( p_playlist, p_item, PLAYLIST_APPEND, PLAYLIST_END,
- false, false );
+ false, pl_Unlocked );
}
int playlist_MLLoad( playlist_t *p_playlist )
{
- const char *psz_datadir = p_playlist->p_libvlc->psz_datadir;
+ char *psz_datadir = config_GetUserDataDir();
char *psz_uri = NULL;
input_item_t *p_input;
struct stat p_stat;
/* checks if media library file is present */
if( utf8_stat( psz_uri , &p_stat ) )
- {
- free( psz_uri );
- return VLC_EGENERIC;
- }
+ goto error;
free( psz_uri );
+ /* FIXME: WTF? stat() should never be used right before open()! */
if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xspf",
psz_datadir ) == -1 )
{
psz_uri = NULL;
goto error;
}
+ free( psz_datadir );
+ psz_datadir = NULL;
const char *const psz_option = "meta-file";
/* that option has to be cleaned in input_item_subitem_added() */
error:
free( psz_uri );
+ free( psz_datadir );
return VLC_ENOMEM;
}
int playlist_MLDump( playlist_t *p_playlist )
{
- char *psz_datadir = p_playlist->p_libvlc->psz_datadir;
+ char *psz_datadir = config_GetUserDataDir();
if( !config_GetInt( p_playlist, "media-library") ) return VLC_SUCCESS;
if( !psz_datadir ) /* XXX: This should never happen */
{
return VLC_EGENERIC;
}
- char psz_dirname[ strlen( psz_datadir )
- + sizeof( DIR_SEP "ml.xspf")];
- sprintf( psz_dirname, "%s", psz_datadir );
+ char psz_dirname[ strlen( psz_datadir ) + sizeof( DIR_SEP "ml.xspf")];
+ strcpy( psz_dirname, psz_datadir );
+ free( psz_datadir );
if( config_CreateDir( (vlc_object_t *)p_playlist, psz_dirname ) )
{
return VLC_EGENERIC;