Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
1ae4e4dc
Commit
1ae4e4dc
authored
Oct 31, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
songvec: sort songs by album name first, then disc/track number
When the songs of two albums are in the same directory, all songs of an album should be right next to each others.
parent
d099a7e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
NEWS
NEWS
+1
-0
songvec.c
src/songvec.c
+30
-1
No files found.
NEWS
View file @
1ae4e4dc
...
...
@@ -46,6 +46,7 @@ ver 0.16 (20??/??/??)
* update:
- automatically update the database with Linux inotify
- support .mpdignore files in the music directory
- sort songs by album name first, then disc/track number
* log unused/unknown block parameters
* removed the deprecated "error_file" option
* save state when stopped
...
...
src/songvec.c
View file @
1ae4e4dc
...
...
@@ -37,6 +37,30 @@ tag_get_value_checked(const struct tag *tag, enum tag_type type)
:
NULL
;
}
static
int
compare_utf8_string
(
const
char
*
a
,
const
char
*
b
)
{
if
(
a
==
NULL
)
return
b
==
NULL
?
0
:
-
1
;
if
(
b
==
NULL
)
return
1
;
return
g_utf8_collate
(
a
,
b
);
}
/**
* Compare two string tag values, ignoring case. Either one may be
* NULL.
*/
static
int
compare_string_tag_item
(
const
struct
tag
*
a
,
const
struct
tag
*
b
,
enum
tag_type
type
)
{
return
compare_utf8_string
(
tag_get_value_checked
(
a
,
type
),
tag_get_value_checked
(
b
,
type
));
}
/**
* Compare two tag values which should contain an integer value
* (e.g. disc or track number). Either one may be NULL.
...
...
@@ -70,7 +94,12 @@ static int songvec_cmp(const void *s1, const void *s2)
const
struct
song
*
b
=
((
const
struct
song
*
const
*
)
s2
)[
0
];
int
ret
;
/* first sort by disc */
/* first sort by album */
ret
=
compare_string_tag_item
(
a
->
tag
,
b
->
tag
,
TAG_ALBUM
);
if
(
ret
!=
0
)
return
ret
;
/* then sort by disc */
ret
=
compare_tag_item
(
a
->
tag
,
b
->
tag
,
TAG_DISC
);
if
(
ret
!=
0
)
return
ret
;
...
...
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