# HG changeset patch # User Matti Hamalainen # Date 1169696762 0 # Node ID 9dafc55c4270067e6803cf3ee9c87a8840309e82 # Parent 00a32ab5887d7b0f848de2c809b37c93056c4e7c Beginnings of vfs portability. diff -r 00a32ab5887d -r 9dafc55c4270 src/xs_sidplay1.cc --- a/src/xs_sidplay1.cc Thu Jan 25 03:44:01 2007 +0000 +++ b/src/xs_sidplay1.cc Thu Jan 25 03:46:02 2007 +0000 @@ -44,21 +44,31 @@ extern "C" { +/* Return song information + */ +#define TFUNCTION xs_sidplay1_getinfo +#define TFUNCTION2 xs_sidplay1_updateinfo +#define TTUNEINFO sidTuneInfo +#define TTUNE sidTune +#define TENGINE t_xs_sidplay1 +#include "xs_sidplay.h" + + /* Check if we can play the given file */ -gboolean xs_sidplay1_isourfile(gchar * pcFilename) +gboolean xs_sidplay1_isourfile(t_xs_file *f) { - sidTune *testTune = new sidTune(pcFilename); - - if (!testTune) return FALSE; - - if (!testTune->getStatus()) { - delete testTune; + gchar tmpBuf[4]; + + if (!f) return FALSE; + + if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) return FALSE; - } - - delete testTune; - return TRUE; + + if (!strncmp(tmpBuf, "PSID", 4)) + return TRUE; + else + return FALSE; } @@ -327,13 +337,5 @@ } -/* Return song information - */ -#define TFUNCTION xs_sidplay1_getinfo -#define TFUNCTION2 xs_sidplay1_updateinfo -#define TTUNEINFO sidTuneInfo -#define TTUNE sidTune -#include "xs_sidplay.h" - -} /* extern "C" */ -#endif /* HAVE_SIDPLAY1 */ +} /* extern "C" */ +#endif /* HAVE_SIDPLAY1 */ diff -r 00a32ab5887d -r 9dafc55c4270 src/xs_sidplay1.h --- a/src/xs_sidplay1.h Thu Jan 25 03:44:01 2007 +0000 +++ b/src/xs_sidplay1.h Thu Jan 25 03:46:02 2007 +0000 @@ -2,6 +2,7 @@ #define _XS_SIDPLAY1_H #include "xmms-sid.h" +#include "xs_support.h" /* Maximum audio frequency supported by libSIDPlay v1 */ #define SIDPLAY1_MAX_FREQ (48000) @@ -10,7 +11,7 @@ extern "C" { #endif -gboolean xs_sidplay1_isourfile(gchar *); +gboolean xs_sidplay1_isourfile(t_xs_file *); void xs_sidplay1_close(t_xs_status *); gboolean xs_sidplay1_init(t_xs_status *); gboolean xs_sidplay1_initsong(t_xs_status *); diff -r 00a32ab5887d -r 9dafc55c4270 src/xs_sidplay2.cc --- a/src/xs_sidplay2.cc Thu Jan 25 03:44:01 2007 +0000 +++ b/src/xs_sidplay2.cc Thu Jan 25 03:46:02 2007 +0000 @@ -27,7 +27,6 @@ #include #include "xs_sidplay2.h" #include "xs_config.h" -#include "xs_support.h" #include @@ -51,27 +50,37 @@ extern "C" { +/* Return song information + */ +#define TFUNCTION xs_sidplay2_getinfo +#define TFUNCTION2 xs_sidplay2_updateinfo +#define TTUNEINFO SidTuneInfo +#define TTUNE SidTune +#define TENGINE t_xs_sidplay2 +#include "xs_sidplay.h" + + /* Check if we can play the given file */ -gboolean xs_sidplay2_isourfile(gchar *pcFilename) +gboolean xs_sidplay2_isourfile(t_xs_file *f) { - SidTune *testTune = new SidTune(pcFilename); - - if (!testTune) return FALSE; - - if (!testTune->getStatus()) { - delete testTune; + gchar tmpBuf[4]; + + if (!f) return FALSE; + + if (xs_fread(tmpBuf, sizeof(gchar), 4, f) != 4) return FALSE; - } - - delete testTune; - return TRUE; + + if (!strncmp(tmpBuf, "PSID", 4) || !strncmp(tmpBuf, "RSID", 4)) + return TRUE; + else + return FALSE; } /* Initialize SIDPlay2 */ -gboolean xs_sidplay2_init(t_xs_ t_xs_status * myStatus) +gboolean xs_sidplay2_init(t_xs_status * myStatus) { gint tmpFreq; t_xs_sidplay2 *myEngine; @@ -348,7 +357,7 @@ myEngine->currTune = NULL; } - xs_sidplay2_deletesid(myStatus); + xs_sidplay2_delete(myStatus); g_free(myEngine); myStatus->sidEngine = NULL; @@ -427,13 +436,5 @@ } -/* Return song information - */ -#define TFUNCTION xs_sidplay2_getinfo -#define TFUNCTION2 xs_sidplay2_updateinfo -#define TTUNEINFO SidTuneInfo -#define TTUNE SidTune -#include "xs_sidplay.h" - } /* extern "C" */ #endif /* HAVE_SIDPLAY2 */ diff -r 00a32ab5887d -r 9dafc55c4270 src/xs_sidplay2.h --- a/src/xs_sidplay2.h Thu Jan 25 03:44:01 2007 +0000 +++ b/src/xs_sidplay2.h Thu Jan 25 03:46:02 2007 +0000 @@ -2,12 +2,13 @@ #define _XS_SIDPLAY2_H #include "xmms-sid.h" +#include "xs_support.h" #ifdef __cplusplus extern "C" { #endif -gboolean xs_sidplay2_isourfile(gchar *); +gboolean xs_sidplay2_isourfile(t_xs_file *); void xs_sidplay2_close(t_xs_status *); gboolean xs_sidplay2_init(t_xs_status *); gboolean xs_sidplay2_initsong(t_xs_status *);