summaryrefslogtreecommitdiff
path: root/plugins/gme
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-10-23 17:05:43 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-23 17:05:43 +0200
commit0556a39f8a37da68f21772da896ebfdf15b6057d (patch)
tree9097a29b5d9e4fcffe62356859823ad45a7ea5fd /plugins/gme
parentc4063208d93804d8836ed8c9fa423c6c931b724d (diff)
gme: added support for intro_length and loop_length
Diffstat (limited to 'plugins/gme')
-rw-r--r--plugins/gme/cgme.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/plugins/gme/cgme.c b/plugins/gme/cgme.c
index 6a28a878..e94a4773 100644
--- a/plugins/gme/cgme.c
+++ b/plugins/gme/cgme.c
@@ -41,6 +41,7 @@ int _Unwind_GetIPInfo;
static DB_decoder_t plugin;
static DB_functions_t *deadbeef;
static int conf_fadeout = 10;
+static int conf_loopcount = 2;
typedef struct {
DB_fileinfo_t info;
@@ -322,10 +323,10 @@ cgme_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id);
char str[1024];
if (inf->song[0]) {
- snprintf (str, 1024, "%d %s - %s", i, inf->game, inf->song);
+ snprintf (str, sizeof(str), "%d %s - %s", i, inf->game, inf->song);
}
else {
- snprintf (str, 1024, "%d %s - ?", i, inf->game);
+ snprintf (str, sizeof(str), "%d %s - ?", i, inf->game);
}
trace ("track subtune %d %s, length=%d\n", i, str, inf->length);
deadbeef->pl_set_meta_int (it, ":TRACKNUM", i);
@@ -349,9 +350,26 @@ cgme_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
char trk[10];
snprintf (trk, 10, "%d", i+1);
cgme_add_meta (it, "track", trk);
+ snprintf (str, sizeof(str), "%d", inf->length);
+ deadbeef->pl_add_meta (it, ":GME_LENGTH", str);
+ snprintf (str, sizeof(str), "%d", inf->intro_length);
+ deadbeef->pl_add_meta (it, ":GME_INTRO_LENGTH", str);
+ snprintf (str, sizeof(str), "%d", inf->loop_length);
+ deadbeef->pl_add_meta (it, ":GME_LOOP_LENGTH", str);
if (inf->length == -1 || inf->length == 0) {
- float songlength = deadbeef->conf_get_float ("gme.songlength", 3);
- deadbeef->plt_set_item_duration (plt, it, songlength * 60.f);
+ float songlength;
+
+ if (inf->loop_length > 0 && conf_loopcount > 0) {
+ songlength = inf->intro_length / 1000.f;
+ if (songlength < 0) {
+ songlength = 0;
+ }
+ songlength += (inf->loop_length * conf_loopcount) / 1000.f;
+ }
+ else {
+ songlength = deadbeef->conf_get_float ("gme.songlength", 3) * 60.f;
+ }
+ deadbeef->plt_set_item_duration (plt, it, songlength);
}
else {
deadbeef->plt_set_item_duration (plt, it, (float)inf->length/1000.f);
@@ -425,6 +443,7 @@ cgme_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) {
switch (id) {
case DB_EV_CONFIGCHANGED:
conf_fadeout = deadbeef->conf_get_int ("gme.fadeout", 10);
+ conf_loopcount = deadbeef->conf_get_int ("gme.loopcount", 2);
break;
}
return 0;
@@ -433,6 +452,7 @@ cgme_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) {
static const char settings_dlg[] =
"property \"Max song length (in minutes)\" entry gme.songlength 3;\n"
"property \"Fadeout length (seconds)\" entry gme.fadeout 10;\n"
+ "property \"Play loops nr. of times (if available)\" entry gme.loopcount 2;\n"
;
// define plugin interface