# HG changeset patch # User William Pitcock # Date 1224280063 18000 # Node ID 6013ab159139f077bda105f703c710aa50245a0d # Parent 629d5494c8f1a9d3529e5b513c8f03e19b272aea Make forward seeking work. Backwards seeking is still not working. diff -r 629d5494c8f1 -r 6013ab159139 src/xsf/plugin.c --- a/src/xsf/plugin.c Thu Oct 16 14:53:09 2008 -0500 +++ b/src/xsf/plugin.c Fri Oct 17 16:47:43 2008 -0500 @@ -116,6 +116,7 @@ gchar *title = xsf_title(data->filename, &length); gint16 samples[44100*2]; gint seglen = 44100 / 60; + gfloat pos; path = g_strdup(data->filename); aud_vfs_file_get_contents(data->filename, (gchar **) &buffer, &size); @@ -146,21 +147,57 @@ if (seek) { - data->eof = FALSE; - data->output->flush(seek); - - xsf_term(); + if (seek > data->output->output_time()) + { + pos = data->output->output_time(); + while (pos < seek) + { + xsf_gen(samples, seglen); + pos += 16.666; + } - if (xsf_start(buffer, size) == AO_SUCCESS) - { - //xsf_seek(seek); + data->output->flush(seek); seek = 0; + continue; } - else + else if (seek < data->output->output_time()) { - data->output->close_audio(); - break; + data->eof = FALSE; + + g_print("xsf_term\n"); + xsf_term(); + + g_print("xsf_start... "); + if (xsf_start(buffer, size) == AO_SUCCESS) + { + g_print("ok!\n"); + pos = 0; + while (pos < seek) + { + xsf_gen(samples, seglen); + pos += 16.666; /* each segment is 16.666ms */ + } + + data->output->flush(seek); + seek = 0; + + continue; + } + else + { + g_print("fail :(\n"); + + data->output->close_audio(); + + g_free(buffer); + g_free(path); + g_free(title); + + data->playing = FALSE; + + return; + } } } @@ -211,22 +248,6 @@ count -= t; buffer += t; } - -#if 0 - if (seek) - { - if (xsf_seek(seek)) - { - playback->output->flush(seek); - seek = 0; - } - else - { - playback->eof = TRUE; - return; - } - } -#endif } void xsf_Stop(InputPlayback *playback) diff -r 629d5494c8f1 -r 6013ab159139 src/xsf/vio2sf.c --- a/src/xsf/vio2sf.c Thu Oct 16 14:53:09 2008 -0500 +++ b/src/xsf/vio2sf.c Fri Oct 17 16:47:43 2008 -0500 @@ -9,6 +9,7 @@ #include "desmume/cp15.h" #include +#include #include "tagget.h" #include "vio2sf.h" @@ -248,8 +249,10 @@ if (!load_libs(pwork->level + 1, libbuf, libsize) || !load_psf_one(libbuf, libsize)) ret = xsf_tagenum_callback_returnvaluebreak; else + { pwork->found++; - free(libbuf); + free(libbuf); + } } free(lib); } @@ -631,8 +634,10 @@ sndifwork.arm7_clockdown_level = xsf_tagget_int("_vio2sf_arm7_clockdown_level", pfile, bytes, clockdown); sndifwork.xfs_load = 0; + printf("load_psf... "); if (!load_psf(pfile, bytes)) return XSF_FALSE; + printf("ok!\n"); #ifdef GDB_STUB if (NDS_Init(&arm9_base_memory_iface, &arm9_ctrl_iface, &arm7_base_memory_iface, &arm7_ctrl_iface))