summaryrefslogtreecommitdiff
path: root/plugins/adplug/adplug-db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/adplug/adplug-db.cpp')
-rw-r--r--plugins/adplug/adplug-db.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/plugins/adplug/adplug-db.cpp b/plugins/adplug/adplug-db.cpp
index 86323d45..6aa46dab 100644
--- a/plugins/adplug/adplug-db.cpp
+++ b/plugins/adplug/adplug-db.cpp
@@ -79,10 +79,12 @@ adplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
info->subsong = it->tracknum;
info->decoder->rewind (info->subsong);
- info->totalsamples = info->decoder->songlength (info->subsong) / 1000.f * samplerate;
+ float dur = deadbeef->pl_get_item_duration (it);
+ info->totalsamples = dur * samplerate;
info->currentsample = 0;
info->toadd = 0;
+ printf ("playing subtrack %d dur %f\n", info->subsong, dur);
// fill in mandatory plugin fields
_info->plugin = &adplug_plugin;
_info->bps = bps;
@@ -247,25 +249,30 @@ adplug_insert (DB_playItem_t *after, const char *fname) {
int subsongs = p->getsubsongs ();
for (int i = 0; i < subsongs; i++) {
// prepare track for addition
+ float dur = p->songlength (i)/1000.f;
+ if (dur < 0.1) {
+ continue;
+ }
+ printf ("adding subtrack %d dur %f\n", i, dur);
DB_playItem_t *it = deadbeef->pl_item_alloc ();
it->decoder_id = deadbeef->plug_get_decoder_id (adplug_plugin.plugin.id);
it->fname = strdup (fname);
it->filetype = adplug_get_extension (fname);
it->tracknum = i;
- deadbeef->pl_set_item_duration (it, p->songlength (i)/1000.f);
+ deadbeef->pl_set_item_duration (it, dur);
// add metainfo
-// if (p->gettitle()[0]) {
-// adplug_add_meta (it, "title", p->gettitle());
-// }
-// else {
-// deadbeef->pl_add_meta (it, "title", NULL);
-// }
-// if (p->getdesc()[0]) {
-// adplug_add_meta (it, "comment", p->getdesc());
-// }
-// if (!p->getauthor()[0]) {
-// adplug_add_meta (it, "artist", p->getauthor());
-// }
+ if (p->gettitle()[0]) {
+ adplug_add_meta (it, "title", p->gettitle());
+ }
+ else {
+ deadbeef->pl_add_meta (it, "title", NULL);
+ }
+ if (p->getdesc()[0]) {
+ adplug_add_meta (it, "comment", p->getdesc());
+ }
+ if (!p->getauthor()[0]) {
+ adplug_add_meta (it, "artist", p->getauthor());
+ }
deadbeef->pl_add_meta (it, "title", NULL);
// insert
after = deadbeef->pl_insert_item (after, it);