Mercurial > hg > xmms-sid
annotate src/xmms-sid.cc @ 49:3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 21 Jun 2003 20:51:01 +0000 |
parents | 84214a409d19 |
children | 6a3ce7260ae1 |
rev | line source |
---|---|
1 | 1 /* |
5 | 2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
1 | 3 |
4 Main source file | |
5 | |
5 | 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 */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
22 extern "C" { |
28 | 23 #include <pthread.h> |
24 #include <stdlib.h> | |
25 #include <string.h> | |
26 #include <stdio.h> | |
27 #include <errno.h> | |
28 #include <xmms/plugin.h> | |
29 #include <xmms/util.h> | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
30 #include <xmms/titlestring.h> |
1 | 31 #include "xmms-sid.h" |
42 | 32 #include "xs_interface.h" |
33 #include "xs_glade.h" | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
34 #include "xs_support.h" |
22 | 35 #include "xs_config.h" |
36 #include "xs_length.h" | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
37 } |
28 | 38 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
39 #ifdef HAVE_SIDPLAY1 |
1 | 40 #include <sidplay/player.h> |
41 #include <sidplay/myendian.h> | |
42 #include <sidplay/fformat.h> | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
43 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
44 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
45 #ifdef HAVE_SIDPLAY2 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
46 #include <sidplay/sidplay2.h> |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
47 #endif |
1 | 48 |
49 | |
50 /* | |
28 | 51 * Global variables |
1 | 52 */ |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
53 #ifdef HAVE_SIDPLAY1 |
1 | 54 static struct emuConfig xs_emuConf; |
55 static emuEngine xs_emuEngine; | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
56 typedef sidTune t_xs_tune; |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
57 typedef struct sidTuneInfo t_xs_tuneinfo; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
58 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
59 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
60 #ifdef HAVE_SIDPLAY2 |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
61 static struct sid2_config_t xs_emuConf; |
42 | 62 static sidplay2 xs_emuEngine; |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
63 typedef SidTune t_xs_tune; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
64 typedef struct SidTuneInfo t_xs_tuneinfo; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
65 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
66 |
42 | 67 static GtkWidget *xs_ctrlwin = NULL; |
1 | 68 static pthread_t xs_decode_thread; |
5 | 69 struct t_xs_cfg xs_cfg; |
70 | |
71 struct { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
72 gboolean isError, isPlaying, allowNext; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
73 gint currSong, nSongs; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
74 t_xs_tune *currTune; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
75 gchar *currFilename; |
5 | 76 } xs_status; |
77 | |
78 pthread_mutex_t xs_mutex = PTHREAD_MUTEX_INITIALIZER; | |
1 | 79 |
42 | 80 /* |
81 * Create sub-song control window | |
82 */ | |
83 void xs_ctrlwin_open(void) | |
84 { | |
85 /* Create sub-song control window */ | |
86 if (xs_ctrlwin != NULL) | |
87 { | |
88 gdk_window_raise(xs_ctrlwin->window); | |
89 return; | |
90 } | |
91 | |
92 xs_ctrlwin = create_xs_ctrlwin(); | |
93 gtk_widget_show(xs_ctrlwin); | |
94 } | |
95 | |
1 | 96 |
97 /* | |
5 | 98 * Initialize XMMS-SID |
1 | 99 */ |
100 void xs_init(void) | |
101 { | |
5 | 102 XSDEBUG("xs_init()\n"); |
1 | 103 |
28 | 104 /* Initialize and get configuration */ |
105 memset(&xs_cfg, 0, sizeof(xs_cfg)); | |
106 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
107 xs_read_configuration(); |
28 | 108 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
109 xs_status.isError = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
110 xs_status.isPlaying = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
111 xs_status.nSongs = 0; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
112 xs_status.currSong = 0; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
113 xs_status.allowNext = TRUE; // Initialize to TRUE to allow first song |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
114 xs_status.currTune = NULL; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
115 xs_status.currFilename = NULL; |
28 | 116 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
117 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
118 /* Try to initialize libSIDPlay(s) */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
119 #ifdef HAVE_SIDPLAY1 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
120 if (!xs_emuEngine || !xs_emuEngine.verifyEndianess()) |
5 | 121 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
122 XSERR("Couldn't start SIDPlay1 emulator engine!\n"); |
5 | 123 return; |
1 | 124 } |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
125 #endif |
1 | 126 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
127 #ifdef HAVE_SIDPLAY2 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
128 #endif |
1 | 129 |
22 | 130 /* Read song-length database */ |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
131 if (xs_cfg.songlenDBEnable) |
22 | 132 if (xs_songlen_init() < 0) |
133 { | |
134 XSERR("Error initializing song-length database!\n"); | |
135 } | |
5 | 136 |
137 /* Initialize STIL structures */ | |
42 | 138 |
139 xs_ctrlwin_open(); | |
140 | |
5 | 141 // FIXME FIXME FIx ME |
1 | 142 |
143 } | |
144 | |
145 | |
146 /* | |
5 | 147 * Shut down XMMS-SID |
148 */ | |
149 void xs_close(void) | |
1 | 150 { |
5 | 151 XSDEBUG("shutting down...\n"); |
1 | 152 |
5 | 153 /* Stop playing */ |
22 | 154 xs_plugin_ip.stop(); |
1 | 155 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
156 /* Shutdown libSIDPlay(s) */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
157 #ifdef HAVE_SIDPLAY1 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
158 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
159 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
160 #ifdef HAVE_SIDPLAY2 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
161 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
162 |
28 | 163 /* Close sub-song control window */ |
164 | |
5 | 165 /* Free allocated memory */ |
22 | 166 xs_songlen_close(); |
1 | 167 |
28 | 168 // FIXME FIXME: STIL-entries |
1 | 169 } |
170 | |
171 | |
172 /* | |
28 | 173 * Check whether the given file is handled by this plugin |
1 | 174 */ |
5 | 175 gint xs_is_our_file(char *fileName) |
1 | 176 { |
5 | 177 char *pcExt; |
178 | |
179 /* Check the filename */ | |
180 if (fileName == NULL) | |
181 return FALSE; | |
182 | |
183 /* Try to detect via libSIDPlay's detection routine, if required */ | |
28 | 184 if (xs_cfg.detectMagic) |
185 { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
186 #ifdef HAVE_SIDPLAY1 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
187 t_xs_tune *testTune = new sidTune(fileName); |
5 | 188 if (!testTune) return FALSE; |
189 if (!testTune->getStatus()) | |
190 { | |
191 delete testTune; | |
192 return FALSE; | |
193 } | |
194 | |
195 delete testTune; | |
196 return TRUE; | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
197 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
198 #ifdef HAVE_SIDPLAY2 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
199 #endif |
1 | 200 } |
201 | |
5 | 202 /* Detect just by checking filename extension */ |
203 pcExt = strrchr(fileName, '.'); | |
204 if (pcExt) | |
205 { | |
206 pcExt++; | |
207 if (!strcasecmp(pcExt, "psid")) return TRUE; | |
208 if (!strcasecmp(pcExt, "sid")) return TRUE; | |
209 if (!strcasecmp(pcExt, "dat")) return TRUE; | |
210 if (!strcasecmp(pcExt, "inf")) return TRUE; | |
211 if (!strcasecmp(pcExt, "info")) return TRUE; | |
1 | 212 } |
5 | 213 |
214 return FALSE; | |
1 | 215 } |
216 | |
217 | |
218 /* | |
28 | 219 * Main playing thread loop |
1 | 220 */ |
5 | 221 static void *xs_play_loop(void *argPointer) |
1 | 222 { |
5 | 223 /* Don't allow next song to be set yet */ |
224 pthread_mutex_lock(&xs_mutex); | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
225 xs_status.allowNext = FALSE; |
5 | 226 pthread_mutex_unlock(&xs_mutex); |
227 | |
228 | |
49
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
229 /* Exit the playing thread */ |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
230 XSDEBUG("exiting thread, bye.\n"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
231 return NULL; |
1 | 232 } |
233 | |
234 | |
235 /* | |
28 | 236 * Start playing the given file |
1 | 237 */ |
5 | 238 void xs_play_file(char *fileName) |
1 | 239 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
240 t_xs_tune *newTune; |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
241 t_xs_tuneinfo sidInf; |
5 | 242 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
243 XSDEBUG("request to load '%s'\n", fileName); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
244 |
5 | 245 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
246 /* Initialize audio output */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
247 XSDEBUG("opening audio output plugin...\n"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
248 if (!xs_plugin_ip.output->open_audio( |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
249 ((xs_cfg.fmtBitsPerSample == 16) ? FMT_S16_NE : FMT_U8), xs_cfg.fmtFrequency, |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
250 ((xs_cfg.fmtChannels == XS_CHN_MONO) ? 1 : 2))) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
251 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
252 XSERR("Couldn't open audio output plugin!\n"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
253 delete newTune; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
254 return; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
255 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
256 |
1 | 257 |
5 | 258 /* Try to get the tune */ |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
259 newTune = new t_xs_tune(fileName); |
5 | 260 if (newTune == NULL) return; |
261 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
262 XSDEBUG("tune ok, configuring SIDPlay engine\n"); |
1 | 263 |
28 | 264 |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
265 #ifdef HAVE_SIDPLAY1 |
5 | 266 /* Get current configuration */ |
267 xs_emuEngine.getConfig(xs_emuConf); | |
268 | |
269 /* Configure channels and stuff */ | |
270 switch (xs_cfg.fmtChannels) { | |
1 | 271 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
272 case XS_CHN_AUTOPAN: |
1 | 273 xs_emuConf.channels = SIDEMU_STEREO; |
274 xs_emuConf.autoPanning = SIDEMU_CENTEREDAUTOPANNING; | |
275 xs_emuConf.volumeControl = SIDEMU_FULLPANNING; | |
276 break; | |
277 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
278 case XS_CHN_STEREO: |
1 | 279 xs_emuConf.channels = SIDEMU_STEREO; |
280 xs_emuConf.autoPanning = SIDEMU_NONE; | |
281 xs_emuConf.volumeControl = SIDEMU_NONE; | |
282 break; | |
283 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
284 case XS_CHN_MONO: |
1 | 285 xs_emuConf.channels = SIDEMU_MONO; |
286 xs_emuConf.autoPanning = SIDEMU_NONE; | |
287 xs_emuConf.volumeControl = SIDEMU_NONE; | |
288 break; | |
289 | |
5 | 290 default: |
291 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n"); | |
292 delete newTune; | |
293 return; | |
294 } | |
1 | 295 |
28 | 296 |
5 | 297 /* Memory mode settings */ |
298 switch (xs_cfg.memoryMode) { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
299 case XS_MPU_BANK_SWITCHING: |
1 | 300 xs_emuConf.memoryMode = MPU_BANK_SWITCHING; |
301 break; | |
302 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
303 case XS_MPU_TRANSPARENT_ROM: |
1 | 304 xs_emuConf.memoryMode = MPU_TRANSPARENT_ROM; |
305 break; | |
306 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
307 case XS_MPU_PLAYSID_ENVIRONMENT: |
1 | 308 xs_emuConf.memoryMode = MPU_PLAYSID_ENVIRONMENT; |
309 break; | |
310 | |
5 | 311 default: |
312 XSERR("Internal: Invalid memoryMode setting. Possibly corrupted configuration file.\n"); | |
313 delete newTune; | |
314 return; | |
315 } | |
1 | 316 |
317 | |
5 | 318 /* Clockspeed settings */ |
319 switch (xs_cfg.clockSpeed) { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
320 case XS_CLOCK_PAL: |
1 | 321 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_PAL; |
322 break; | |
323 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
324 case XS_CLOCK_NTSC: |
1 | 325 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_NTSC; |
326 break; | |
327 | |
5 | 328 default: |
329 XSERR("Internal: Invalid clockSpeed setting. Possibly corrupted configuration file.\n"); | |
330 delete newTune; | |
331 return; | |
332 } | |
333 | |
334 | |
335 /* Configure rest of the emulation */ | |
28 | 336 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample; |
337 xs_emuConf.frequency = xs_cfg.fmtFrequency; | |
49
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
338 #ifdef HAVE_UNSIGNEDPCM |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
339 xs_emuConf.sampleFormat = SIDEMU_UNSIGNED_PCM; |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
340 #else |
28 | 341 xs_emuConf.sampleFormat = SIDEMU_SIGNED_PCM; |
49
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
342 #endif |
28 | 343 xs_emuConf.mos8580 = xs_cfg.mos8580; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
344 xs_emuConf.emulateFilter = xs_cfg.emulateFilters; |
28 | 345 xs_emuConf.filterFs = xs_cfg.filterFs; |
346 xs_emuConf.filterFm = xs_cfg.filterFm; | |
347 xs_emuConf.filterFt = xs_cfg.filterFt; | |
5 | 348 |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
349 /* Now set the emulator configuration */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
350 xs_emuEngine.setConfig(xs_emuConf); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
351 #endif |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
352 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
353 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
354 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
355 #ifdef HAVE_SIDPLAY2 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
356 /* Get current configuration */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
357 xs_emuConf = xs_emuEngine.config(); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
358 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
359 /* Configure channels and stuff */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
360 switch (xs_cfg.fmtChannels) { |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
361 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
362 case XS_CHN_AUTOPAN: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
363 xs_emuConf.playback = sid2_stereo; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
364 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
365 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
366 case XS_CHN_STEREO: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
367 xs_emuConf.playback = sid2_stereo; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
368 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
369 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
370 case XS_CHN_MONO: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
371 xs_emuConf.playback = sid2_mono; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
372 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
373 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
374 default: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
375 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n"); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
376 delete newTune; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
377 return; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
378 } |
5 | 379 |
28 | 380 |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
381 /* Memory mode settings */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
382 switch (xs_cfg.memoryMode) { |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
383 case XS_MPU_BANK_SWITCHING: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
384 xs_emuConf.environment = sid2_envBS; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
385 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
386 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
387 case XS_MPU_TRANSPARENT_ROM: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
388 xs_emuConf.environment = sid2_envTP; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
389 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
390 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
391 case XS_MPU_PLAYSID_ENVIRONMENT: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
392 xs_emuConf.environment = sid2_envPS; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
393 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
394 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
395 case XS_MPU_REAL: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
396 xs_emuConf.environment = sid2_envR; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
397 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
398 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
399 default: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
400 XSERR("Internal: Invalid memoryMode setting. Possibly corrupted configuration file.\n"); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
401 delete newTune; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
402 return; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
403 } |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
404 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
405 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
406 /* Clockspeed settings */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
407 switch (xs_cfg.clockSpeed) { |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
408 case XS_CLOCK_PAL: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
409 xs_emuConf.clockSpeed = xs_emuConf.clockDefault = SID2_CLOCK_PAL; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
410 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
411 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
412 case XS_CLOCK_NTSC: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
413 xs_emuConf.clockSpeed = xs_emuConf.clockDefault = SID2_CLOCK_NTSC; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
414 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
415 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
416 default: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
417 XSERR("Internal: Invalid clockSpeed setting. Possibly corrupted configuration file.\n"); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
418 delete newTune; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
419 return; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
420 } |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
421 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
422 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
423 /* Configure rest of the emulation */ |
45 | 424 xs_emuConf.precision = xs_cfg.fmtBitsPerSample; |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
425 xs_emuConf.frequency = xs_cfg.fmtFrequency; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
426 xs_emuConf.clockForced = xs_cfg.forceSpeed; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
427 xs_emuConf.optimisation = xs_cfg.optimiseLevel; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
428 xs_emuConf.sidModel = (xs_cfg.mos8580) ? SID2_MOS8580 : SID2_MOS6581; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
429 xs_emuConf.sidDefault = SID2_MOS6581; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
430 xs_emuConf.sidSamples = emulation.sidSamples; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
431 |
49
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
432 #ifdef HAVE_UNSIGNEDPCM |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
433 #ifdef WORDS_BIGENDIAN |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
434 xs_emuConf.sampleFormat = SID2_BIG_UNSIGNED; |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
435 #else |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
436 xs_emuConf.sampleFormat = SID2_LITTLE_UNSIGNED; |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
437 #endif |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
438 #else |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
439 #ifdef WORDS_BIGENDIAN |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
440 xs_emuConf.sampleFormat = SID2_BIG_SIGNED; |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
441 #else |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
442 xs_emuConf.sampleFormat = SID2_LITTLE_SIGNED; |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
443 #endif |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
444 #endif |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
445 |
5 | 446 /* Now set the emulator configuration */ |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
447 xs_emuEngine.config(xs_emuConf); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
448 #endif |
5 | 449 |
28 | 450 |
451 /* Initialize status information */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
452 XSDEBUG("initializing and starting playing thread!\n"); |
28 | 453 |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
454 newTune->getInfo(sidInf); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
455 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
456 xs_status.isError = FALSE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
457 xs_status.isPlaying = TRUE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
458 xs_status.allowNext = TRUE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
459 xs_status.currSong = sidInf.startSong; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
460 xs_status.nSongs = sidInf.songs; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
461 xs_status.currTune = newTune; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
462 |
5 | 463 |
464 /* Start the playing thread! */ | |
465 if (pthread_create(&xs_decode_thread, NULL, xs_play_loop, NULL) < 0) | |
466 { | |
467 XSERR("Couldn't start playing thread! Possible reason reported by system: %s\n", strerror(errno)); | |
468 delete newTune; | |
1 | 469 } |
470 | |
5 | 471 /* Exit */ |
1 | 472 } |
473 | |
474 | |
475 /* | |
5 | 476 * Stop playing |
1 | 477 */ |
478 void xs_stop(void) | |
479 { | |
5 | 480 /* If playing, stop. */ |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
481 XSDEBUG("request to stop.\n"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
482 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
483 if (xs_status.isPlaying) |
1 | 484 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
485 XSDEBUG("stopping...\n"); |
5 | 486 pthread_mutex_lock(&xs_mutex); |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
487 xs_status.isPlaying = 0; |
5 | 488 pthread_mutex_unlock(&xs_mutex); |
489 | |
490 pthread_join(xs_decode_thread, NULL); | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
491 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
492 xs_plugin_ip.output->close_audio(); |
1 | 493 } |
494 } | |
495 | |
496 | |
497 /* | |
5 | 498 * Pause the playing |
1 | 499 */ |
5 | 500 void xs_pause(short pauseState) |
1 | 501 { |
24 | 502 xs_plugin_ip.output->pause(pauseState); |
1 | 503 } |
504 | |
505 | |
506 /* | |
5 | 507 * Set the time-seek position |
508 * (the playing thread will do the "seeking" aka song-change) | |
1 | 509 */ |
5 | 510 void xs_seek(int iTime) |
1 | 511 { |
5 | 512 #ifdef HAVE_SONG_POSITION |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
513 pthread_mutex_lock(&xs_mutex); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
514 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
515 if ((iTime > 0) && (iTime <= xs_status.nSongs) && xs_status.isPlaying) |
5 | 516 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
517 xs_status.currSong = iTime; |
1 | 518 } |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
519 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
520 pthread_mutex_unlock(&xs_mutex); |
5 | 521 #endif |
1 | 522 } |
523 | |
524 | |
525 /* | |
5 | 526 * Return the playing "position/time" |
1 | 527 */ |
528 int xs_get_time(void) | |
529 { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
530 pthread_mutex_lock(&xs_mutex); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
531 if (xs_status.isError) |
5 | 532 return -2; |
533 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
534 if (!xs_status.isPlaying) |
5 | 535 return -1; |
1 | 536 |
5 | 537 #ifdef HAVE_SONG_POSITION |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
538 set_song_position(xs_status.currSong, 1, xs_status.nSongs); |
5 | 539 #endif |
1 | 540 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
541 pthread_mutex_unlock(&xs_mutex); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
542 |
24 | 543 return xs_plugin_ip.output->output_time(); |
1 | 544 } |
545 | |
546 | |
5 | 547 /* |
548 * Return song information | |
549 */ | |
550 void xs_get_song_info(char *songFilename, char **songTitle, int *songLength) | |
551 { | |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
552 t_xs_tuneinfo sidInf; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
553 t_xs_tune *testTune = new sidTune(songFilename); |
5 | 554 |
555 /* Check if the tune exists and is readable */ | |
556 if (!testTune) return; | |
557 if (!testTune->getStatus()) | |
558 { | |
559 delete testTune; | |
560 return; | |
561 } | |
562 | |
563 /* Get general tune information */ | |
564 testTune->getInfo(sidInf); | |
565 delete testTune; | |
566 | |
567 /* Get titlestring */ | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
568 *songTitle = NULL; |
5 | 569 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
570 /* Get song length (in milliseconds), negative if no known length */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
571 *songLength = xs_songlen_get(songFilename, sidInf.startSong) * 1000; |
5 | 572 } |
573 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
574 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
575 /* |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
576 * Create the SID-tune description string from the tune's information |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
577 * formatted by the user-specified format-string. |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
578 */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
579 gchar *xs_filetitle_get(gchar *pcFilename, void *pfInfo, gint iSubTune) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
580 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
581 gint i, j, iLength; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
582 gchar *pcResult; |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
583 t_xs_tuneinfo *finfo = (t_xs_tuneinfo *) pfInfo; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
584 #ifdef HAVE_XMMSEXTRA |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
585 TitleInput *ptInput; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
586 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
587 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
588 // FIXME FIXME: get STIL-info |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
589 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
590 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
591 #ifdef HAVE_XMMSEXTRA |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
592 /* Check if the titles are overridden or not */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
593 if (!xs_cfg.titleOverride) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
594 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
595 /* Use generic XMMS titles */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
596 /* XMMS_NEW_TITLEINPUT(ptInput); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
597 * We duplicate and add typecast to the code here due to XMMS's braindead headers |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
598 */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
599 ptInput = (TitleInput *) g_malloc0(sizeof(TitleInput)); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
600 ptInput->__size = XMMS_TITLEINPUT_SIZE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
601 ptInput->__version = XMMS_TITLEINPUT_VERSION; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
602 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
603 /* Create the input fields */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
604 ptInput->file_name = pcFilename; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
605 ptInput->file_ext = pcFilename; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
606 ptInput->file_path = pcFilename; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
607 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
608 ptInput->track_name = finfo->nameString; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
609 ptInput->track_number = iSubTune; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
610 ptInput->album_name = NULL; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
611 ptInput->performer = finfo->authorString; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
612 xs_strcalloc(&ptInput->date, ""); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
613 ptInput->year = 0; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
614 xs_strcalloc(&ptInput->genre, "SID-tune"); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
615 ptInput->comment = finfo->copyrightString; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
616 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
617 /* Create the string */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
618 pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
619 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
620 /* Dispose all allocated memory */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
621 g_free(ptInput->date); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
622 g_free(ptInput->genre); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
623 g_free(ptInput); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
624 } else { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
625 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
626 /* Check the info strings */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
627 if (finfo->numberOfInfoStrings != 3) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
628 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
629 if (finfo->numberOfInfoStrings < 1) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
630 return 0; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
631 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
632 return g_strdup(finfo->infoString[0]); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
633 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
634 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
635 /* Construct the final result info */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
636 for (j = i = 0; i < strlen(xs_cfg.titleFormat); i++) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
637 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
638 if (xs_cfg.titleFormat[i] == '%') |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
639 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
640 switch (xs_cfg.titleFormat[++i]) { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
641 case '1': |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
642 xs_strpcat(&pcResult, &j, finfo->authorString); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
643 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
644 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
645 case '2': |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
646 xs_strpcat(&pcResult, &j, finfo->nameString); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
647 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
648 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
649 case '3': |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
650 xs_strpcat(&pcResult, &j, finfo->copyrightString); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
651 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
652 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
653 case '4': |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
654 xs_strpcat(&pcResult, &j, finfo->formatString); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
655 break; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
656 } /* case */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
657 } else |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
658 pcResult[j++] = xs_cfg.titleFormat[i]; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
659 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
660 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
661 pcResult[j] = 0; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
662 #ifdef HAVE_XMMSEXTRA |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
663 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
664 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
665 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
666 return pcResult; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
667 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
668 |