Mercurial > hg > xmms-sid
annotate src/xmms-sid.h @ 334:19c89f9ca2cc
Misc commit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 22 Sep 2005 02:19:02 +0000 |
parents | 7888e5d973b9 |
children | 26079ab52fc3 |
rev | line source |
---|---|
1 | 1 /* |
3 | 2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
1 | 3 |
4 Main header file | |
5 | |
324 | 6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
7 (C) Copyright 1999-2005 Tecnic Software productions (TNSP) | |
1 | 8 |
9 This program is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 2 of the License, or | |
12 (at your option) any later version. | |
13 | |
14 This program is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with this program; if not, write to the Free Software | |
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
22 */ | |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
23 #ifndef _XMMS_SID_H |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
24 #define _XMMS_SID_H |
1 | 25 |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
26 #ifdef HAVE_CONFIG_H |
24 | 27 #include <config.h> |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
28 #endif |
219 | 29 |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
30 #ifdef HAVE_ASSERT_H |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
31 #include <assert.h> |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
32 #else |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
33 #define assert(x) /* stub */ |
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
34 #endif |
219 | 35 |
1 | 36 #include <glib.h> |
230 | 37 #include <pthread.h> |
1 | 38 |
230 | 39 #ifdef __cplusplus |
40 extern "C" { | |
41 #endif | |
42 | |
328 | 43 #include <xmms/plugin.h> |
44 | |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
45 /* |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
46 * Some constants and defines |
78
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
47 */ |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
48 /* Define for spurious debugging messages */ |
300 | 49 #define DEBUG |
50 | |
51 /* Define to ISO C99 macro for debugging instead of varargs function. | |
52 * This provides more useful information. | |
53 */ | |
308
ae5795ba5c77
Remove "only when song-length unknown" option from minimum playtime, it
Matti Hamalainen <ccr@tnsp.org>
parents:
300
diff
changeset
|
54 #define DEBUG_NP |
230 | 55 |
272 | 56 /* Define to enable non-portable thread and mutex debugging code. |
300 | 57 * You need to #define DEBUG also to make this useful. |
58 * (Works probably with GNU/Linux pthreads implementation only) | |
272 | 59 */ |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
60 #undef XS_MUTEX_DEBUG |
72
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
61 |
272 | 62 /* HardSID-support is not working and is untested, thus we disable it here. |
63 */ | |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
64 #undef HAVE_HARDSID_BUILDER |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
65 |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
66 /* Size for some small buffers (always static variables) */ |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
67 #define XS_BUF_SIZE (1024) |
1 | 68 |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
69 /* If defined, dynamically allocated temp. buffers are used. |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
70 * Static (#undef) are probably faster than allocating/deallocating |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
71 * from heap, but fails on systems with limited stack space. */ |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
72 #define XS_BUF_DYNAMIC |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
73 |
242 | 74 /* Size of audio buffer. If you are experiencing lots of audio |
75 * "underruns" or clicks/gaps in output, try increasing this value. | |
76 * Do notice, however, that it also affects the update frequency of | |
77 * XMMS's visualization plugins... | |
78 */ | |
79 #define XS_AUDIOBUF_SIZE (2*1024) | |
230 | 80 |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
81 /* Size of data buffer used for SID-tune MD5 hash calculation. |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
82 * If this is too small, the computed hash will be incorrect. |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
83 * Largest SID files I've seen are ~70kB. */ |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
84 #define XS_SIDBUF_SIZE (80*1024) |
230 | 85 |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
86 |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
87 |
334 | 88 #define XS_STIL_MAXENTRY (128) /* Max number of sub-songs in STIL/SLDB node */ |
230 | 89 |
90 | |
50
dae6d3c2268d
Minor fixes, updated to support default XMMS configfile
Matti Hamalainen <ccr@tnsp.org>
parents:
40
diff
changeset
|
91 #define XS_CONFIG_IDENT "XMMS-SID" /* Configuration file identifier */ |
62
0d1df20745dd
Started to rewrite STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
50
diff
changeset
|
92 #define XS_CONFIG_FILE "/.xmms/xmms-sid" /* Use this configfile if autocyrpe fails */ |
0d1df20745dd
Started to rewrite STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
50
diff
changeset
|
93 |
0d1df20745dd
Started to rewrite STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
50
diff
changeset
|
94 #define XS_MIN_OVERSAMPLE (2) /* Minimum oversampling factor */ |
0d1df20745dd
Started to rewrite STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
50
diff
changeset
|
95 #define XS_MAX_OVERSAMPLE (8) /* Maximum oversampling factor */ |
1 | 96 |
230 | 97 |
98 /* Macros for mutexes and threads. These exist to be able to | |
99 * easily change from pthreads to glib threads, etc, if necessary. | |
100 */ | |
101 #define XS_MPP(M) M ## _mutex | |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
102 #if XS_MUTEX_DEBUG |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
103 #define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; int M ## _qq; |
293
3fa910269508
Remove extra semicolon from macro definition, #undef DEBUG
Matti Hamalainen <ccr@tnsp.org>
parents:
278
diff
changeset
|
104 #define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M); extern int M ## _qq |
230 | 105 #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); } |
106 #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); } | |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
107 #else |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
108 #define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_MUTEX_INITIALIZER |
293
3fa910269508
Remove extra semicolon from macro definition, #undef DEBUG
Matti Hamalainen <ccr@tnsp.org>
parents:
278
diff
changeset
|
109 #define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M) |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
110 #define XS_MUTEX_LOCK(M) pthread_mutex_lock(&XS_MPP(M)) |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
111 #define XS_MUTEX_UNLOCK(M) pthread_mutex_unlock(&XS_MPP(M)) |
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
112 #endif |
230 | 113 |
114 /* Shorthands for linked lists | |
115 */ | |
116 #define LPREV (pNode->pPrev) | |
117 #define LTHIS (pNode) | |
118 #define LNEXT (pNode->pNext) | |
62
0d1df20745dd
Started to rewrite STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
50
diff
changeset
|
119 |
72
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
120 |
230 | 121 /* Plugin-wide typedefs |
122 */ | |
72
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
123 typedef struct { |
78
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
124 gint tuneSpeed; |
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
125 gint tuneLength; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
126 gchar *tuneTitle; |
230 | 127 } t_xs_subtuneinfo; |
78
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
128 |
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
129 |
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
130 typedef struct { |
230 | 131 gchar *sidFilename, |
132 *sidName, | |
133 *sidComposer, | |
134 *sidCopyright; | |
135 gint loadAddr, | |
136 initAddr, | |
137 playAddr, | |
138 dataFileLen; | |
139 gint nsubTunes, startTune; | |
334 | 140 t_xs_subtuneinfo *subTunes; |
230 | 141 } t_xs_tuneinfo; |
142 | |
143 | |
144 struct t_xs_status; | |
145 | |
146 typedef struct { | |
147 gint plrIdent; | |
148 gboolean (*plrIsOurFile)(gchar *); | |
149 gboolean (*plrInit)(struct t_xs_status *); | |
150 void (*plrClose)(struct t_xs_status *); | |
151 gboolean (*plrInitSong)(struct t_xs_status *); | |
152 guint (*plrFillBuffer)(struct t_xs_status *, gchar *, guint); | |
153 gboolean (*plrLoadSID)(struct t_xs_status *, gchar *); | |
154 void (*plrDeleteSID)(struct t_xs_status *); | |
155 t_xs_tuneinfo* (*plrGetSIDInfo)(gchar *); | |
156 } t_xs_player; | |
157 | |
158 | |
159 typedef struct t_xs_status { | |
160 gint audioFrequency, /* Audio settings */ | |
127
ddb513bd2610
Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
161 audioChannels, |
269 | 162 audioBitsPerSample, |
163 oversampleFactor; /* Factor of oversampling */ | |
295 | 164 AFormat audioFormat; |
269 | 165 gboolean oversampleEnable; /* TRUE after sidEngine initialization, |
166 if xs_cfg.oversampleEnable == TRUE and | |
167 emulation backend supports oversampling. | |
168 */ | |
230 | 169 void *sidEngine; /* SID-emulation internal engine data */ |
170 t_xs_player *sidPlayer; /* Selected player engine */ | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
171 gboolean isError, isPlaying; |
230 | 172 gint currSong, /* Current sub-tune */ |
132
4162a5370b9e
Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
173 lastTime; |
230 | 174 t_xs_tuneinfo *tuneInfo; |
72
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
175 } t_xs_status; |
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
176 |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
177 |
230 | 178 /* Global variables |
179 */ | |
180 extern InputPlugin xs_plugin_ip; | |
181 | |
182 extern t_xs_status xs_status; | |
183 XS_MUTEX_H(xs_status); | |
1 | 184 |
185 | |
230 | 186 |
187 /* Plugin function prototypes | |
1 | 188 */ |
189 void xs_init(void); | |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
190 void xs_reinit(void); |
3 | 191 void xs_close(void); |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
192 gint xs_is_our_file(gchar *); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
193 void xs_play_file(gchar *); |
1 | 194 void xs_stop(void); |
195 void xs_pause(short); | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
196 void xs_seek(gint); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
197 gint xs_get_time(void); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
62
diff
changeset
|
198 void xs_get_song_info(gchar *, gchar **, gint *); |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
199 void xs_about(void); |
1 | 200 |
230 | 201 t_xs_tuneinfo *xs_tuneinfo_new(gchar *, gint, gint, gchar *, gchar *, gchar *, gint, gint, gint, gint); |
202 void xs_tuneinfo_free(t_xs_tuneinfo *); | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
78
diff
changeset
|
203 |
300 | 204 void XSERR(const char *, ...); |
1 | 205 |
300 | 206 #ifndef DEBUG_NP |
207 void XSDEBUG(const char *, ...); | |
208 #else | |
1 | 209 #ifdef DEBUG |
297 | 210 #define XSDEBUG(...) { fprintf(stderr, "XS[%s:%s:%d]: ", __FILE__, __FUNCTION__, (int) __LINE__); fprintf(stderr, __VA_ARGS__); } |
1 | 211 #else |
300 | 212 #define XSDEBUG(...) /* stub */ |
1 | 213 #endif |
300 | 214 #endif |
1 | 215 |
216 #ifdef __cplusplus | |
217 } | |
218 #endif | |
92
2607683bc9eb
Improvements in length- and title handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
219 #endif /* _XMMS_SID_H */ |