Mercurial > audlegacy-plugins
changeset 2953:2cbc458d8286
Fix backwards seeking in PSF2 files.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Wed, 15 Oct 2008 14:20:45 -0500 |
parents | 63bf9d97ce65 |
children | f1482af6384c |
files | src/psf2/plugin.c |
diffstat | 1 files changed, 14 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- a/src/psf2/plugin.c Tue Oct 14 22:28:14 2008 +0900 +++ b/src/psf2/plugin.c Wed Oct 15 14:20:45 2008 -0500 @@ -34,25 +34,9 @@ #include "corlett.h" #include "eng_protos.h" -/* file types */ -static uint32 type; +/* ao_get_lib: called to load secondary files */ +static gchar *path; -static struct -{ - uint32 sig; - char *name; - int32 (*start)(uint8 *, uint32); - int32 (*stop)(void); - int32 (*command)(int32, int32); - uint32 rate; -} types[] = { - { 0x50534602, "Sony PlayStation 2 (.psf2)", psf2_start, psf2_stop, psf2_command, 60 }, - { 0xffffffff, "", NULL, NULL, NULL, 0 } -}; - -static char *path; - -/* ao_get_lib: called to load secondary files */ int ao_get_lib(char *filename, uint8 **buffer, uint64 *length) { guchar *filebuf; @@ -128,40 +112,15 @@ { guchar *buffer; gsize size; - uint32 filesig; gint length; gchar *title = psf2_title(data->filename, &length); path = g_strdup(data->filename); aud_vfs_file_get_contents(data->filename, (gchar **) &buffer, &size); - // now try to identify the file - type = 0; - filesig = buffer[0]<<24 | buffer[1]<<16 | buffer[2]<<8 | buffer[3]; - while (types[type].sig != 0xffffffff) - { - if (filesig == types[type].sig) - { - break; - } - else - { - type++; - } - } - - // now did we identify it above or just fall through? - if (types[type].sig == 0xffffffff) - { - printf("ERROR: File is unknown, signature bytes are %02x %02x %02x %02x\n", buffer[0], buffer[1], buffer[2], buffer[3]); - free(buffer); - return; - } - if (psf2_start(buffer, size) != AO_SUCCESS) { free(buffer); - printf("ERROR: Engine rejected file!\n"); return; } @@ -181,11 +140,19 @@ data->eof = FALSE; data->output->flush(seek); - psf2_command(COMMAND_RESTART, 0); - psf2_seek(seek); + psf2_stop(); - seek = 0; - continue; + if (psf2_start(buffer, size) == AO_SUCCESS) + { + psf2_seek(seek); + seek = 0; + continue; + } + else + { + data->output->close_audio(); + break; + } } psf2_stop();