summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-07 11:59:40 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-02-07 11:59:40 +0100
commitcb1c3828de71185f02b21a69150f968d64412cc5 (patch)
tree383bbff3b0da9b627d11d55ba3880cbe12463b6d /playlist.c
parente0cb4500dd05050e60414b7bb25d91f392435437 (diff)
parent1d259b115c302a23c6e2ccfe96b88e5135d033e7 (diff)
Merge branch 'master' into devel
Conflicts: Makefile.am configure.ac plugins/ffmpeg/ffmpeg.c plugins/gtkui/gtkui.c streamer.c
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/playlist.c b/playlist.c
index 6ac561bc..ac8e31c1 100644
--- a/playlist.c
+++ b/playlist.c
@@ -377,8 +377,8 @@ pl_insert_cue_from_buffer (playItem_t *after, playItem_t *origin, const uint8_t
p++;
}
if (p-buffer > 2048) { // huge string, ignore
- buffer = p;
buffersize -= p-buffer;
+ buffer = p;
continue;
}
char str[p-buffer+1];
@@ -1821,30 +1821,25 @@ pl_sort (int iter, int id, const char *format, int ascending) {
if (!next) {
break;
}
- char title1[1024];
- char title2[1024];
- if (id == DB_COLUMN_TRACK) {
+ int cmp;
+ if (id == DB_COLUMN_DURATION) {
+ cmp = ascending ? next->_duration > it->_duration : it->_duration > next->_duration;
+ }
+ else 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));
- }
+ int a = t ? atoi (t) : -1;
t = pl_find_meta (next, "track");
- if (!t || !isdigit (*t)) {
- strcpy (title2, "-1");
- }
- else {
- snprintf (title2, sizeof (title2), "%03d", atoi (t));
- }
+ int b = t ? atoi (t) : -1;
+ cmp = ascending ? b > a : a > b;
}
else {
+ char title1[1024];
+ char title2[1024];
pl_format_title (it, -1, title1, sizeof (title1), id, format);
pl_format_title (next, -1, title2, sizeof (title2), id, format);
+ cmp = ascending ? strcmp (title1, title2) < 0 : strcmp (title1, title2) > 0;
}
- int cmp = ascending ? strcmp (title1, title2) < 0 : strcmp (title1, title2) > 0;
if (cmp) {
// printf ("%p %p swapping %s and %s\n", it, next, meta1, meta2);
sorted = 0;