]> git.sesse.net Git - vlc/commitdiff
* Fixed some doxygen comments.
authorDerk-Jan Hartman <hartman@videolan.org>
Sat, 10 Jan 2004 14:24:33 +0000 (14:24 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Sat, 10 Jan 2004 14:24:33 +0000 (14:24 +0000)
* Added SORT_ID
* remember last sorting and ordering in playlist struct

include/vlc_playlist.h
src/playlist/item-ext.c
src/playlist/playlist.c
src/playlist/sort.c

index d10d7ef6977b2b1608ec8244a2f951e4821dd3b9..78fa63e3923a9074343350d4163d22b9d7393de9 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
  *
@@ -120,14 +120,16 @@ struct playlist_t
     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
@@ -199,6 +201,7 @@ VLC_EXPORT( int, playlist_AddOption, (playlist_t *, int, const char *, ...) );
 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)
index 96b1ae89f237634809f81e1b117ad7c7a5628236..9f3fb2db06238cb113b202b379e238dd696c482d 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -151,11 +151,11 @@ playlist_item_t * playlist_GetItemById( playlist_t * p_playlist , int i_id )
  * 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 */
@@ -164,12 +164,12 @@ int playlist_SetGroup( playlist_t *p_playlist, int i_item, int i_group )
         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
     {
@@ -179,7 +179,7 @@ int playlist_SetGroup( playlist_t *p_playlist, int i_item, int i_group )
     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;
 }
@@ -188,11 +188,11 @@ int playlist_SetGroup( playlist_t *p_playlist, int i_item, int i_group )
  * 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;
 
@@ -202,25 +202,25 @@ int playlist_SetName( playlist_t *p_playlist, int i_item, char *psz_name )
         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;
 }
@@ -229,11 +229,11 @@ int playlist_SetName( playlist_t *p_playlist, int i_item, char *psz_name )
  * 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;
@@ -244,19 +244,19 @@ int playlist_SetDuration( playlist_t *p_playlist, int i_item, mtime_t i_duration
         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 );
@@ -265,10 +265,10 @@ int playlist_SetDuration( playlist_t *p_playlist, int i_item, mtime_t i_duration
     {
         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;
 }
@@ -457,7 +457,7 @@ int playlist_Enable( playlist_t * p_playlist, int i_pos )
  * 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)
@@ -491,7 +491,7 @@ 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)
index 1209e9647543f81ed130410af82ac89b1465bec0..a8bb06c95d39ef1df736fce45fea6a91fdb6bf0e 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.c : Playlist management functions
  *****************************************************************************
  * Copyright (C) 1999-2004 VideoLAN
- * $Id: playlist.c,v 1.72 2004/01/06 08:50:20 zorglub Exp $
+ * $Id: playlist.c,v 1.73 2004/01/10 14:24:33 hartman Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -101,6 +101,8 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
     p_playlist->pp_groups = NULL;
     p_playlist->i_last_group = 0;
     p_playlist->i_last_id = 0;
+    p_playlist->i_sort = SORT_ID;
+    p_playlist->i_order = ORDER_NORMAL;
 
     playlist_CreateGroup( p_playlist, "Normal" );
 
index 1e777f6ddd0dcb0735fa7eef5d66d04c7a7155cd..374e6ce02d14d7754e54a36d84c22e55bbfca76e 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
  *
@@ -33,7 +33,7 @@
 /**
  * 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
  */
@@ -46,6 +46,9 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
 
     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 ++ )
@@ -77,7 +80,12 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
         {
             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 );