# HG changeset patch # User William Pitcock # Date 1214883391 18000 # Node ID af1338519322f62834a1dfd91d340310314c2d89 # Parent f0547285577e5b7f5dd798b7c93760ff54913b2b Plugin works kinda, but stopping after track ends isn't done yet. diff -r f0547285577e -r af1338519322 src/psf2/plugin.c --- a/src/psf2/plugin.c Mon Jun 30 22:21:38 2008 -0500 +++ b/src/psf2/plugin.c Mon Jun 30 22:36:31 2008 -0500 @@ -31,6 +31,7 @@ #include #include "ao.h" +#include "corlett.h" #include "eng_protos.h" /* file types */ @@ -44,10 +45,9 @@ int32 (*stop)(void); int32 (*command)(int32, int32); uint32 rate; - int32 (*fillinfo)(ao_display_info *); } types[] = { - { 0x50534602, "Sony PlayStation 2 (.psf2)", psf2_start, psf2_stop, psf2_command, 60, psf2_fill_info }, - { 0xffffffff, "", NULL, NULL, NULL, 0, NULL } + { 0x50534602, "Sony PlayStation 2 (.psf2)", psf2_start, psf2_stop, psf2_command, 60 }, + { 0xffffffff, "", NULL, NULL, NULL, 0 } }; static char *path; @@ -218,8 +218,7 @@ playback->output->pause(p); } -static int -is_our_fd(gchar *filename, VFSFile *file) +static int psf2_is_our_fd(gchar *filename, VFSFile *file) { gchar magic[4]; aud_vfs_fread(magic, 1, 4, file); @@ -230,6 +229,38 @@ return 0; } +static Tuple *psf2_tuple(gchar *filename) +{ + Tuple *t; + corlett_t *c; + guchar *buf; + gsize sz; + + aud_vfs_file_get_contents(filename, (gchar **) &buf, &sz); + + if (!buf) + return NULL; + + if (corlett_decode(buf, sz, NULL, NULL, &c) != AO_SUCCESS) + return NULL; + + t = aud_tuple_new_from_filename(filename); + + aud_tuple_associate_int(t, FIELD_LENGTH, NULL, psfTimeToMS(c->inf_length)); + aud_tuple_associate_string(t, FIELD_ARTIST, NULL, c->inf_artist); + aud_tuple_associate_string(t, FIELD_ALBUM, NULL, c->inf_game); + aud_tuple_associate_string(t, -1, "game", c->inf_game); + aud_tuple_associate_string(t, FIELD_TITLE, NULL, c->inf_title); + aud_tuple_associate_string(t, FIELD_COPYRIGHT, NULL, c->inf_copy); + aud_tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced"); + aud_tuple_associate_string(t, FIELD_CODEC, NULL, "PlayStation2 Audio"); + aud_tuple_associate_string(t, -1, "console", "PlayStation 2"); + + free(c); + + return t; +} + gchar *psf2_fmts[] = { "psf2", "minipsf2", NULL }; InputPlugin psf2_ip = @@ -241,9 +272,9 @@ #if 0 .seek = sexypsf_xmms_seek, .get_song_info = sexypsf_xmms_getsonginfo, - .get_song_tuple = get_aud_tuple_psf, #endif - .is_our_file_from_vfs = is_our_fd, + .get_song_tuple = psf2_tuple, + .is_our_file_from_vfs = psf2_is_our_fd, .vfs_extensions = psf2_fmts, };