Mercurial > hg > xmms-sid
comparison 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 |
comparison
equal
deleted
inserted
replaced
229:7bb9e20e3092 | 230:608f31f6c095 |
---|---|
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 */ | 21 */ |
22 #ifndef _XMMS_SID_H | 22 #ifndef _XMMS_SID_H |
23 #define _XMMS_SID_H | 23 #define _XMMS_SID_H |
24 | 24 |
25 #ifdef __cplusplus | |
26 extern "C" { | |
27 #endif | |
28 | |
29 #ifdef HAVE_CONFIG_H | 25 #ifdef HAVE_CONFIG_H |
30 #include <config.h> | 26 #include <config.h> |
31 #endif | 27 #endif |
32 | 28 |
33 #ifdef HAVE_ASSERT_H | 29 #ifdef HAVE_ASSERT_H |
35 #else | 31 #else |
36 #define assert(x) /* stub */ | 32 #define assert(x) /* stub */ |
37 #endif | 33 #endif |
38 | 34 |
39 #include <glib.h> | 35 #include <glib.h> |
36 #include <pthread.h> | |
40 #include <xmms/plugin.h> | 37 #include <xmms/plugin.h> |
41 | 38 |
42 /* | 39 #ifdef __cplusplus |
43 * Some defines | 40 extern "C" { |
41 #endif | |
42 | |
43 /* Some defines | |
44 */ | 44 */ |
45 #define DEBUG | 45 #define DEBUG |
46 | |
46 #undef HAVE_HARDSID_BUILDER /* HardSID-support is not working and is untested */ | 47 #undef HAVE_HARDSID_BUILDER /* HardSID-support is not working and is untested */ |
47 | 48 |
48 /* | |
49 * Generals | |
50 */ | |
51 #define XS_BUFSIZE (4096) /* Size for some buffers */ | 49 #define XS_BUFSIZE (4096) /* Size for some buffers */ |
50 | |
51 #define XS_SIDBUF_SIZE (80*1024) /* Size of data buffer used for SID-tune | |
52 MD5 hash calculation. If this is too small, | |
53 the computed hash will be incorrect. | |
54 Largest SID files I've seen are ~70kB. | |
55 */ | |
56 | |
57 #define XS_SIDBUF_DYNAMIC /* If not defined, static buffer is used. | |
58 Probably faster than allocating/deallocating | |
59 from heap, but fails on systems with limited | |
60 stack space. | |
61 */ | |
62 | |
63 #define XS_STIL_MAXENTRY (128) /* Max number of sub-songs in STIL/SLDB node */ | |
64 | |
52 | 65 |
53 #define XS_CONFIG_IDENT "XMMS-SID" /* Configuration file identifier */ | 66 #define XS_CONFIG_IDENT "XMMS-SID" /* Configuration file identifier */ |
54 #define XS_CONFIG_FILE "/.xmms/xmms-sid" /* Use this configfile if autocyrpe fails */ | 67 #define XS_CONFIG_FILE "/.xmms/xmms-sid" /* Use this configfile if autocyrpe fails */ |
55 | 68 |
56 #define XS_STIL_MAXENTRY (128) /* Max number of sub-songs in STIL/SLDB node */ | |
57 | |
58 #define XS_MIN_OVERSAMPLE (2) /* Minimum oversampling factor */ | 69 #define XS_MIN_OVERSAMPLE (2) /* Minimum oversampling factor */ |
59 #define XS_MAX_OVERSAMPLE (8) /* Maximum oversampling factor */ | 70 #define XS_MAX_OVERSAMPLE (8) /* Maximum oversampling factor */ |
60 | 71 |
61 extern InputPlugin xs_plugin_ip; /* XMMS-SID plugin structure */ | 72 |
73 /* Macros for mutexes and threads. These exist to be able to | |
74 * easily change from pthreads to glib threads, etc, if necessary. | |
75 */ | |
76 #define XS_MPP(M) M ## _mutex | |
77 #ifdef DEBUG | |
78 #define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; int M ## _qq; | |
79 #else | |
80 #define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_MUTEX_INITIALIZER | |
81 #endif | |
82 #define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M); extern int M ## _qq; | |
83 #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); } | |
84 #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); } | |
85 | |
86 /* Shorthands for linked lists | |
87 */ | |
88 #define LPREV (pNode->pPrev) | |
89 #define LTHIS (pNode) | |
90 #define LNEXT (pNode->pNext) | |
62 | 91 |
63 | 92 |
93 /* Plugin-wide typedefs | |
94 */ | |
64 typedef struct { | 95 typedef struct { |
65 gint tuneSpeed; | 96 gint tuneSpeed; |
66 gint tuneLength; | 97 gint tuneLength; |
67 gchar *tuneTitle; | 98 gchar *tuneTitle; |
68 } t_xs_subtune; | 99 } t_xs_subtuneinfo; |
69 | 100 |
70 | 101 |
71 typedef struct { | 102 typedef struct { |
72 gchar *tuneFilename, | 103 gchar *sidFilename, |
73 *tuneName, | 104 *sidName, |
74 *tuneComposer, | 105 *sidComposer, |
75 *tuneCopyright; | 106 *sidCopyright; |
107 gint loadAddr, | |
108 initAddr, | |
109 playAddr, | |
110 dataFileLen; | |
76 gint nsubTunes, startTune; | 111 gint nsubTunes, startTune; |
77 t_xs_subtune subTunes[XS_STIL_MAXENTRY]; | 112 t_xs_subtuneinfo subTunes[XS_STIL_MAXENTRY]; |
78 } t_xs_tune; | 113 } t_xs_tuneinfo; |
79 | 114 |
80 | 115 |
116 struct t_xs_status; | |
117 | |
81 typedef struct { | 118 typedef struct { |
82 gint audioFrequency, | 119 gint plrIdent; |
120 gboolean (*plrIsOurFile)(gchar *); | |
121 gboolean (*plrInit)(struct t_xs_status *); | |
122 void (*plrClose)(struct t_xs_status *); | |
123 gboolean (*plrInitSong)(struct t_xs_status *); | |
124 guint (*plrFillBuffer)(struct t_xs_status *, gchar *, guint); | |
125 gboolean (*plrLoadSID)(struct t_xs_status *, gchar *); | |
126 void (*plrDeleteSID)(struct t_xs_status *); | |
127 t_xs_tuneinfo* (*plrGetSIDInfo)(gchar *); | |
128 } t_xs_player; | |
129 | |
130 | |
131 typedef struct t_xs_status { | |
132 gint audioFrequency, /* Audio settings */ | |
83 audioFormat, | 133 audioFormat, |
84 audioChannels, | 134 audioChannels, |
85 audioBitsPerSample; | 135 audioBitsPerSample; |
86 void *player; | 136 void *sidEngine; /* SID-emulation internal engine data */ |
137 t_xs_player *sidPlayer; /* Selected player engine */ | |
87 gboolean isError, isPlaying; | 138 gboolean isError, isPlaying; |
88 gint currSong, | 139 gint currSong, /* Current sub-tune */ |
89 lastTime; | 140 lastTime; |
90 t_xs_tune *pTune; | 141 t_xs_tuneinfo *tuneInfo; |
91 } t_xs_status; | 142 } t_xs_status; |
92 | 143 |
93 | 144 |
94 extern t_xs_status xs_status; | 145 /* Global variables |
146 */ | |
147 extern InputPlugin xs_plugin_ip; | |
148 | |
149 extern t_xs_status xs_status; | |
150 XS_MUTEX_H(xs_status); | |
95 | 151 |
96 | 152 |
97 /* | 153 |
98 * Plugin function prototypes | 154 /* Plugin function prototypes |
99 */ | 155 */ |
100 void xs_init(void); | 156 void xs_init(void); |
101 void xs_reinit(void); | 157 void xs_reinit(void); |
102 void xs_close(void); | 158 void xs_close(void); |
103 gint xs_is_our_file(gchar *); | 159 gint xs_is_our_file(gchar *); |
107 void xs_seek(gint); | 163 void xs_seek(gint); |
108 gint xs_get_time(void); | 164 gint xs_get_time(void); |
109 void xs_get_song_info(gchar *, gchar **, gint *); | 165 void xs_get_song_info(gchar *, gchar **, gint *); |
110 void xs_fileinfo(gchar *); | 166 void xs_fileinfo(gchar *); |
111 void xs_about(void); | 167 void xs_about(void); |
168 void xs_set_subtune(gint); | |
112 | 169 |
113 t_xs_tune *xs_tune_new(gchar *, gint, gint, gchar *, gchar *, gchar *); | 170 t_xs_tuneinfo *xs_tuneinfo_new(gchar *, gint, gint, gchar *, gchar *, gchar *, gint, gint, gint, gint); |
114 void xs_tune_free(t_xs_tune *); | 171 void xs_tuneinfo_free(t_xs_tuneinfo *); |
115 | 172 |
116 | 173 |
117 /* | 174 /* Debugging and error handling macros |
118 * Debugging and error handling macros | |
119 */ | 175 */ |
120 #ifdef DEBUG | 176 #ifdef DEBUG |
121 #define XSDEBUG(x...) { fprintf(stderr, "XS[%s:%d]: ", __FILE__, (int) __LINE__); fprintf(stderr, ## x); } | 177 #define XSDEBUG(x...) { fprintf(stderr, "XS[%s:%s:%d]: ", __FILE__, __FUNCTION__, (int) __LINE__); fprintf(stderr, ## x); } |
122 #else | 178 #else |
123 #define XSDEBUG(x...) /* foo */ | 179 #define XSDEBUG(x...) /* foo */ |
124 #endif | 180 #endif |
125 | 181 |
126 #define XSERR(x...) { fprintf(stderr, PACKAGE_NAME ": "); fprintf(stderr, ## x); } | 182 #define XSERR(x...) { fprintf(stderr, PACKAGE_NAME ": "); fprintf(stderr, ## x); } |