summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-30 21:36:35 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-30 21:36:35 +0100
commitc76550d5b7d8f4ccc2a3674535f70820fb8163ad (patch)
treea1fd76b08d62fb0617c419d78b13f5462f0ba38f /playlist.c
parentfd3e9a424015a7fa6de4027658628e2c5c9263a6 (diff)
better sorting by track number
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/playlist.c b/playlist.c
index 06b6970c..be3d8a49 100644
--- a/playlist.c
+++ b/playlist.c
@@ -1634,6 +1634,7 @@ pl_format_duration (playItem_t *it, const char *ret, char *dur, int size) {
int
pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
char dur[50];
+ char ftrk[50];
const char *artist = NULL;
const char *album = NULL;
const char *track = NULL;
@@ -1667,7 +1668,18 @@ pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
text = (duration = pl_format_duration (it, duration, dur, sizeof (dur)));
break;
case DB_COLUMN_TRACK:
- text = (track = pl_get_meta_cached (it, "track", track, ""));
+ track = pl_get_meta_cached (it, "track", track, "");
+ text = track;
+#if 0 // kept for tracing purposes
+ if (isdigit (track[0])) {
+ snprintf (ftrk, sizeof (ftrk), "%03d (%s)", atoi (track), track);
+ text = ftrk;
+ }
+ else {
+ snprintf (ftrk, sizeof (ftrk), "-1 (%s)", track);
+ text = ftrk;
+ }
+#endif
break;
}
if (text) {
@@ -1743,6 +1755,23 @@ pl_sort (int iter, int id, const char *format, int ascending) {
}
char title1[1024];
char title2[1024];
+ if (id == DB_COLUMN_TRACK) {
+ const char *t;
+ t = pl_find_meta (it, "track");
+ if (!t || !isdigit (*t)) {
+ strcpy (title1, "-1");
+ }
+ else {
+ snprintf (title1, sizeof (title1), "%03d", atoi (t));
+ }
+ t = pl_find_meta (next, "track");
+ if (!t || !isdigit (*t)) {
+ strcpy (title2, "-1");
+ }
+ else {
+ snprintf (title2, sizeof (title2), "%03d", atoi (t));
+ }
+ }
pl_format_title (it, title1, sizeof (title1), id, format);
pl_format_title (next, title2, sizeof (title2), id, format);
// const char *meta1 = pl_find_meta (it, meta);