Commit 37dbdbd8 authored by Clément Stenac's avatar Clément Stenac

* Doxygen doc fixes

* Add missing locks
* Duration sort
parent 6729ec17
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions * vlc_playlist.h : Playlist functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -139,6 +139,7 @@ struct playlist_t ...@@ -139,6 +139,7 @@ struct playlist_t
#define SORT_AUTHOR 2 #define SORT_AUTHOR 2
#define SORT_GROUP 3 #define SORT_GROUP 3
#define SORT_RANDOM 4 #define SORT_RANDOM 4
#define SORT_DURATION 5
#define ORDER_NORMAL 0 #define ORDER_NORMAL 0
#define ORDER_REVERSE 1 #define ORDER_REVERSE 1
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* playlist.c : Playlist groups management functions * playlist.c : Playlist groups management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
...@@ -48,7 +48,7 @@ playlist_group_t * playlist_CreateGroup(playlist_t * p_playlist, char *psz_name) ...@@ -48,7 +48,7 @@ playlist_group_t * playlist_CreateGroup(playlist_t * p_playlist, char *psz_name)
{ {
if( !strcasecmp( p_playlist->pp_groups[i]->psz_name , psz_name ) ) 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]; return p_playlist->pp_groups[i];
} }
} }
...@@ -81,7 +81,7 @@ playlist_group_t * playlist_CreateGroup(playlist_t * p_playlist, char *psz_name) ...@@ -81,7 +81,7 @@ playlist_group_t * playlist_CreateGroup(playlist_t * p_playlist, char *psz_name)
* *
* \param p_playlist the playlist to remove the group from * \param p_playlist the playlist to remove the group from
* \param i_id the identifier of the group to remove * \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 ) int playlist_DeleteGroup( playlist_t *p_playlist, int i_id )
{ {
...@@ -131,16 +131,16 @@ char *playlist_FindGroup( playlist_t *p_playlist, int i_id ) ...@@ -131,16 +131,16 @@ char *playlist_FindGroup( 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 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 * \return the id of the group
*/ */
int playlist_GroupToId( playlist_t *p_playlist, char *psz_name ) int playlist_GroupToId( playlist_t *p_playlist, char *psz_name )
{ {
int i; 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) if( p_playlist->pp_groups[i]->psz_name)
{ {
...@@ -150,5 +150,5 @@ int playlist_GroupToId( playlist_t *p_playlist, char *psz_name ) ...@@ -150,5 +150,5 @@ int playlist_GroupToId( playlist_t *p_playlist, char *psz_name )
} }
} }
} }
return 0; return VLC_SUCCESS;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* info.c : Playlist info management * info.c : Playlist info management
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
...@@ -34,13 +34,14 @@ ...@@ -34,13 +34,14 @@
* Get one special info * Get one special info
* *
* \param p_playlist the playlist to get the info from * \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_cat the category in which the info is stored
* \param psz_name the name of the info * \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, 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 */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
...@@ -69,7 +70,7 @@ char * playlist_GetInfo( playlist_t *p_playlist, int i_item, ...@@ -69,7 +70,7 @@ char * playlist_GetInfo( playlist_t *p_playlist, int i_item,
* \param p_item the item on which we want the info * \param p_item the item on which we want the info
* \param psz_cat the category in which the info is stored * \param psz_cat the category in which the info is stored
* \param psz_name the name of the info * \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, char * playlist_GetItemInfo( playlist_item_t *p_item,
const char * psz_cat, const char *psz_name ) const char * psz_cat, const char *psz_name )
...@@ -94,10 +95,11 @@ char * playlist_GetItemInfo( playlist_item_t *p_item, ...@@ -94,10 +95,11 @@ char * playlist_GetItemInfo( playlist_item_t *p_item,
} }
/** /**
* 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 p_playlist the playlist to get the category from
* \param i_item the item on which we want the info ( -1 for current ) * \param i_item the position of the item on which we want
* the info ( -1 for current )
* \param psz_cat the category we want * \param psz_cat the category we want
* \return the info category. * \return the info category.
*/ */
...@@ -128,9 +130,9 @@ playlist_GetCategory( playlist_t *p_playlist, int i_item, ...@@ -128,9 +130,9 @@ playlist_GetCategory( playlist_t *p_playlist, int i_item,
} }
/** /**
* 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 * \param psz_cat the category we want
* \return the info category. * \return the info category.
*/ */
...@@ -156,14 +158,15 @@ item_info_category_t *playlist_GetItemCategory( playlist_item_t *p_item, ...@@ -156,14 +158,15 @@ item_info_category_t *playlist_GetItemCategory( playlist_item_t *p_item,
/** /**
* Create one info category. * Create one info category.
* *
* \param p_playlist the playlist to get the info from * \param p_playlist the playlist
* \param i_item the item on which we want the info ( -1 for current ) * \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 * \param psz_cat the category we want to create
* \return the info category. * \return the info category.
*/ */
item_info_category_t * item_info_category_t *
playlist_CreateCategory( playlist_t *p_playlist, int i_item, playlist_CreateCategory( playlist_t *p_playlist, int i_item,
const char * psz_cat ) const char * psz_cat )
{ {
playlist_item_t *p_item = NULL; playlist_item_t *p_item = NULL;
...@@ -193,8 +196,8 @@ playlist_CreateCategory( playlist_t *p_playlist, int i_item, ...@@ -193,8 +196,8 @@ playlist_CreateCategory( playlist_t *p_playlist, int i_item,
/** /**
* Create one info category for an item ( no p_playlist required ) * Create one info category for an item ( no p_playlist required )
* *
* \param p_playlist the playlist to get the info from * \param p_playlist the playlist
* \param i_item the item on which we want the info ( -1 for current ) * \param p_item the item to create category for
* \param psz_cat the category we want to create * \param psz_cat the category we want to create
* \return the info category. * \return the info category.
*/ */
...@@ -230,11 +233,14 @@ playlist_CreateItemCategory( playlist_item_t *p_item, const char *psz_cat ) ...@@ -230,11 +233,14 @@ playlist_CreateItemCategory( playlist_item_t *p_item, const char *psz_cat )
/** /**
* Add an info item * Add an info item
* *
* \param p_playlist the playlist to get the info from * \param p_playlist the playlist
* \param i_item the item on which we want the info ( -1 for current ) * \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 * \param psz_cat the category we want to put the info into
* (gets created if needed) * (gets created if needed)
* \return the info category. * \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, int playlist_AddInfo( playlist_t *p_playlist, int i_item,
const char * psz_cat, const char *psz_name, const char * psz_cat, const char *psz_name,
...@@ -248,7 +254,7 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item, ...@@ -248,7 +254,7 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item,
/* Check the existence of the playlist */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
{ {
return -1; return VLC_EGENERIC;
} }
/* Get a correct item */ /* Get a correct item */
...@@ -262,7 +268,7 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item, ...@@ -262,7 +268,7 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item,
} }
else else
{ {
return -1; return VLC_EGENERIC;
} }
va_start( args, psz_format ); va_start( args, psz_format );
...@@ -279,10 +285,11 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item, ...@@ -279,10 +285,11 @@ int playlist_AddInfo( playlist_t *p_playlist, int i_item,
/** /**
* Add info to one item ( no need for p_playlist ) * Add info to one item ( no need for p_playlist )
* *
* \param p_item the item on which we want the info * \param p_item the item for which we add the info
* \param psz_cat the category in which the info is stored (must exist !) * \param psz_cat the category in which the info is stored
* \param psz_name the name of the info * \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, int playlist_AddItemInfo( playlist_item_t *p_item,
const char *psz_cat, const char *psz_name, const char *psz_cat, const char *psz_name,
...@@ -298,7 +305,7 @@ int playlist_AddItemInfo( playlist_item_t *p_item, ...@@ -298,7 +305,7 @@ int playlist_AddItemInfo( playlist_item_t *p_item,
p_cat = playlist_GetItemCategory( p_item, psz_cat ); p_cat = playlist_GetItemCategory( p_item, psz_cat );
if( p_cat == NULL) if( p_cat == NULL)
{ {
return -1; return VLC_EGENERIC;
} }
for( i = 0 ; i< p_cat->i_infos ; i++) for( i = 0 ; i< p_cat->i_infos ; i++)
...@@ -317,7 +324,7 @@ int playlist_AddItemInfo( playlist_item_t *p_item, ...@@ -317,7 +324,7 @@ int playlist_AddItemInfo( playlist_item_t *p_item,
{ {
if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL ) if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL )
{ {
return -1; return VLC_EGENERIC;
} }
p_info->psz_name = strdup( psz_name); p_info->psz_name = strdup( psz_name);
} }
...@@ -339,14 +346,15 @@ int playlist_AddItemInfo( playlist_item_t *p_item, ...@@ -339,14 +346,15 @@ int playlist_AddItemInfo( playlist_item_t *p_item,
p_info ); p_info );
} }
return 0; return VLC_SUCCESS;
} }
/** /**
* Add a special info : option * Add a special info : option
* *
* \param p_playlist the playlist to get the info from * \param p_playlist the playlist
* \param i_item the item on which we want the info ( -1 for current ) * \param i_item the position of the item on which we
* add the option ( -1 for current )
* \param psz_value the option to add * \param psz_value the option to add
* \return the info category. * \return the info category.
*/ */
...@@ -360,7 +368,7 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item, ...@@ -360,7 +368,7 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item,
/* Check the existence of the playlist */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
{ {
return -1; return VLC_EGENERIC;
} }
/* Get a correct item */ /* Get a correct item */
...@@ -373,20 +381,20 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item, ...@@ -373,20 +381,20 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item,
} }
else else
{ {
return -1; return VLC_EGENERIC;
} }
p_cat = playlist_GetCategory( p_playlist, i_item , "Options" ); p_cat = playlist_GetCategory( p_playlist, i_item , "Options" );
if( p_cat == NULL) if( p_cat == NULL)
{ {
return -1; return VLC_EGENERIC;
} }
if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL ) if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL )
{ {
msg_Err( p_playlist, "out of memory" ); msg_Err( p_playlist, "out of memory" );
return -1; return VLC_EGENERIC;
} }
p_info->psz_name = strdup( "option" ); p_info->psz_name = strdup( "option" );
...@@ -397,7 +405,7 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item, ...@@ -397,7 +405,7 @@ int playlist_AddOption( playlist_t *p_playlist, int i_item,
INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info ); INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info );
return 0; return VLC_SUCCESS;
} }
/** /**
...@@ -417,12 +425,12 @@ int playlist_AddItemOption( playlist_item_t *p_item, ...@@ -417,12 +425,12 @@ int playlist_AddItemOption( playlist_item_t *p_item,
p_cat = playlist_GetItemCategory( p_item, "Options" ); p_cat = playlist_GetItemCategory( p_item, "Options" );
if( p_cat == NULL) if( p_cat == NULL)
{ {
return -1; return VLC_EGENERIC;
} }
if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL ) if( ( p_info = malloc( sizeof( item_info_t) ) ) == NULL )
{ {
return -1; return VLC_EGENERIC;
} }
p_info->psz_name = strdup( "option" ); p_info->psz_name = strdup( "option" );
...@@ -433,5 +441,5 @@ int playlist_AddItemOption( playlist_item_t *p_item, ...@@ -433,5 +441,5 @@ int playlist_AddItemOption( playlist_item_t *p_item,
INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info ); INSERT_ELEM( p_cat->pp_infos, p_cat->i_infos, p_cat->i_infos, p_info );
return 0; return VLC_SUCCESS;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* item-ext.c : Exported playlist item functions * item-ext.c : Exported playlist item functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* Clment Stenac <zorglub@videolan.org> * Clment Stenac <zorglub@videolan.org>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "vlc_playlist.h" #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 p_playlist the playlist to add into
* \param psz_uri the mrl to add to the playlist * \param psz_uri the mrl to add to the playlist
...@@ -102,7 +102,7 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_uri, ...@@ -102,7 +102,7 @@ int playlist_Add( playlist_t *p_playlist, const char * psz_uri,
* Search the position of an item by its id * Search the position of an item by its id
* \param p_playlist the playlist * \param p_playlist the playlist
* \param i_id the id to find * \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 ) int playlist_GetPositionById( playlist_t * p_playlist , int i_id )
{ {
...@@ -114,7 +114,7 @@ int playlist_GetPositionById( playlist_t * p_playlist , int i_id ) ...@@ -114,7 +114,7 @@ int playlist_GetPositionById( playlist_t * p_playlist , int i_id )
return i; return i;
} }
} }
return -1; return VLC_EGENERIC;
} }
...@@ -149,16 +149,20 @@ playlist_item_t * playlist_GetItemById( playlist_t * p_playlist , int i_id ) ...@@ -149,16 +149,20 @@ playlist_item_t * playlist_GetItemById( playlist_t * p_playlist , int i_id )
* \param p_playlist the playlist * \param p_playlist the playlist
* \param i_pos the postition of the item of which we change the group * \param i_pos the postition of the item of which we change the group
* \param i_group the new 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 ) int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group )
{ {
char *psz_group; char *psz_group;
vlc_value_t val;
/* Check the existence of the playlist */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
{ {
return -1; return VLC_EGENERIC;
} }
vlc_mutex_lock( &p_playlist->object_lock );
/* Get a correct item */ /* Get a correct item */
if( i_pos >= 0 && i_pos < p_playlist->i_size ) if( i_pos >= 0 && i_pos < p_playlist->i_size )
{ {
...@@ -169,7 +173,7 @@ int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group ) ...@@ -169,7 +173,7 @@ int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group )
} }
else else
{ {
return -1; return VLC_EGENERIC;
} }
psz_group = playlist_FindGroup( p_playlist , i_group ); psz_group = playlist_FindGroup( p_playlist , i_group );
...@@ -177,7 +181,11 @@ int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group ) ...@@ -177,7 +181,11 @@ int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group )
{ {
p_playlist->pp_items[i_pos]->i_group = 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;
} }
/** /**
...@@ -195,8 +203,11 @@ int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name ) ...@@ -195,8 +203,11 @@ int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name )
/* Check the existence of the playlist */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
{ {
return -1; return VLC_EGENERIC;
} }
vlc_mutex_lock( &p_playlist->object_lock );
/* Get a correct item */ /* Get a correct item */
if( i_pos >= 0 && i_pos < p_playlist->i_size ) if( i_pos >= 0 && i_pos < p_playlist->i_size )
{ {
...@@ -207,7 +218,7 @@ int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name ) ...@@ -207,7 +218,7 @@ int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name )
} }
else else
{ {
return -1; return VLC_EGENERIC;
} }
if( p_playlist->pp_items[i_pos]->psz_name) if( p_playlist->pp_items[i_pos]->psz_name)
...@@ -216,6 +227,8 @@ int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name ) ...@@ -216,6 +227,8 @@ int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name )
if( psz_name ) if( psz_name )
p_playlist->pp_items[i_pos]->psz_name = strdup( 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; val.b_bool = i_pos;
var_Set( p_playlist, "item-change", val ); var_Set( p_playlist, "item-change", val );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -237,8 +250,11 @@ int playlist_SetDuration( playlist_t *p_playlist, int i_pos, mtime_t i_duration ...@@ -237,8 +250,11 @@ int playlist_SetDuration( playlist_t *p_playlist, int i_pos, mtime_t i_duration
/* Check the existence of the playlist */ /* Check the existence of the playlist */
if( p_playlist == NULL) if( p_playlist == NULL)
{ {
return -1; return VLC_EGENERIC;
} }
vlc_mutex_lock( &p_playlist->object_lock );
/* Get a correct item */ /* Get a correct item */
if( i_pos >= 0 && i_pos < p_playlist->i_size ) if( i_pos >= 0 && i_pos < p_playlist->i_size )
{ {
...@@ -264,6 +280,8 @@ int playlist_SetDuration( playlist_t *p_playlist, int i_pos, mtime_t i_duration ...@@ -264,6 +280,8 @@ int playlist_SetDuration( playlist_t *p_playlist, int i_pos, mtime_t i_duration
playlist_AddInfo( p_playlist, i_pos, _("General") , _("Duration"), playlist_AddInfo( p_playlist, i_pos, _("General") , _("Duration"),
"%s", psz_buffer ); "%s", psz_buffer );
vlc_mutex_unlock( &p_playlist->object_lock );
val.b_bool = i_pos; val.b_bool = i_pos;
var_Set( p_playlist, "item-change", val ); var_Set( p_playlist, "item-change", val );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -533,7 +551,7 @@ int playlist_EnableGroup( playlist_t * p_playlist, int i_group) ...@@ -533,7 +551,7 @@ int playlist_EnableGroup( playlist_t * p_playlist, int i_group)
* \param i_pos the position of the item to move * \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 * \param i_newpos the position of the item that will be behind the moved item
* after the move * after the move
* \return returns 0 * \return returns VLC_SUCCESS
*/ */
int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos) int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos)
{ {
...@@ -592,5 +610,5 @@ int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos) ...@@ -592,5 +610,5 @@ int playlist_Move( playlist_t * p_playlist, int i_pos, int i_newpos)
val.b_bool = VLC_TRUE; val.b_bool = VLC_TRUE;
var_Set( p_playlist, "intf-change", val ); var_Set( p_playlist, "intf-change", val );
return 0; return VLC_SUCCESS;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* loadsave.c : Playlist loading / saving functions * loadsave.c : Playlist loading / saving functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -41,12 +41,11 @@ ...@@ -41,12 +41,11 @@
/** /**
* Import a playlist file
*
* Import a certain playlist file into the playlist * Import a certain playlist file into the playlist
*
* \param p_playlist the playlist to which the new items will be added * \param p_playlist the playlist to which the new items will be added
* \param psz_filename the name of the playlistfile to import * \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 playlist_Import( playlist_t * p_playlist, const char *psz_filename )
{ {
...@@ -55,40 +54,31 @@ int playlist_Import( playlist_t * p_playlist, const char *psz_filename ) ...@@ -55,40 +54,31 @@ int playlist_Import( playlist_t * p_playlist, const char *psz_filename )
int i_id; int i_id;
msg_Dbg( p_playlist, "clearing playlist"); msg_Dbg( p_playlist, "clearing playlist");
/* Create our "fake" playlist item */
playlist_Clear( p_playlist ); playlist_Clear( p_playlist );
psz_uri = (char *)malloc(sizeof(char)*strlen(psz_filename) + 17 ); psz_uri = (char *)malloc(sizeof(char)*strlen(psz_filename) + 17 );
sprintf( psz_uri, "file/playlist://%s", psz_filename); 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, i_id = playlist_Add( p_playlist, psz_uri, psz_uri,
PLAYLIST_INSERT | PLAYLIST_GO , PLAYLIST_END); PLAYLIST_INSERT | PLAYLIST_GO , PLAYLIST_END);
p_item = playlist_GetItemById( p_playlist, i_id ); p_item = playlist_GetItemById( p_playlist, i_id );
p_item->b_autodeletion = VLC_TRUE; p_item->b_autodeletion = VLC_TRUE;
//p_playlist->i_index = 0; vlc_mutex_unlock( &p_playlist->object_lock );
/*
* if( p_item )
{
p_playlist->p_input = input_CreateThread( p_playlist, p_item );
}
*/
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/** /**
* Export a playlist to a file
*
* Export a playlist to a certain type of playlistfile * Export a playlist to a certain type of playlistfile
*
* \param p_playlist the playlist to export * \param p_playlist the playlist to export
* \param psz_filename the location where the exported file will be saved * \param psz_filename the location where the exported file will be saved
* \param psz_type the type of playlist file to create. * \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 , int playlist_Export( playlist_t * p_playlist, const char *psz_filename ,
const char *psz_type) const char *psz_type)
...@@ -96,13 +86,13 @@ int playlist_Export( playlist_t * p_playlist, const char *psz_filename , ...@@ -96,13 +86,13 @@ int playlist_Export( playlist_t * p_playlist, const char *psz_filename ,
module_t *p_module; module_t *p_module;
playlist_export_t *p_export; 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 */ /* Prepare the playlist_export_t structure */
p_export = (playlist_export_t *)malloc( sizeof(playlist_export_t) ); p_export = (playlist_export_t *)malloc( sizeof(playlist_export_t) );
if( !p_export) if( !p_export)
{ {
msg_Err( p_playlist, "Out of memory"); msg_Err( p_playlist, "out of memory");
return VLC_ENOMEM; return VLC_ENOMEM;
} }
p_export->p_file = fopen( psz_filename, "wt" ); p_export->p_file = fopen( psz_filename, "wt" );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* playlist.c : Playlist management functions * playlist.c : Playlist management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "vlc_playlist.h" #include "vlc_playlist.h"
#define PLAYLIST_FILE_HEADER_0_5 "# vlc playlist file version 0.5" #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 * Local prototypes
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sort.c : Playlist sorting functions * sort.c : Playlist sorting functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2004 VideoLAN * 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: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
* \param p_playlist the playlist * \param p_playlist the playlist
* \param i_mode: SORT_ID, SORT_TITLE, SORT_GROUP, SORT_AUTHOR, SORT_RANDOM * \param i_mode: SORT_ID, SORT_TITLE, SORT_GROUP, SORT_AUTHOR, SORT_RANDOM
* \param i_type: ORDER_NORMAL or ORDER_REVERSE (reversed order) * \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 ) int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
{ {
...@@ -70,7 +70,7 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type ) ...@@ -70,7 +70,7 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
/* Notify the interfaces */ /* Notify the interfaces */
var_Set( p_playlist, "intf-change", val ); 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 ++ ) for( i_position = 0; i_position < p_playlist->i_size -1 ; i_position ++ )
...@@ -95,6 +95,11 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type ) ...@@ -95,6 +95,11 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
i_test = p_playlist->pp_items[i]->i_group - i_test = p_playlist->pp_items[i]->i_group -
p_playlist->pp_items[i_small]->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 ) else if( i_mode == SORT_AUTHOR )
{ {
i_test = strcasecmp( i_test = strcasecmp(
...@@ -125,5 +130,5 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type ) ...@@ -125,5 +130,5 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
/* Notify the interfaces */ /* Notify the interfaces */
var_Set( p_playlist, "intf-change", val ); var_Set( p_playlist, "intf-change", val );
return 0; return VLC_SUCCESS;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment