summaryrefslogtreecommitdiff
path: root/plugins/aac/aac.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-11-14 22:20:06 +0100
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2013-11-14 22:20:06 +0100
commit632eb7b107267d40ada93fc3fdaf0e23be31250d (patch)
tree2db449fe2ee5fbd6658e6117631d38aefd4b74da /plugins/aac/aac.c
parent366a4c67e495562c60df73bd3999c214dd37ca3c (diff)
aac: workaround for corrupted chapter titles in m4b
Diffstat (limited to 'plugins/aac/aac.c')
-rw-r--r--plugins/aac/aac.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/plugins/aac/aac.c b/plugins/aac/aac.c
index 9d97fe8a..d86298a5 100644
--- a/plugins/aac/aac.c
+++ b/plugins/aac/aac.c
@@ -1013,7 +1013,9 @@ aac_load_itunes_chapters (mp4ff_t *mp4, /* out */ int *num_chapters, int sampler
}
int len = (buffer[0] << 8) | buffer[1];
len = min (len, buffer_size - 2);
- chapters[*num_chapters].title = strndup (&buffer[2], len);
+ if (len > 0) {
+ chapters[*num_chapters].title = strndup (&buffer[2], len);
+ }
chapters[*num_chapters].startsample = curr_sample;
curr_sample += (int64_t)dur * samplerate / 1000.f;
chapters[*num_chapters].endsample = curr_sample - 1;
@@ -1042,7 +1044,15 @@ aac_insert_with_chapters (ddb_playlist_t *plt, DB_playItem_t *after, DB_playItem
DB_playItem_t *it = deadbeef->pl_item_alloc_init (uri, dec);
deadbeef->pl_set_meta_int (it, ":TRACKNUM", i);
deadbeef->pl_set_meta_int (it, "TRACK", i);
- deadbeef->pl_add_meta (it, "title", chapters[i].title);
+ // poor-man utf8 check
+ if (!chapters[i].title || deadbeef->junk_detect_charset (chapters[i].title)) {
+ char s[1000];
+ snprintf (s, sizeof (s), "chapter %d", i+1);
+ deadbeef->pl_add_meta (it, "title", s);
+ }
+ else {
+ deadbeef->pl_add_meta (it, "title", chapters[i].title);
+ }
it->startsample = chapters[i].startsample;
it->endsample = chapters[i].endsample;
deadbeef->pl_replace_meta (it, ":FILETYPE", ftype);