[vlc-devel] commit: Fix a bug when sorting the playlist: ( Rémi Duraffort )

git version control git at videolan.org
Sun May 17 22:47:34 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Duraffort <ivoire at videolan.org> | Sun May 17 22:18:08 2009 +0200| [29ab3b29df89fcd92973a404f2d8495039853899] | committer: Rémi Duraffort 

Fix a bug when sorting the playlist:

Actually sort is well done but when the user ask for the next/previous item in
the playlist, it will get the one without the sort and not the right
previous/next item.

This is caused by the fact that the table which describe previous/next isn't
rebuilded after a call to the sort function. This commit force the rebuild to
be done (b_reset_currently_playing = true)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=29ab3b29df89fcd92973a404f2d8495039853899
---

 src/playlist/sort.c |   38 ++++++++++++++++++++++++++++++--------
 1 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/src/playlist/sort.c b/src/playlist/sort.c
index b6e59f2..5cbf2ac 100644
--- a/src/playlist/sort.c
+++ b/src/playlist/sort.c
@@ -54,32 +54,54 @@ static int playlist_NodeSort( playlist_t * p_playlist , playlist_item_t *p_node,
 }
 
 /**
- * Sort a node recursively.
- *
- * This function must be entered with the playlist lock !
- *
+ * Sort a node recursively
  * \param p_playlist the playlist
  * \param p_node the node to sort
  * \param i_mode: SORT_ID, SORT_TITLE, SORT_ARTIST, SORT_ALBUM, SORT_RANDOM
  * \param i_type: ORDER_NORMAL or ORDER_REVERSE (reversed order)
  * \return VLC_SUCCESS on success
  */
-int playlist_RecursiveNodeSort( playlist_t *p_playlist, playlist_item_t *p_node,
-                                int i_mode, int i_type )
+static int recursiveNodeSort( playlist_t *p_playlist, playlist_item_t *p_node,
+                              int i_mode, int i_type )
 {
     int i;
+    /* Sort the current node */
     playlist_NodeSort( p_playlist, p_node, i_mode, i_type );
+
+    /* And all the children */
     for( i = 0 ; i< p_node->i_children; i++ )
     {
         if( p_node->pp_children[i]->i_children != -1 )
         {
-            playlist_RecursiveNodeSort( p_playlist, p_node->pp_children[i],
-                                        i_mode,i_type );
+            recursiveNodeSort( p_playlist, p_node->pp_children[i],
+                               i_mode, i_type );
         }
     }
     return VLC_SUCCESS;
 }
 
+
+/**
+ * Sort a node recursively.
+ *
+ * This function must be entered with the playlist lock !
+ *
+ * \param p_playlist the playlist
+ * \param p_node the node to sort
+ * \param i_mode: SORT_ID, SORT_TITLE, SORT_ARTIST, SORT_ALBUM, SORT_RANDOM
+ * \param i_type: ORDER_NORMAL or ORDER_REVERSE (reversed order)
+ * \return VLC_SUCCESS on success
+ */
+int playlist_RecursiveNodeSort( playlist_t *p_playlist, playlist_item_t *p_node,
+                                int i_mode, int i_type )
+{
+    /* Ask the playlist to reset as we are changing the order */
+    pl_priv(p_playlist)->b_reset_currently_playing = true;
+
+    /* Do the real job recursively */
+    return recursiveNodeSort( p_playlist, p_node, i_mode, i_type );
+}
+
 static int sort_mode = 0;
 static int sort_type = 0;
 




More information about the vlc-devel mailing list