Mercurial > hg > xmms-sid
annotate src/xmms-sid.h @ 810:0c2f8ee6be42
Make debug output compile-time configurable via --enable-debug. Disabled by
default.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 07 Nov 2012 12:52:46 +0200 |
parents | f2e023bf718f |
children | cbba4cf52ff9 |
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> |
723 | 7 (C) Copyright 1999-2009 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 | |
412
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
19 You should have received a copy of the GNU General Public License along |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
20 with this program; if not, write to the Free Software Foundation, Inc., |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
402
diff
changeset
|
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
1 | 22 */ |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
524
diff
changeset
|
23 #ifndef XMMS_SID_H |
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
524
diff
changeset
|
24 #define XMMS_SID_H |
1 | 25 |
465
ba98fdac6307
Moved some things to xs_support.h; t_xs_subtuneinfo.tuneSpeed is now the
Matti Hamalainen <ccr@tnsp.org>
parents:
459
diff
changeset
|
26 #include "xs_support.h" |
1 | 27 |
230 | 28 #ifdef __cplusplus |
29 extern "C" { | |
30 #endif | |
31 | |
300 | 32 /* Define to ISO C99 macro for debugging instead of varargs function. |
365
5a92a2aee74c
Better comments and .. you guessed it: more indentation fixes. :)
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
33 * This provides more useful information, but is incompatible with |
5a92a2aee74c
Better comments and .. you guessed it: more indentation fixes. :)
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
34 * older standards. If #undef'd, a varargs function is used instead. |
300 | 35 */ |
308
ae5795ba5c77
Remove "only when song-length unknown" option from minimum playtime, it
Matti Hamalainen <ccr@tnsp.org>
parents:
300
diff
changeset
|
36 #define DEBUG_NP |
230 | 37 |
272 | 38 /* Define to enable non-portable thread and mutex debugging code. |
300 | 39 * You need to #define DEBUG also to make this useful. |
40 * (Works probably with GNU/Linux pthreads implementation only) | |
272 | 41 */ |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
42 #undef XS_MUTEX_DEBUG |
72
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
43 |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
44 /* Size for some small buffers (always static variables) */ |
777
15f0c8e11338
Increase line buffer size in songlength database reader. Fixes problems with
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
45 #define XS_BUF_SIZE (512) |
15f0c8e11338
Increase line buffer size in songlength database reader. Fixes problems with
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
46 |
15f0c8e11338
Increase line buffer size in songlength database reader. Fixes problems with
Matti Hamalainen <ccr@tnsp.org>
parents:
752
diff
changeset
|
47 #define XS_BUF2_SIZE (4096) |
1 | 48 |
355
26079ab52fc3
Comment about XS_DYNAMIC_BUF changed
Matti Hamalainen <ccr@tnsp.org>
parents:
334
diff
changeset
|
49 /* If defined, some dynamically allocated temp. buffers are used. |
26079ab52fc3
Comment about XS_DYNAMIC_BUF changed
Matti Hamalainen <ccr@tnsp.org>
parents:
334
diff
changeset
|
50 * Static (#undef) might give slight performance gain, |
26079ab52fc3
Comment about XS_DYNAMIC_BUF changed
Matti Hamalainen <ccr@tnsp.org>
parents:
334
diff
changeset
|
51 * but fails on systems with limited stack space. */ |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
52 #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
|
53 |
546
70fe31fe2bf5
Reordering cleanup and added constant for SIDPlay2 max # of filter coeffs.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
54 /* Configuration section identifier |
70fe31fe2bf5
Reordering cleanup and added constant for SIDPlay2 max # of filter coeffs.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
55 */ |
752 | 56 #define XS_PACKAGE_STRING PACKAGE_STRING |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
57 #define XS_CONFIG_IDENT "XMMS-SID" |
546
70fe31fe2bf5
Reordering cleanup and added constant for SIDPlay2 max # of filter coeffs.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
58 |
486
4c599be2d349
Default audio rendering frequency #define.
Matti Hamalainen <ccr@tnsp.org>
parents:
478
diff
changeset
|
59 /* Default audio rendering frequency in Hz |
4c599be2d349
Default audio rendering frequency #define.
Matti Hamalainen <ccr@tnsp.org>
parents:
478
diff
changeset
|
60 */ |
752 | 61 #define XS_AUDIO_FREQ (44100) |
486
4c599be2d349
Default audio rendering frequency #define.
Matti Hamalainen <ccr@tnsp.org>
parents:
478
diff
changeset
|
62 |
242 | 63 /* Size of audio buffer. If you are experiencing lots of audio |
64 * "underruns" or clicks/gaps in output, try increasing this value. | |
65 * Do notice, however, that it also affects the update frequency of | |
66 * XMMS's visualization plugins... | |
67 */ | |
752 | 68 #define XS_AUDIOBUF_SIZE (2*1024) |
230 | 69 |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
70 /* 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
|
71 * 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
|
72 * Largest SID files I've seen are ~70kB. */ |
752 | 73 #define XS_SIDBUF_SIZE (80*1024) |
230 | 74 |
546
70fe31fe2bf5
Reordering cleanup and added constant for SIDPlay2 max # of filter coeffs.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
75 /* libSIDPlay1/2 constants (copied from internal headers/source) |
70fe31fe2bf5
Reordering cleanup and added constant for SIDPlay2 max # of filter coeffs.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
76 * For some stupid reason these are not available in public |
70fe31fe2bf5
Reordering cleanup and added constant for SIDPlay2 max # of filter coeffs.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
77 * headers, so we have to duplicate them here... |
70fe31fe2bf5
Reordering cleanup and added constant for SIDPlay2 max # of filter coeffs.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
78 */ |
752 | 79 #define XS_SIDPLAY1_FS (400.0f) |
80 #define XS_SIDPLAY1_FM (60.0f) | |
81 #define XS_SIDPLAY1_FT (0.05f) | |
376
b20300813b42
Moved some #defines from xs_config.c to xmms-sid.h; Changed default SID
Matti Hamalainen <ccr@tnsp.org>
parents:
369
diff
changeset
|
82 |
752 | 83 #define XS_SIDPLAY2_NFPOINTS (0x800) |
84 #define XS_SIDPLAY2_FMAX (24000) | |
62
0d1df20745dd
Started to rewrite STIL-support
Matti Hamalainen <ccr@tnsp.org>
parents:
50
diff
changeset
|
85 |
230 | 86 |
87 /* Macros for mutexes and threads. These exist to be able to | |
88 * easily change from pthreads to glib threads, etc, if necessary. | |
89 */ | |
752 | 90 #define XS_THREAD_T pthread_t |
91 #define XS_THREAD_EXIT(M) pthread_exit(M) | |
92 #define XS_THREAD_JOIN(M) pthread_join(M, NULL) | |
93 #define XS_MPP(M) M ## _mutex | |
640
91056492b156
Fix XS_MUTEX_DEBUG to work again.
Matti Hamalainen <ccr@tnsp.org>
parents:
632
diff
changeset
|
94 #ifdef XS_MUTEX_DEBUG |
91056492b156
Fix XS_MUTEX_DEBUG to work again.
Matti Hamalainen <ccr@tnsp.org>
parents:
632
diff
changeset
|
95 # ifndef __USE_GNU |
91056492b156
Fix XS_MUTEX_DEBUG to work again.
Matti Hamalainen <ccr@tnsp.org>
parents:
632
diff
changeset
|
96 # define __USE_GNU |
91056492b156
Fix XS_MUTEX_DEBUG to work again.
Matti Hamalainen <ccr@tnsp.org>
parents:
632
diff
changeset
|
97 # endif |
752 | 98 # define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; gint M ## _qq |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
99 # define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M); extern gint M ## _qq |
752 | 100 # 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); } |
101 # 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
|
102 #else |
752 | 103 # define XS_MUTEX(M) pthread_mutex_t XS_MPP(M) = PTHREAD_MUTEX_INITIALIZER |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
104 # define XS_MUTEX_H(M) extern pthread_mutex_t XS_MPP(M) |
752 | 105 # define XS_MUTEX_LOCK(M) pthread_mutex_lock(&XS_MPP(M)) |
106 # define XS_MUTEX_UNLOCK(M) pthread_mutex_unlock(&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
|
107 #endif |
640
91056492b156
Fix XS_MUTEX_DEBUG to work again.
Matti Hamalainen <ccr@tnsp.org>
parents:
632
diff
changeset
|
108 #include <pthread.h> |
230 | 109 |
622
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
619
diff
changeset
|
110 /* Character set conversion helper macros |
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
619
diff
changeset
|
111 */ |
752 | 112 #define XS_CS_FILENAME(M) g_strdup(M) |
113 #define XS_CS_SID(M) g_strdup(M) | |
114 #define XS_CS_STIL(M) M | |
622
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
619
diff
changeset
|
115 #define XS_CS_FREE(M) |
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
619
diff
changeset
|
116 |
72
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
117 |
230 | 118 /* Plugin-wide typedefs |
119 */ | |
72
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
65
diff
changeset
|
120 typedef struct { |
752 | 121 gint tuneSpeed, |
122 tuneLength; | |
123 gboolean tunePlayed; | |
751 | 124 } XSSubTuneInfo; |
78
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
125 |
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
126 |
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
127 typedef struct { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
128 gchar *sidFilename, |
752 | 129 *sidName, |
130 *sidComposer, | |
131 *sidCopyright, | |
132 *sidFormat; | |
133 gint loadAddr, | |
134 initAddr, | |
135 playAddr, | |
136 dataFileLen, | |
137 sidModel; | |
138 gint nsubTunes, startTune; | |
751 | 139 XSSubTuneInfo *subTunes; |
140 } XSTuneInfo; | |
230 | 141 |
142 | |
143 /* Global variables | |
144 */ | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
145 extern InputPlugin xs_plugin_ip; |
230 | 146 |
147 | |
148 /* Plugin function prototypes | |
1 | 149 */ |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
150 void xs_init(void); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
151 void xs_reinit(void); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
152 void xs_close(void); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
153 gint xs_is_our_file(gchar *); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
154 void xs_play_file(gchar *); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
155 void xs_stop(void); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
156 void xs_pause(short); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
157 void xs_seek(gint); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
158 gint xs_get_time(void); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
159 void xs_get_song_info(gchar *, gchar **, gint *); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
160 void xs_about(void); |
1 | 161 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
162 void xs_error(const char *, ...); |
1 | 163 |
427
2ea3005a4b7f
Conditional #definition of _()
Matti Hamalainen <ccr@tnsp.org>
parents:
424
diff
changeset
|
164 |
2ea3005a4b7f
Conditional #definition of _()
Matti Hamalainen <ccr@tnsp.org>
parents:
424
diff
changeset
|
165 /* Debugging |
2ea3005a4b7f
Conditional #definition of _()
Matti Hamalainen <ccr@tnsp.org>
parents:
424
diff
changeset
|
166 */ |
300 | 167 #ifndef DEBUG_NP |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
168 void XSDEBUG(const char *, ...); |
300 | 169 #else |
532 | 170 # ifdef DEBUG |
171 # define XSDEBUG(...) { fprintf(stderr, "XS[%s:%s:%d]: ", __FILE__, __FUNCTION__, (int) __LINE__); fprintf(stderr, __VA_ARGS__); } | |
172 # else | |
173 # define XSDEBUG(...) /* stub */ | |
174 # endif | |
300 | 175 #endif |
1 | 176 |
612
32fc27395220
About window wasn't handling delete_event properly, fixed; Cleaned up event handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
177 |
32fc27395220
About window wasn't handling delete_event properly, fixed; Cleaned up event handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
178 /* And even some Gtk+ macro crap here, yay. |
32fc27395220
About window wasn't handling delete_event properly, fixed; Cleaned up event handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
179 */ |
752 | 180 #define XS_DEF_WINDOW_DELETE(ME, MV) \ |
181 gboolean xs_ ## ME ## _delete(GtkWidget *w, GdkEvent *e, gpointer d) { \ | |
182 (void) w; (void) e; (void) d; \ | |
183 if (xs_ ## MV ) { \ | |
184 gtk_widget_destroy(xs_ ## MV ); \ | |
185 xs_ ## MV = NULL; \ | |
186 } \ | |
187 return FALSE; \ | |
612
32fc27395220
About window wasn't handling delete_event properly, fixed; Cleaned up event handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
188 } |
32fc27395220
About window wasn't handling delete_event properly, fixed; Cleaned up event handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
189 |
752 | 190 #define XS_DEF_WINDOW_CLOSE(ME, MV) \ |
191 void xs_ ## ME (GtkButton *b, gpointer d) { \ | |
192 (void) b; (void) d; \ | |
193 gtk_widget_destroy(xs_ ## MV ); \ | |
194 xs_ ## MV = NULL; \ | |
612
32fc27395220
About window wasn't handling delete_event properly, fixed; Cleaned up event handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
195 } |
32fc27395220
About window wasn't handling delete_event properly, fixed; Cleaned up event handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
196 |
752 | 197 #define XS_SIGNAL_CONNECT(SOBJ, SNAME, SFUNC, SDATA) \ |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
657
diff
changeset
|
198 gtk_signal_connect(GTK_OBJECT(SOBJ), SNAME, GTK_SIGNAL_FUNC(SFUNC), SDATA) |
612
32fc27395220
About window wasn't handling delete_event properly, fixed; Cleaned up event handling a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
610
diff
changeset
|
199 |
665
94186706beed
Use macro wrapping for Gtk+ v1 vs v2 differences, yet again.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
200 #define XS_WINDOW_PRESENT(SWIN) gdk_window_raise(SWIN ->window) |
94186706beed
Use macro wrapping for Gtk+ v1 vs v2 differences, yet again.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
201 |
1 | 202 #ifdef __cplusplus |
203 } | |
204 #endif | |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
524
diff
changeset
|
205 #endif /* XMMS_SID_H */ |