Mercurial > audlegacy
diff Plugins/Input/console/Audacious_Driver.cpp @ 477:8fc500c08b61 trunk
[svn] SPC length detection c/o Kiyoshi Aman <kiyoshi.aman -at- gmail.com>
author | nenolod |
---|---|
date | Thu, 19 Jan 2006 19:31:32 -0800 |
parents | c7191cd6ee8e |
children | 0b9507985f0d |
line wrap: on
line diff
--- a/Plugins/Input/console/Audacious_Driver.cpp Thu Jan 19 15:45:42 2006 -0800 +++ b/Plugins/Input/console/Audacious_Driver.cpp Thu Jan 19 19:31:32 2006 -0800 @@ -27,6 +27,8 @@ #include <cstring> #include <stdio.h> +#include <cstdlib> +#include <cctype> static Spc_Emu *spc = NULL; static Nsf_Emu *nsf = NULL; @@ -81,10 +83,21 @@ return 0; } +static gint strtoi(gchar *buf,size_t len) { + guint num = 0; + while (len && isdigit(*buf)) { + num *= 10; + num += *buf - '0'; + buf++; + len--; + } + return num; +} + static gchar *get_title_spc(gchar *filename) { gchar *title; - Emu_Std_Reader reader; + Spc_Reader reader; Spc_Emu::header_t header; reader.open(filename); @@ -257,7 +270,7 @@ static void play_file_spc(char *filename) { gchar *name; - Emu_Std_Reader reader; + Spc_Reader reader; Spc_Emu::header_t header; gint samplerate; @@ -278,7 +291,12 @@ name = get_title(filename); - if (audcfg.loop_length) + spc->length = strtoi(header.len_secs,3); + + if (spc->length > 0) + console_ip.set_info(name, spc->length * 1000, + spc->voice_count() * 1000, samplerate, 2); + else if (audcfg.loop_length) console_ip.set_info(name, audcfg.loop_length * 1000, spc->voice_count() * 1000, samplerate, 2); else @@ -550,6 +568,9 @@ my_spc->play(1024, buf); + if ((console_ip.output->output_time() / 1000) > + spc->length && spc->length != 0) + break; if ((console_ip.output->output_time() / 1000) > audcfg.loop_length && audcfg.loop_length != 0) break;