diff options
author | Max Kellermann <max@duempel.org> | 2009-02-12 16:47:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-02-12 16:47:48 +0100 |
commit | 321eb1077a54aa84dca2f6363fe776af4f489689 (patch) | |
tree | 246ea02f95447f26fcb293dedc03d78f118a6c63 /src/decoder | |
parent | 149233946329ae050142e3fe1b9656d7cd9dd1dc (diff) | |
download | mpd-321eb1077a54aa84dca2f6363fe776af4f489689.tar.gz mpd-321eb1077a54aa84dca2f6363fe776af4f489689.tar.xz mpd-321eb1077a54aa84dca2f6363fe776af4f489689.zip |
wildmidi: provide and current total song time
The _WM_Info struct provides all we need, it is obtained by
WildMidi_GetInfo().
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/wildmidi_plugin.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/decoder/wildmidi_plugin.c b/src/decoder/wildmidi_plugin.c index e8cd42dee..39b82d0b1 100644 --- a/src/decoder/wildmidi_plugin.c +++ b/src/decoder/wildmidi_plugin.c @@ -54,23 +54,38 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs) .channels = 2, }; midi *wm; + const struct _WM_Info *info; enum decoder_command cmd; wm = WildMidi_Open(path_fs); if (wm == NULL) return; - decoder_initialized(decoder, &audio_format, false, -1); + info = WildMidi_GetInfo(wm); + if (info == NULL) { + WildMidi_Close(wm); + return; + } + + decoder_initialized(decoder, &audio_format, false, + info->approx_total_samples / WILDMIDI_SAMPLE_RATE); do { char buffer[4096]; int len; + info = WildMidi_GetInfo(wm); + if (info == NULL) + break; + len = WildMidi_GetOutput(wm, buffer, sizeof(buffer)); if (len <= 0) break; - cmd = decoder_data(decoder, NULL, buffer, len, 0, 0, NULL); + cmd = decoder_data(decoder, NULL, buffer, len, + (float)info->current_sample / + (float)WILDMIDI_SAMPLE_RATE, + 0, NULL); } while (cmd == DECODE_COMMAND_NONE); WildMidi_Close(wm); @@ -79,10 +94,24 @@ wildmidi_file_decode(struct decoder *decoder, const char *path_fs) static struct tag * wildmidi_tag_dup(const char *path_fs) { - struct tag *tag = tag_new(); + midi *wm; + const struct _WM_Info *info; + struct tag *tag; - /* to be implemented */ - (void)path_fs; + wm = WildMidi_Open(path_fs); + if (wm == NULL) + return NULL; + + info = WildMidi_GetInfo(wm); + if (info == NULL) { + WildMidi_Close(wm); + return NULL; + } + + tag = tag_new(); + tag->time = info->approx_total_samples / WILDMIDI_SAMPLE_RATE; + + WildMidi_Close(wm); return tag; } |