/**
* Sort a node.
+ *
+ * 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_AUTHOR, SORT_RANDOM
int playlist_NodeSort( playlist_t * p_playlist , playlist_item_t *p_node,
int i_mode, int i_type )
{
- vlc_value_t val;
- val.b_bool = VLC_TRUE;
-
- vlc_mutex_lock( &p_playlist->object_lock );
playlist_ItemArraySort( p_playlist,p_node->i_children,
p_node->pp_children, i_mode, i_type );
p_node->i_serial++;
- vlc_mutex_unlock( &p_playlist->object_lock );
+ return VLC_SUCCESS;
+}
- /* Notify the interfaces */
- var_Set( p_playlist, "intf-change", val );
+/**
+ *
+ * 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_AUTHOR, 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 )
+{
+ int i;
+
+ playlist_NodeSort( p_playlist, p_node, i_mode, i_type );
+ 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 );
+ }
+ }
return VLC_SUCCESS;
+
}
{
for( i_position = 0; i_position < i_items ; i_position ++ )
{
- int i_new = rand() % (i_items - 1);
+ int i_new;
+ if( i_items > 1 )
+ i_new = rand() % (i_items - 1);
+ else
+ i_new = 0;
p_temp = pp_items[i_position];
pp_items[i_position] = pp_items[i_new];
pp_items[i_new] = p_temp;
i_test = strcasecmp( pp_items[i]->input.psz_name,
pp_items[i_small]->input.psz_name );
}
+ else if( i_mode == SORT_TITLE_NUMERIC )
+ {
+ i_test = atoi( pp_items[i]->input.psz_name ) -
+ atoi( pp_items[i_small]->input.psz_name );
+ }
else if( i_mode == SORT_DURATION )
{
i_test = pp_items[i]->input.i_duration -
{
msg_Err( p_playlist,"META SORT not implemented" );
}
+ else if( i_mode == SORT_TITLE_NODES_FIRST )
+ {
+ /* Alphabetic sort, all nodes first */
+
+ if( pp_items[i]->i_children == -1 &&
+ pp_items[i_small]->i_children >= 0 )
+ {
+ i_test = 1;
+ }
+ else if( pp_items[i]->i_children >= 0 &&
+ pp_items[i_small]->i_children == -1 )
+ {
+ i_test = -1;
+ }
+ else
+ {
+ i_test = strcasecmp( pp_items[i]->input.psz_name,
+ pp_items[i_small]->input.psz_name );
+ }
+ }
if( ( i_type == ORDER_NORMAL && i_test < 0 ) ||
( i_type == ORDER_REVERSE && i_test > 0 ) )
}
else if ( i_mode == SORT_AUTHOR )
{
- psz_search = playlist_ItemGetInfo( pp_items[i],
+ psz_search = vlc_input_item_GetInfo( &pp_items[i]->input,
_("Meta-information"), _( "Artist" ) );
}
+ else if ( i_mode == SORT_GENRE )
+ {
+ psz_search = vlc_input_item_GetInfo( &pp_items[i]->input,
+ _("Meta-information"), _( "Genre" ) );
+ }
if( psz_search && !strcmp( psz_search, "" ) )
{