Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
a5df65a2
Commit
a5df65a2
authored
Aug 07, 2006
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sort by artist
parent
afab5309
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
167 deletions
+58
-167
include/vlc_playlist.h
include/vlc_playlist.h
+1
-7
include/vlc_symbols.h
include/vlc_symbols.h
+2
-3
modules/control/http/macro.c
modules/control/http/macro.c
+1
-1
modules/control/rc.c
modules/control/rc.c
+9
-0
modules/gui/macosx/playlist.m
modules/gui/macosx/playlist.m
+2
-2
src/playlist/sort.c
src/playlist/sort.c
+43
-154
No files found.
include/vlc_playlist.h
View file @
a5df65a2
...
...
@@ -185,7 +185,7 @@ struct playlist_add_t
#define SORT_ID 0
#define SORT_TITLE 1
#define SORT_TITLE_NODES_FIRST 2
#define SORT_A
UTHOR
3
#define SORT_A
RTIST
3
#define SORT_GENRE 4
#define SORT_RANDOM 5
#define SORT_DURATION 6
...
...
@@ -341,13 +341,7 @@ static inline playlist_item_t *playlist_LockItemGetByInput(
VLC_EXPORT
(
int
,
playlist_LiveSearchUpdate
,
(
playlist_t
*
,
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_SortAlbum(p, i) playlist_Sort( p, SORT_ALBUM, i)
#define playlist_SortGroup(p, i) playlist_Sort( p, SORT_GROUP, i)
VLC_EXPORT
(
int
,
playlist_TreeMove
,
(
playlist_t
*
,
playlist_item_t
*
,
playlist_item_t
*
,
int
)
);
VLC_EXPORT
(
int
,
playlist_NodeGroup
,
(
playlist_t
*
,
playlist_item_t
*
,
playlist_item_t
**
,
int
,
int
,
int
)
);
VLC_EXPORT
(
int
,
playlist_NodeSort
,
(
playlist_t
*
,
playlist_item_t
*
,
int
,
int
)
);
VLC_EXPORT
(
int
,
playlist_RecursiveNodeSort
,
(
playlist_t
*
,
playlist_item_t
*
,
int
,
int
)
);
...
...
include/vlc_symbols.h
View file @
a5df65a2
...
...
@@ -309,7 +309,7 @@ struct module_symbols_t
void
(
*
playlist_ItemAddOption_inner
)
(
playlist_item_t
*
,
const
char
*
);
void
*
playlist_Sort_deprecated
;
void
*
playlist_Move_deprecated
;
int
(
*
playlist_NodeGroup_inner
)
(
playlist_t
*
,
playlist_item_t
*
,
playlist_item_t
**
,
int
,
int
,
int
)
;
void
*
playlist_NodeGroup_deprecated
;
int
(
*
playlist_NodeSort_inner
)
(
playlist_t
*
,
playlist_item_t
*
,
int
,
int
);
int
(
*
playlist_RecursiveNodeSort_inner
)
(
playlist_t
*
,
playlist_item_t
*
,
int
,
int
);
int
(
*
playlist_Import_inner
)
(
playlist_t
*
,
const
char
*
,
playlist_item_t
*
,
vlc_bool_t
);
...
...
@@ -791,7 +791,6 @@ struct module_symbols_t
# define playlist_ItemGetById (p_symbols)->playlist_ItemGetById_inner
# define playlist_ItemGetByInput (p_symbols)->playlist_ItemGetByInput_inner
# define playlist_ItemAddOption (p_symbols)->playlist_ItemAddOption_inner
# define playlist_NodeGroup (p_symbols)->playlist_NodeGroup_inner
# define playlist_NodeSort (p_symbols)->playlist_NodeSort_inner
# define playlist_RecursiveNodeSort (p_symbols)->playlist_RecursiveNodeSort_inner
# define playlist_Import (p_symbols)->playlist_Import_inner
...
...
@@ -1261,7 +1260,6 @@ struct module_symbols_t
((p_symbols)->playlist_ItemGetById_inner) = playlist_ItemGetById; \
((p_symbols)->playlist_ItemGetByInput_inner) = playlist_ItemGetByInput; \
((p_symbols)->playlist_ItemAddOption_inner) = playlist_ItemAddOption; \
((p_symbols)->playlist_NodeGroup_inner) = playlist_NodeGroup; \
((p_symbols)->playlist_NodeSort_inner) = playlist_NodeSort; \
((p_symbols)->playlist_RecursiveNodeSort_inner) = playlist_RecursiveNodeSort; \
((p_symbols)->playlist_Import_inner) = playlist_Import; \
...
...
@@ -1486,6 +1484,7 @@ struct module_symbols_t
(p_symbols)->playlist_GetPositionById_deprecated = NULL; \
(p_symbols)->playlist_Sort_deprecated = NULL; \
(p_symbols)->playlist_Move_deprecated = NULL; \
(p_symbols)->playlist_NodeGroup_deprecated = NULL; \
(p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \
(p_symbols)->__intf_Interact_deprecated = NULL; \
(p_symbols)->__intf_UserProgress_deprecated = NULL; \
...
...
modules/control/http/macro.c
View file @
a5df65a2
...
...
@@ -452,7 +452,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
{
playlist_RecursiveNodeSort
(
p_sys
->
p_playlist
,
/*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys
->
p_playlist
->
p_root_onelevel
,
SORT_A
UTHOR
,
SORT_A
RTIST
,
(
i_order
==
0
)
?
ORDER_NORMAL
:
ORDER_REVERSE
);
msg_Dbg
(
p_intf
,
"requested playlist sort by author (%d)"
,
i_order
);
}
...
...
modules/control/rc.c
View file @
a5df65a2
...
...
@@ -360,6 +360,8 @@ static void RegisterCallbacks( intf_thread_t *p_intf )
var_AddCallback
(
p_intf
,
"add"
,
Playlist
,
NULL
);
var_Create
(
p_intf
,
"playlist"
,
VLC_VAR_VOID
|
VLC_VAR_ISCOMMAND
);
var_AddCallback
(
p_intf
,
"playlist"
,
Playlist
,
NULL
);
var_Create
(
p_intf
,
"sort"
,
VLC_VAR_VOID
|
VLC_VAR_ISCOMMAND
);
var_AddCallback
(
p_intf
,
"sort"
,
Playlist
,
NULL
);
var_Create
(
p_intf
,
"play"
,
VLC_VAR_VOID
|
VLC_VAR_ISCOMMAND
);
var_AddCallback
(
p_intf
,
"play"
,
Playlist
,
NULL
);
var_Create
(
p_intf
,
"stop"
,
VLC_VAR_VOID
|
VLC_VAR_ISCOMMAND
);
...
...
@@ -1280,9 +1282,16 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
}
else
if
(
!
strcmp
(
psz_cmd
,
"playlist"
)
)
{
msg_Dbg
(
p_playlist
,
"Dumping category"
);
playlist_NodeDump
(
p_playlist
,
p_playlist
->
p_root_category
,
0
);
msg_Dbg
(
p_playlist
,
"Dumping Onelevel"
);
playlist_NodeDump
(
p_playlist
,
p_playlist
->
p_root_onelevel
,
0
);
}
else
if
(
!
strcmp
(
psz_cmd
,
"sort"
))
{
playlist_RecursiveNodeSort
(
p_playlist
,
p_playlist
->
p_root_onelevel
,
SORT_ARTIST
,
ORDER_NORMAL
);
}
else
if
(
!
strcmp
(
psz_cmd
,
"status"
)
)
{
if
(
p_playlist
->
p_input
)
...
...
modules/gui/macosx/playlist.m
View file @
a5df65a2
...
...
@@ -919,7 +919,7 @@ NSLog( @"expandable" );
-
(
IBAction
)
sortNodeByAuthor
:(
id
)
sender
{
[
self
sortNode
:
SORT_A
UTHOR
];
[
self
sortNode
:
SORT_A
RTIST
];
}
-
(
void
)
sortNode
:(
int
)
i_mode
...
...
@@ -1390,7 +1390,7 @@ NSLog( @"expandable" );
}
else
if
(
o_tc
==
o_tc_author
)
{
i_mode
=
SORT_A
UTHOR
;
i_mode
=
SORT_A
RTIST
;
}
if
(
b_isSortDescending
)
...
...
src/playlist/sort.c
View file @
a5df65a2
...
...
@@ -43,29 +43,26 @@ int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
*
* \param p_playlist the playlist
* \param p_node the node to sort
* \param i_mode: SORT_ID, SORT_TITLE, SORT_A
UTHOR
, SORT_ALBUM, SORT_RANDOM
* \param i_mode: SORT_ID, SORT_TITLE, SORT_A
RTIST
, SORT_ALBUM, SORT_RANDOM
* \param i_type: ORDER_NORMAL or ORDER_REVERSE (reversed order)
* \return VLC_SUCCESS on success
*/
int
playlist_NodeSort
(
playlist_t
*
p_playlist
,
playlist_item_t
*
p_node
,
int
i_mode
,
int
i_type
)
{
playlist_ItemArraySort
(
p_playlist
,
p_node
->
i_children
,
p_node
->
pp_children
,
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_A
UTHOR
, SORT_ALBUM, SORT_RANDOM
* \param i_mode: SORT_ID, SORT_TITLE, SORT_A
RTIST
, SORT_ALBUM, SORT_RANDOM
* \param i_type: ORDER_NORMAL or ORDER_REVERSE (reversed order)
* \return VLC_SUCCESS on success
*/
...
...
@@ -73,7 +70,6 @@ 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
++
)
{
...
...
@@ -83,15 +79,13 @@ int playlist_RecursiveNodeSort( playlist_t *p_playlist, playlist_item_t *p_node,
i_mode
,
i_type
);
}
}
return
VLC_SUCCESS
;
}
int
playlist_ItemArraySort
(
playlist_t
*
p_playlist
,
int
i_items
,
playlist_item_t
**
pp_items
,
int
i_mode
,
int
i_type
)
playlist_item_t
**
pp_items
,
int
i_mode
,
int
i_type
)
{
int
i
,
i_small
,
i_position
;
playlist_item_t
*
p_temp
;
...
...
@@ -116,6 +110,41 @@ int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
return
VLC_SUCCESS
;
}
#define DO_META_SORT( node ) { \
char *psz_a = pp_items[i]->p_input->p_meta ? \
pp_items[i]->p_input->p_meta->psz_##node : NULL ; \
char *psz_b = pp_items[i_small]->p_input->p_meta ? \
pp_items[i_small]->p_input->p_meta->psz_##node : NULL; \
/* Nodes go 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; \
/* Both are nodes, sort by name */
\
else if( pp_items[i]->i_children >= 0 && \
pp_items[i_small]->i_children >= 0 ) \
{ \
i_test = strcasecmp( pp_items[i]->p_input->psz_name, \
pp_items[i_small]->p_input->psz_name ); \
} \
/* Both are items */
\
else if( psz_a == NULL && psz_b != NULL ) \
i_test = 1; \
else if( psz_a != NULL && psz_b == NULL ) \
i_test = -1;\
/* No meta, sort by name */
\
else if( psz_a == NULL && psz_b == NULL ) \
{ \
i_test = strcasecmp( pp_items[i]->p_input->psz_name, \
pp_items[i_small]->p_input->psz_name ); \
} \
else \
{ \
i_test = strcmp( psz_b, psz_a ); \
} \
}
for
(
i_position
=
0
;
i_position
<
i_items
-
1
;
i_position
++
)
{
i_small
=
i_position
;
...
...
@@ -126,7 +155,7 @@ int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
if
(
i_mode
==
SORT_TITLE
)
{
i_test
=
strcasecmp
(
pp_items
[
i
]
->
p_input
->
psz_name
,
pp_items
[
i_small
]
->
p_input
->
psz_name
);
pp_items
[
i_small
]
->
p_input
->
psz_name
);
}
else
if
(
i_mode
==
SORT_TITLE_NUMERIC
)
{
...
...
@@ -138,83 +167,13 @@ int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
i_test
=
pp_items
[
i
]
->
p_input
->
i_duration
-
pp_items
[
i_small
]
->
p_input
->
i_duration
;
}
else
if
(
i_mode
==
SORT_A
UTHOR
)
else
if
(
i_mode
==
SORT_A
RTIST
)
{
char
*
psz_a
=
pp_items
[
i
]
->
p_input
->
p_meta
->
psz_artist
;
char
*
psz_b
=
pp_items
[
i_small
]
->
p_input
->
p_meta
->
psz_artist
;
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
;
}
// both are nodes
else
if
(
pp_items
[
i
]
->
i_children
>=
0
&&
pp_items
[
i_small
]
->
i_children
>=
0
)
{
i_test
=
strcasecmp
(
pp_items
[
i
]
->
p_input
->
psz_name
,
pp_items
[
i_small
]
->
p_input
->
psz_name
);
}
else
if
(
psz_a
==
NULL
&&
psz_b
!=
NULL
)
{
i_test
=
1
;
}
else
if
(
psz_a
!=
NULL
&&
psz_b
==
NULL
)
{
i_test
=
-
1
;
}
else
if
(
psz_a
==
NULL
&&
psz_b
==
NULL
)
{
i_test
=
strcasecmp
(
pp_items
[
i
]
->
p_input
->
psz_name
,
pp_items
[
i_small
]
->
p_input
->
psz_name
);
}
else
{
i_test
=
strcmp
(
psz_b
,
psz_a
);
}
DO_META_SORT
(
artist
);
}
else
if
(
i_mode
==
SORT_ALBUM
)
{
char
*
psz_a
=
pp_items
[
i
]
->
p_input
->
p_meta
->
psz_album
;
char
*
psz_b
=
pp_items
[
i_small
]
->
p_input
->
p_meta
->
psz_album
;
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
;
}
// both are nodes
else
if
(
pp_items
[
i
]
->
i_children
>=
0
&&
pp_items
[
i_small
]
->
i_children
>=
0
)
{
i_test
=
strcasecmp
(
pp_items
[
i
]
->
p_input
->
psz_name
,
pp_items
[
i_small
]
->
p_input
->
psz_name
);
}
else
if
(
psz_a
==
NULL
&&
psz_b
!=
NULL
)
{
i_test
=
1
;
}
else
if
(
psz_a
!=
NULL
&&
psz_b
==
NULL
)
{
i_test
=
-
1
;
}
else
if
(
psz_a
==
NULL
&&
psz_b
==
NULL
)
{
i_test
=
strcasecmp
(
pp_items
[
i
]
->
p_input
->
psz_name
,
pp_items
[
i_small
]
->
p_input
->
psz_name
);
}
else
{
i_test
=
strcmp
(
psz_b
,
psz_a
);
}
DO_META_SORT
(
album
);
}
else
if
(
i_mode
==
SORT_TITLE_NODES_FIRST
)
{
...
...
@@ -249,73 +208,3 @@ int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
}
return
VLC_SUCCESS
;
}
int
playlist_NodeGroup
(
playlist_t
*
p_playlist
,
playlist_item_t
*
p_root
,
playlist_item_t
**
pp_items
,
int
i_item
,
int
i_mode
,
int
i_type
)
{
char
*
psz_search
=
NULL
;
int
i_nodes
=
0
;
playlist_item_t
**
pp_nodes
=
NULL
;
playlist_item_t
*
p_node
;
vlc_bool_t
b_found
;
int
i
,
j
;
for
(
i
=
0
;
i
<
i_item
;
i
++
)
{
if
(
psz_search
)
free
(
psz_search
);
if
(
i_mode
==
SORT_TITLE
)
{
psz_search
=
strdup
(
pp_items
[
i
]
->
p_input
->
psz_name
);
}
else
if
(
i_mode
==
SORT_AUTHOR
)
{
psz_search
=
pp_items
[
i
]
->
p_input
->
p_meta
->
psz_artist
;
}
else
if
(
i_mode
==
SORT_ALBUM
)
{
psz_search
=
pp_items
[
i
]
->
p_input
->
p_meta
->
psz_album
;
}
else
if
(
i_mode
==
SORT_GENRE
)
{
psz_search
=
pp_items
[
i
]
->
p_input
->
p_meta
->
psz_genre
;
}
if
(
psz_search
&&
!
strcmp
(
psz_search
,
""
)
)
{
free
(
psz_search
);
psz_search
=
strdup
(
_
(
"Undefined"
)
);
}
b_found
=
VLC_FALSE
;
for
(
j
=
0
;
j
<
i_nodes
;
j
++
)
{
if
(
!
strcasecmp
(
psz_search
,
pp_nodes
[
j
]
->
p_input
->
psz_name
)
)
{
playlist_NodeAppend
(
p_playlist
,
pp_items
[
i
],
pp_nodes
[
j
]
);
b_found
=
VLC_TRUE
;
break
;
}
}
if
(
!
b_found
)
{
p_node
=
playlist_NodeCreate
(
p_playlist
,
psz_search
,
NULL
);
INSERT_ELEM
(
pp_nodes
,
i_nodes
,
i_nodes
,
p_node
);
playlist_NodeAppend
(
p_playlist
,
pp_items
[
i
],
p_node
);
}
}
/* Now, sort the nodes by name */
playlist_ItemArraySort
(
p_playlist
,
i_nodes
,
pp_nodes
,
SORT_TITLE
,
i_type
);
/* Now, sort each node and append it to the root node*/
for
(
i
=
0
;
i
<
i_nodes
;
i
++
)
{
playlist_ItemArraySort
(
p_playlist
,
pp_nodes
[
i
]
->
i_children
,
pp_nodes
[
i
]
->
pp_children
,
SORT_TITLE
,
i_type
);
playlist_NodeAppend
(
p_playlist
,
pp_nodes
[
i
],
p_root
);
}
return
VLC_SUCCESS
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment