* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: vlc_playlist.h,v 1.24 2004/01/11 00:45:06 zorglub Exp $
+ * $Id: vlc_playlist.h,v 1.25 2004/01/23 10:48:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
#define SORT_AUTHOR 2
#define SORT_GROUP 3
#define SORT_RANDOM 4
+#define SORT_DURATION 5
#define ORDER_NORMAL 0
#define ORDER_REVERSE 1
* playlist.c : Playlist groups management functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: group.c,v 1.7 2004/01/11 00:45:06 zorglub Exp $
+ * $Id: group.c,v 1.8 2004/01/23 10:48:08 zorglub Exp $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
{
if( !strcasecmp( p_playlist->pp_groups[i]->psz_name , psz_name ) )
{
- msg_Info( p_playlist, "This group already exists !");
+ msg_Info( p_playlist, "this group already exists");
return p_playlist->pp_groups[i];
}
}
*
* \param p_playlist the playlist to remove the group from
* \param i_id the identifier of the group to remove
- * \return 0 on success
+ * \return VLC_SUCCESS
*/
int playlist_DeleteGroup( playlist_t *p_playlist, int i_id )
{
}
/**
- * Find the Id of a group given its name
+ * Find the id of a group given its name
*
* \param p_playlist the playlist where to find the group
- * \param char * the name to search for
+ * \param psz_name the name to search for
* \return the id of the group
*/
int playlist_GroupToId( playlist_t *p_playlist, char *psz_name )
{
int i;
- for( i=0 ; i< p_playlist->i_groups; i++ )
+ for( i = 0 ; i< p_playlist->i_groups; i++ )
{
if( p_playlist->pp_groups[i]->psz_name)
{
}
}
}
- return 0;
+ return VLC_SUCCESS;
}
* info.c : Playlist info management
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: info.c,v 1.5 2004/01/17 16:24:14 gbazin Exp $
+ * $Id: info.c,v 1.6 2004/01/23 10:48:08 zorglub Exp $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* Get one special info
*
* \param p_playlist the playlist to get the info from
- * \param i_item the item on which we want the info ( -1 for current )
+ * \param i_item position of the item on
+ * which we want the info ( -1 for current )
* \param psz_cat the category in which the info is stored
* \param psz_name the name of the info
- * \return the info value if any, NULL else
+ * \return the info value if any, an empty string else
*/
char * playlist_GetInfo( playlist_t *p_playlist, int i_item,
- const char * psz_cat, const char *psz_name )
+ const char * psz_cat, const char *psz_name )
{
/* Check the existence of the playlist */
if( p_playlist == NULL)
* \param p_item the item on which we want the info
* \param psz_cat the category in which the info is stored
* \param psz_name the name of the info
- * \return the info value if any, NULL else
+ * \return the info value if any, an empty string else
*/
char * playlist_GetItemInfo( playlist_item_t *p_item,
const char * psz_cat, const char *psz_name )
}
/**
- * Get one info category. Creates it if it does not exist
+ * Get one info category. Create it if it does not exist
*
- * \param p_playlist the playlist to get the info from
- * \param i_item the item on which we want the info ( -1 for current )
+ * \param p_playlist the playlist to get the category from
+ * \param i_item the position of the item on which we want
+ * the info ( -1 for current )
* \param psz_cat the category we want
* \return the info category.
*/
}
/**
- * Get one info category (no p_playlist). Creates it if it does not exist
+ * Get one info category (no p_playlist). Create it if it does not exist
*
- * \param p_item the playlist to search categories in
+ * \param p_item the playlist item to get the category from
* \param psz_cat the category we want
* \return the info category.
*/
/**
* Create one info category.
*
- * \param p_playlist the playlist to get the info from
- * \param i_item the item on which we want the info ( -1 for current )
+ * \param p_playlist the playlist
+ * \param i_item the position of the item for which we create
+ * the category ( -1 for current )
* \param psz_cat the category we want to create
* \return the info category.
*/
item_info_category_t *
playlist_CreateCategory( playlist_t *p_playlist, int i_item,
- const char * psz_cat )
+ const char * psz_cat )
{
playlist_item_t *p_item = NULL;
/**
* Create one info category for an item ( no p_playlist required )
*
- * \param p_playlist the playlist to get the info from
- * \param i_item the item on which we want the info ( -1 for current )
+ * \param p_playlist the playlist
+ * \param p_item the item to create category for
* \param psz_cat the category we want to create
* \return the info category.
*/
/**
* Add an info item
*
- * \param p_playlist the playlist to get the info from
- * \param i_item the item on which we want the info ( -1 for current )
+ * \param p_playlist the playlist
+ * \param i_item the position of the item on which we want
+ * the info ( -1 for current )
* \param psz_cat the category we want to put the info into
- * (gets created if needed)
- * \return the info category.
+ * (gets created if needed)
+ * \param psz_name the name of the info
+ * \param psz_format printf-style info
+ * \return VLC_SUCCESS
*/
int playlist_AddInfo( playlist_t *p_playlist, int i_item,
const char * psz_cat, const char *psz_name,
/* Check the existence of the playlist */
if( p_playlist == NULL)
{
- return -1;
+ return VLC_EGENERIC;
}
/* Get a correct item */
}
else
{
- return -1;
+ return VLC_EGENERIC;
}
va_start( args, psz_format );
/**
* Add info to one item ( no need for p_playlist )
*
- * \param p_item the item on which we want the info
- * \param psz_cat the category in which the info is stored (must exist !)
+ * \param p_item the item for which we add the info
+ * \param psz_cat the category in which the info is stored
* \param psz_name the name of the info
- * \return the info value if any, NULL else
+ * \param psz_format printf-style info
+ * \return VLC_SUCCESS on success
*/
int playlist_AddItemInfo( playlist_item_t *p_item,
const char *psz_cat, const char *psz_name,
p_cat = playlist_GetItemCategory( p_item, psz_cat );
if( p_cat == NULL)
{
- return -1;
+ return VLC_EGENERIC;
}
for( i = 0 ; i< p_cat->i_infos ; i++)
{
if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL )
{
- return -1;
+ return VLC_EGENERIC;
}
p_info->psz_name = strdup( psz_name);
}
p_info );
}
- return 0;
+ return VLC_SUCCESS;
}
/**
* Add a special info : option
*
- * \param p_playlist the playlist to get the info from
- * \param i_item the item on which we want the info ( -1 for current )
+ * \param p_playlist the playlist
+ * \param i_item the position of the item on which we
+ * add the option ( -1 for current )
* \param psz_value the option to add
* \return the info category.
*/
/* Check the existence of the playlist */
if( p_playlist == NULL)
{
- return -1;
+ return VLC_EGENERIC;
}
/* Get a correct item */
}
else
{
- return -1;
+ return VLC_EGENERIC;
}
p_cat = playlist_GetCategory( p_playlist, i_item , "Options" );
if( p_cat == NULL)
{
- return -1;
+ return VLC_EGENERIC;
}
if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL )
{
msg_Err( p_playlist, "out of memory" );
- return -1;
+ return VLC_EGENERIC;
}
p_info->psz_name = strdup( "option" );
INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info );
- return 0;
+ return VLC_SUCCESS;
}
/**
p_cat = playlist_GetItemCategory( p_item, "Options" );
if( p_cat == NULL)
{
- return -1;
+ return VLC_EGENERIC;
}
if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL )
{
- return -1;
+ return VLC_EGENERIC;
}
p_info->psz_name = strdup( "option" );
INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info );
- return 0;
+ return VLC_SUCCESS;
}
* item-ext.c : Exported playlist item functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: item-ext.c,v 1.10 2004/01/17 14:08:37 sigmunau Exp $
+ * $Id: item-ext.c,v 1.11 2004/01/23 10:48:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Clément Stenac <zorglub@videolan.org>
#include "vlc_playlist.h"
/**
- * Add a MRL into the playlist.
+ * Add a MRL into the playlist, duration given.
*
* \param p_playlist the playlist to add into
* \param psz_uri the mrl to add to the playlist
* Search the position of an item by its id
* \param p_playlist the playlist
* \param i_id the id to find
- * \return the position, or -1 on failure
+ * \return the position, or VLC_EGENERIC on failure
*/
int playlist_GetPositionById( playlist_t * p_playlist , int i_id )
{
return i;
}
}
- return -1;
+ return VLC_EGENERIC;
}
* \param p_playlist the playlist
* \param i_pos the postition of the item of which we change the group
* \param i_group the new group
- * \return 0 on success, -1 on failure
+ * \return VLC_SUCCESS on success, VLC_EGENERIC on failure
*/
int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group )
{
char *psz_group;
+ vlc_value_t val;
/* Check the existence of the playlist */
if( p_playlist == NULL)
{
- return -1;
+ return VLC_EGENERIC;
}
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+
/* Get a correct item */
if( i_pos >= 0 && i_pos < p_playlist->i_size )
{
}
else
{
- return -1;
+ return VLC_EGENERIC;
}
psz_group = playlist_FindGroup( p_playlist , i_group );
{
p_playlist->pp_items[i_pos]->i_group = i_group ;
}
- return 0;
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ val.b_bool = i_pos;
+ var_Set( p_playlist, "item-change", val );
+
+ return VLC_SUCCESS;
}
/**
/* Check the existence of the playlist */
if( p_playlist == NULL)
{
- return -1;
+ return VLC_EGENERIC;
}
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+
/* Get a correct item */
if( i_pos >= 0 && i_pos < p_playlist->i_size )
{
}
else
{
- return -1;
+ return VLC_EGENERIC;
}
if( p_playlist->pp_items[i_pos]->psz_name)
if( psz_name )
p_playlist->pp_items[i_pos]->psz_name = strdup( psz_name );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
val.b_bool = i_pos;
var_Set( p_playlist, "item-change", val );
return VLC_SUCCESS;
/* Check the existence of the playlist */
if( p_playlist == NULL)
{
- return -1;
+ return VLC_EGENERIC;
}
+
+ vlc_mutex_lock( &p_playlist->object_lock );
+
/* Get a correct item */
if( i_pos >= 0 && i_pos < p_playlist->i_size )
{
playlist_AddInfo( p_playlist, i_pos, _("General") , _("Duration"),
"%s", psz_buffer );
+ vlc_mutex_unlock( &p_playlist->object_lock );
+
val.b_bool = i_pos;
var_Set( p_playlist, "item-change", val );
return VLC_SUCCESS;
* \param i_pos the position of the item to move
* \param i_newpos the position of the item that will be behind the moved item
* after the move
- * \return returns 0
+ * \return returns VLC_SUCCESS
*/
int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos)
{
val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-change", val );
- return 0;
+ return VLC_SUCCESS;
}
* loadsave.c : Playlist loading / saving functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: loadsave.c,v 1.6 2004/01/22 19:35:14 gbazin Exp $
+ * $Id: loadsave.c,v 1.7 2004/01/23 10:48:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
/**
- * Import a playlist file
- *
* Import a certain playlist file into the playlist
+ *
* \param p_playlist the playlist to which the new items will be added
* \param psz_filename the name of the playlistfile to import
- * \return 0 on succes
+ * \return VLC_SUCCESS on success
*/
int playlist_Import( playlist_t * p_playlist, const char *psz_filename )
{
int i_id;
msg_Dbg( p_playlist, "clearing playlist");
-
- /* Create our "fake" playlist item */
playlist_Clear( p_playlist );
psz_uri = (char *)malloc(sizeof(char)*strlen(psz_filename) + 17 );
sprintf( psz_uri, "file/playlist://%s", psz_filename);
+ vlc_mutex_lock( &p_playlist->object_lock );
i_id = playlist_Add( p_playlist, psz_uri, psz_uri,
PLAYLIST_INSERT | PLAYLIST_GO , PLAYLIST_END);
p_item = playlist_GetItemById( p_playlist, i_id );
p_item->b_autodeletion = VLC_TRUE;
- //p_playlist->i_index = 0;
-
-/*
- * if( p_item )
- {
- p_playlist->p_input = input_CreateThread( p_playlist, p_item );
- }
- */
+ vlc_mutex_unlock( &p_playlist->object_lock );
return VLC_SUCCESS;
}
/**
- * Export a playlist to a file
- *
* Export a playlist to a certain type of playlistfile
+ *
* \param p_playlist the playlist to export
* \param psz_filename the location where the exported file will be saved
* \param psz_type the type of playlist file to create.
- * \return 0 on succes
+ * \return VLC_SUCCESS on success
*/
int playlist_Export( playlist_t * p_playlist, const char *psz_filename ,
const char *psz_type)
module_t *p_module;
playlist_export_t *p_export;
- msg_Info( p_playlist, "Saving playlist to file %s", psz_filename );
+ msg_Info( p_playlist, "saving playlist to file %s", psz_filename );
/* 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");
+ msg_Err( p_playlist, "out of memory");
return VLC_ENOMEM;
}
p_export->p_file = fopen( psz_filename, "wt" );
* playlist.c : Playlist management functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: playlist.c,v 1.74 2004/01/11 00:11:56 zorglub Exp $
+ * $Id: playlist.c,v 1.75 2004/01/23 10:48:08 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
#include "vlc_playlist.h"
#define PLAYLIST_FILE_HEADER_0_5 "# vlc playlist file version 0.5"
-#define PLAYLIST_FILE_HEADER_0_6 "# vlc playlist file version 0.6"
/*****************************************************************************
* Local prototypes
* sort.c : Playlist sorting functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: sort.c,v 1.8 2004/01/10 23:44:19 hartman Exp $
+ * $Id: sort.c,v 1.9 2004/01/23 10:48:08 zorglub Exp $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
* \param p_playlist the playlist
* \param i_mode: SORT_ID, SORT_TITLE, SORT_GROUP, SORT_AUTHOR, SORT_RANDOM
* \param i_type: ORDER_NORMAL or ORDER_REVERSE (reversed order)
- * \return 0 on success
+ * \return VLC_SUCCESS on success
*/
int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
{
/* Notify the interfaces */
var_Set( p_playlist, "intf-change", val );
- return 0;
+ return VLC_SUCCESS;
}
for( i_position = 0; i_position < p_playlist->i_size -1 ; i_position ++ )
i_test = p_playlist->pp_items[i]->i_group -
p_playlist->pp_items[i_small]->i_group;
}
+ else if( i_mode == SORT_DURATION )
+ {
+ i_test = p_playlist->pp_items[i]->i_duration -
+ p_playlist->pp_items[i_small]->i_duration;
+ }
else if( i_mode == SORT_AUTHOR )
{
i_test = strcasecmp(
/* Notify the interfaces */
var_Set( p_playlist, "intf-change", val );
- return 0;
+ return VLC_SUCCESS;
}