changeset 467:9dafc55c4270

Beginnings of vfs portability.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 25 Jan 2007 03:46:02 +0000
parents 00a32ab5887d
children 6963982fcbb6
files src/xs_sidplay1.cc src/xs_sidplay1.h src/xs_sidplay2.cc src/xs_sidplay2.h
diffstat 4 files changed, 50 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- 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 */
--- 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 *);
--- 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 <stdio.h>
 #include "xs_sidplay2.h"
 #include "xs_config.h"
-#include "xs_support.h"
 
 
 #include <sidplay/sidplay2.h>
@@ -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 */
--- 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 *);