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