comparison src/psf2/plugin.c @ 2744:af1338519322

Plugin works kinda, but stopping after track ends isn't done yet.
author William Pitcock <nenolod@atheme.org>
date Mon, 30 Jun 2008 22:36:31 -0500
parents fd5373830ac1
children aa2e0f33f55d
comparison
equal deleted inserted replaced
2743:f0547285577e 2744:af1338519322
29 #include <string.h> 29 #include <string.h>
30 30
31 #include <audacious/plugin.h> 31 #include <audacious/plugin.h>
32 32
33 #include "ao.h" 33 #include "ao.h"
34 #include "corlett.h"
34 #include "eng_protos.h" 35 #include "eng_protos.h"
35 36
36 /* file types */ 37 /* file types */
37 static uint32 type; 38 static uint32 type;
38 39
42 char *name; 43 char *name;
43 int32 (*start)(uint8 *, uint32); 44 int32 (*start)(uint8 *, uint32);
44 int32 (*stop)(void); 45 int32 (*stop)(void);
45 int32 (*command)(int32, int32); 46 int32 (*command)(int32, int32);
46 uint32 rate; 47 uint32 rate;
47 int32 (*fillinfo)(ao_display_info *);
48 } types[] = { 48 } types[] = {
49 { 0x50534602, "Sony PlayStation 2 (.psf2)", psf2_start, psf2_stop, psf2_command, 60, psf2_fill_info }, 49 { 0x50534602, "Sony PlayStation 2 (.psf2)", psf2_start, psf2_stop, psf2_command, 60 },
50 { 0xffffffff, "", NULL, NULL, NULL, 0, NULL } 50 { 0xffffffff, "", NULL, NULL, NULL, 0 }
51 }; 51 };
52 52
53 static char *path; 53 static char *path;
54 54
55 /* ao_get_lib: called to load secondary files */ 55 /* ao_get_lib: called to load secondary files */
216 void psf2_pause(InputPlayback *playback, short p) 216 void psf2_pause(InputPlayback *playback, short p)
217 { 217 {
218 playback->output->pause(p); 218 playback->output->pause(p);
219 } 219 }
220 220
221 static int 221 static int psf2_is_our_fd(gchar *filename, VFSFile *file)
222 is_our_fd(gchar *filename, VFSFile *file)
223 { 222 {
224 gchar magic[4]; 223 gchar magic[4];
225 aud_vfs_fread(magic, 1, 4, file); 224 aud_vfs_fread(magic, 1, 4, file);
226 225
227 if (!memcmp(magic, "PSF\x02", 4)) 226 if (!memcmp(magic, "PSF\x02", 4))
228 return 1; 227 return 1;
229 228
230 return 0; 229 return 0;
230 }
231
232 static Tuple *psf2_tuple(gchar *filename)
233 {
234 Tuple *t;
235 corlett_t *c;
236 guchar *buf;
237 gsize sz;
238
239 aud_vfs_file_get_contents(filename, (gchar **) &buf, &sz);
240
241 if (!buf)
242 return NULL;
243
244 if (corlett_decode(buf, sz, NULL, NULL, &c) != AO_SUCCESS)
245 return NULL;
246
247 t = aud_tuple_new_from_filename(filename);
248
249 aud_tuple_associate_int(t, FIELD_LENGTH, NULL, psfTimeToMS(c->inf_length));
250 aud_tuple_associate_string(t, FIELD_ARTIST, NULL, c->inf_artist);
251 aud_tuple_associate_string(t, FIELD_ALBUM, NULL, c->inf_game);
252 aud_tuple_associate_string(t, -1, "game", c->inf_game);
253 aud_tuple_associate_string(t, FIELD_TITLE, NULL, c->inf_title);
254 aud_tuple_associate_string(t, FIELD_COPYRIGHT, NULL, c->inf_copy);
255 aud_tuple_associate_string(t, FIELD_QUALITY, NULL, "sequenced");
256 aud_tuple_associate_string(t, FIELD_CODEC, NULL, "PlayStation2 Audio");
257 aud_tuple_associate_string(t, -1, "console", "PlayStation 2");
258
259 free(c);
260
261 return t;
231 } 262 }
232 263
233 gchar *psf2_fmts[] = { "psf2", "minipsf2", NULL }; 264 gchar *psf2_fmts[] = { "psf2", "minipsf2", NULL };
234 265
235 InputPlugin psf2_ip = 266 InputPlugin psf2_ip =
239 .stop = psf2_Stop, 270 .stop = psf2_Stop,
240 .pause = psf2_pause, 271 .pause = psf2_pause,
241 #if 0 272 #if 0
242 .seek = sexypsf_xmms_seek, 273 .seek = sexypsf_xmms_seek,
243 .get_song_info = sexypsf_xmms_getsonginfo, 274 .get_song_info = sexypsf_xmms_getsonginfo,
244 .get_song_tuple = get_aud_tuple_psf,
245 #endif 275 #endif
246 .is_our_file_from_vfs = is_our_fd, 276 .get_song_tuple = psf2_tuple,
277 .is_our_file_from_vfs = psf2_is_our_fd,
247 .vfs_extensions = psf2_fmts, 278 .vfs_extensions = psf2_fmts,
248 }; 279 };
249 280
250 InputPlugin *psf2_iplist[] = { &psf2_ip, NULL }; 281 InputPlugin *psf2_iplist[] = { &psf2_ip, NULL };
251 282