diff src/xmms-sid.h @ 230:608f31f6c095

Raw cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 21 Dec 2004 09:25:03 +0000
parents d18bf68d7bd9
children d04191d1ea64
line wrap: on
line diff
--- a/src/xmms-sid.h	Sun Dec 19 16:57:01 2004 +0000
+++ b/src/xmms-sid.h	Tue Dec 21 09:25:03 2004 +0000
@@ -22,10 +22,6 @@
 #ifndef _XMMS_SID_H
 #define _XMMS_SID_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -37,65 +33,125 @@
 #endif
 
 #include <glib.h>
+#include <pthread.h>
 #include <xmms/plugin.h>
 
-/*
- * Some defines
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Some defines
  */
 #define DEBUG
+
 #undef HAVE_HARDSID_BUILDER	/* HardSID-support is not working and is untested */
 
-/*
- * Generals
- */
 #define XS_BUFSIZE		(4096)		/* Size for some buffers */
 
+#define XS_SIDBUF_SIZE		(80*1024)	/* Size of data buffer used for SID-tune
+						MD5 hash calculation. If this is too small,
+						the computed hash will be incorrect.
+						Largest SID files I've seen are ~70kB.
+						*/
+
+#define XS_SIDBUF_DYNAMIC			/* If not defined, static buffer is used.
+						Probably faster than allocating/deallocating
+						from heap, but fails on systems with limited
+						stack space.
+						*/
+
+#define XS_STIL_MAXENTRY	(128)		/* Max number of sub-songs in STIL/SLDB node */
+
+
 #define XS_CONFIG_IDENT		"XMMS-SID"	/* Configuration file identifier */
 #define XS_CONFIG_FILE		"/.xmms/xmms-sid"	/* Use this configfile if autocyrpe fails */
 
-#define XS_STIL_MAXENTRY	(128)		/* Max number of sub-songs in STIL/SLDB node */
-
 #define XS_MIN_OVERSAMPLE	(2)		/* Minimum oversampling factor */
 #define XS_MAX_OVERSAMPLE	(8)		/* Maximum oversampling factor */
 
-extern InputPlugin xs_plugin_ip;		/* XMMS-SID plugin structure */
+
+/* Macros for mutexes and threads. These exist to be able to
+ * easily change from pthreads to glib threads, etc, if necessary.
+ */
+#define XS_MPP(M)	M ## _mutex
+#ifdef DEBUG
+#define XS_MUTEX(M)	pthread_mutex_t	XS_MPP(M) = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; int M ## _qq;
+#else
+#define XS_MUTEX(M)	pthread_mutex_t	XS_MPP(M) = PTHREAD_MUTEX_INITIALIZER
+#endif
+#define XS_MUTEX_H(M)	extern pthread_mutex_t XS_MPP(M); extern int M ## _qq;
+#define XS_MUTEX_LOCK(M)	{ M ## _qq = pthread_mutex_lock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_LOCK(" #M ") == %i\n", M ## _qq); }
+#define XS_MUTEX_UNLOCK(M)	{ M ## _qq = pthread_mutex_unlock(&XS_MPP(M)); if (M ## _qq) XSDEBUG("XS_MUTEX_UNLOCK(" #M ") == %i\n", M ## _qq); }
+
+/* Shorthands for linked lists
+ */
+#define LPREV	(pNode->pPrev)
+#define LTHIS	(pNode)
+#define LNEXT	(pNode->pNext)
 
 
+/* Plugin-wide typedefs
+ */
 typedef struct {
 	gint		tuneSpeed;
 	gint		tuneLength;
 	gchar		*tuneTitle;
-} t_xs_subtune;
-
-
-typedef struct {
-	gchar		*tuneFilename,
-			*tuneName,
-			*tuneComposer,
-			*tuneCopyright;
-	gint		nsubTunes, startTune;
-	t_xs_subtune	subTunes[XS_STIL_MAXENTRY];
-} t_xs_tune;
+} t_xs_subtuneinfo;
 
 
 typedef struct {
-	gint		audioFrequency,
+	gchar		*sidFilename,
+			*sidName,
+			*sidComposer,
+			*sidCopyright;
+	gint		loadAddr,
+			initAddr,
+			playAddr,
+			dataFileLen;
+	gint		nsubTunes, startTune;
+	t_xs_subtuneinfo	subTunes[XS_STIL_MAXENTRY];
+} t_xs_tuneinfo;
+
+
+struct t_xs_status;
+
+typedef struct {
+	gint		plrIdent;
+	gboolean	(*plrIsOurFile)(gchar *);
+	gboolean	(*plrInit)(struct t_xs_status *);
+	void		(*plrClose)(struct t_xs_status *);
+	gboolean	(*plrInitSong)(struct t_xs_status *);
+	guint		(*plrFillBuffer)(struct t_xs_status *, gchar *, guint);
+	gboolean	(*plrLoadSID)(struct t_xs_status *, gchar *);
+	void		(*plrDeleteSID)(struct t_xs_status *);
+	t_xs_tuneinfo*	(*plrGetSIDInfo)(gchar *);
+} t_xs_player;
+
+
+typedef struct t_xs_status {
+	gint		audioFrequency,		/* Audio settings */
 			audioFormat,
 			audioChannels,
 			audioBitsPerSample;
-	void		*player;
+	void		*sidEngine;		/* SID-emulation internal engine data */
+	t_xs_player	*sidPlayer;		/* Selected player engine */
 	gboolean	isError, isPlaying;
-	gint		currSong,
+	gint		currSong,		/* Current sub-tune */
 			lastTime;
-	t_xs_tune	*pTune;
+	t_xs_tuneinfo	*tuneInfo;
 } t_xs_status;
 
 
-extern t_xs_status xs_status;
+/* Global variables
+ */
+extern InputPlugin	xs_plugin_ip;
+
+extern t_xs_status	xs_status;
+XS_MUTEX_H(xs_status);
 
 
-/*
- * Plugin function prototypes
+
+/* Plugin function prototypes
  */
 void	xs_init(void);
 void	xs_reinit(void);
@@ -109,16 +165,16 @@
 void	xs_get_song_info(gchar *, gchar **, gint *);
 void	xs_fileinfo(gchar *);
 void	xs_about(void);
+void	xs_set_subtune(gint);
 
-t_xs_tune *xs_tune_new(gchar *, gint, gint, gchar *, gchar *, gchar *);
-void	xs_tune_free(t_xs_tune *);
+t_xs_tuneinfo *xs_tuneinfo_new(gchar *, gint, gint, gchar *, gchar *, gchar *, gint, gint, gint, gint);
+void	xs_tuneinfo_free(t_xs_tuneinfo *);
 
 
-/*
- * Debugging and error handling macros
+/* Debugging and error handling macros
  */
 #ifdef DEBUG
-#define XSDEBUG(x...) { fprintf(stderr, "XS[%s:%d]: ", __FILE__, (int) __LINE__); fprintf(stderr, ## x); }
+#define XSDEBUG(x...) { fprintf(stderr, "XS[%s:%s:%d]: ", __FILE__, __FUNCTION__, (int) __LINE__); fprintf(stderr, ## x); }
 #else
 #define XSDEBUG(x...) /* foo */
 #endif