* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: vlc_playlist.h,v 1.22 2004/01/10 03:36:03 hartman Exp $
+ * $Id: vlc_playlist.h,v 1.23 2004/01/10 14:24:33 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
input_thread_t * p_input; /**< the input thread ascosiated
* with the current item */
int i_last_id; /**< Last id to an item */
+ int i_sort; /**< Last sorting applied to the playlist */
+ int i_order; /**< Last ordering applied to the playlist */
/*@}*/
};
-#define SORT_TITLE 0
-#define SORT_AUTHOR 1
-#define SORT_GROUP 2
-#define SORT_RANDOM 3
-#define SORT_ID 4
+#define SORT_ID 0
+#define SORT_TITLE 1
+#define SORT_AUTHOR 2
+#define SORT_GROUP 3
+#define SORT_RANDOM 4
#define ORDER_NORMAL 0
#define ORDER_REVERSE 1
VLC_EXPORT( int, playlist_AddItemOption, (playlist_item_t *, const char *, ...) );
/* Playlist sorting */
+#define playlist_SortID(p, i) playlist_Sort( p, SORT_ID, i)
#define playlist_SortTitle(p, i) playlist_Sort( p, SORT_TITLE, i)
#define playlist_SortAuthor(p, i) playlist_Sort( p, SORT_AUTHOR, i)
#define playlist_SortGroup(p, i) playlist_Sort( p, SORT_GROUP, i)
* item-ext.c : Exported playlist item functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: item-ext.c,v 1.6 2004/01/10 03:36:03 hartman Exp $
+ * $Id: item-ext.c,v 1.7 2004/01/10 14:24:33 hartman Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Clément Stenac <zorglub@videolan.org>
* Set the group of a playlist item
*
* \param p_playlist the playlist
- * \param i_item the item of which we change the group (position)
+ * \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
*/
-int playlist_SetGroup( playlist_t *p_playlist, int i_item, int i_group )
+int playlist_SetGroup( playlist_t *p_playlist, int i_pos, int i_group )
{
char *psz_group;
/* Check the existence of the playlist */
return -1;
}
/* Get a correct item */
- if( i_item >= 0 && i_item < p_playlist->i_size )
+ if( i_pos >= 0 && i_pos < p_playlist->i_size )
{
}
else if( p_playlist->i_size > 0 )
{
- i_item = p_playlist->i_index;
+ i_pos = p_playlist->i_index;
}
else
{
psz_group = playlist_FindGroup( p_playlist , i_group );
if( psz_group != NULL)
{
- p_playlist->pp_items[i_item]->i_group = i_group ;
+ p_playlist->pp_items[i_pos]->i_group = i_group ;
}
return 0;
}
* Set the name of a playlist item
*
* \param p_playlist the playlist
- * \param i_item the item of which we change the name
+ * \param i_pos the position of the item of which we change the name
* \param psz_name the new name
* \return VLC_SUCCESS on success, VLC_EGENERIC on failure
*/
-int playlist_SetName( playlist_t *p_playlist, int i_item, char *psz_name )
+int playlist_SetName( playlist_t *p_playlist, int i_pos, char *psz_name )
{
vlc_value_t val;
return -1;
}
/* Get a correct item */
- if( i_item >= 0 && i_item < p_playlist->i_size )
+ if( i_pos >= 0 && i_pos < p_playlist->i_size )
{
}
else if( p_playlist->i_size > 0 )
{
- i_item = p_playlist->i_index;
+ i_pos = p_playlist->i_index;
}
else
{
return -1;
}
- if( p_playlist->pp_items[i_item]->psz_name)
- free( p_playlist->pp_items[i_item]->psz_name );
+ if( p_playlist->pp_items[i_pos]->psz_name)
+ free( p_playlist->pp_items[i_pos]->psz_name );
if( psz_name )
- p_playlist->pp_items[i_item]->psz_name = strdup( psz_name );
+ p_playlist->pp_items[i_pos]->psz_name = strdup( psz_name );
- val.b_bool = i_item;
+ val.b_bool = i_pos;
var_Set( p_playlist, "item-change", val );
return VLC_SUCCESS;
}
* Set the duration of a playlist item
*
* \param p_playlist the playlist
- * \param i_item the item of which we change the name
+ * \param i_pos the position of the item of which we change the duration
* \param i_duration the duration to set
* \return VLC_SUCCESS on success, VLC_EGENERIC on failure
*/
-int playlist_SetDuration( playlist_t *p_playlist, int i_item, mtime_t i_duration )
+int playlist_SetDuration( playlist_t *p_playlist, int i_pos, mtime_t i_duration )
{
char psz_buffer[MSTRTIME_MAX_SIZE];
vlc_value_t val;
return -1;
}
/* Get a correct item */
- if( i_item >= 0 && i_item < p_playlist->i_size )
+ if( i_pos >= 0 && i_pos < p_playlist->i_size )
{
}
else if( p_playlist->i_size > 0 )
{
- i_item = p_playlist->i_index;
+ i_pos = p_playlist->i_index;
}
else
{
return VLC_EGENERIC;
}
- p_playlist->pp_items[i_item]->i_duration = i_duration;
+ p_playlist->pp_items[i_pos]->i_duration = i_duration;
if( i_duration != -1 )
{
secstotimestr( psz_buffer, i_duration/1000000 );
{
memcpy( psz_buffer, "--:--:--", sizeof("--:--:--") );
}
- playlist_AddInfo( p_playlist, i_item, _("General") , _("Duration"),
+ playlist_AddInfo( p_playlist, i_pos, _("General") , _("Duration"),
"%s", psz_buffer );
- val.b_bool = i_item;
+ val.b_bool = i_pos;
var_Set( p_playlist, "item-change", val );
return VLC_SUCCESS;
}
* Disables a playlist group
*
* \param p_playlist the playlist to disable from.
- * \param i_pos the id of the group to disable
+ * \param i_group the id of the group to disable
* \return returns 0
*/
int playlist_DisableGroup( playlist_t * p_playlist, int i_group)
* Enables a playlist group
*
* \param p_playlist the playlist to enable from.
- * \param i_pos the id of the group to enable
+ * \param i_group the id of the group to enable
* \return returns 0
*/
int playlist_EnableGroup( playlist_t * p_playlist, int i_group)
* sort.c : Playlist sorting functions
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: sort.c,v 1.6 2004/01/10 03:36:03 hartman Exp $
+ * $Id: sort.c,v 1.7 2004/01/10 14:24:33 hartman Exp $
*
* Authors: Clément Stenac <zorglub@videolan.org>
*
/**
* Sort the playlist
* \param p_playlist the playlist
- * \param i_mode: SORT_TITLE, SORT_GROUP, SORT_AUTHOR, SORT_RANDOM SORT_ID
+ * \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
*/
vlc_mutex_lock( &p_playlist->object_lock );
+ p_playlist->i_sort = i_mode;
+ p_playlist->i_order = i_type;
+
if( i_mode == SORT_RANDOM )
{
for( i_position = 0; i_position < p_playlist->i_size ; i_position ++ )
{
int i_test = 0;
- if( i_mode == SORT_TITLE )
+ if( i_mode == SORT_ID )
+ {
+ i_test = p_playlist->pp_items[i]->i_id,
+ p_playlist->pp_items[i_small]->i_id;
+ }
+ else if( i_mode == SORT_TITLE )
{
i_test = strcasecmp( p_playlist->pp_items[i]->psz_name,
p_playlist->pp_items[i_small]->psz_name );