Mercurial > hg > xmms-sid
comparison src/xs_sidplay1.cc @ 657:acaba070cf49
Lots of cosmetic code cleanups; synced the de-gettextification from Audacious-SID, I suppose it makes some sense ...
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 02 Apr 2008 19:46:59 +0300 |
parents | 4674e3c37121 |
children | b0743dc9165d |
comparison
equal
deleted
inserted
replaced
656:e9257f006f41 | 657:acaba070cf49 |
---|---|
41 emuEngine *currEng; | 41 emuEngine *currEng; |
42 emuConfig currConfig; | 42 emuConfig currConfig; |
43 sidTune *currTune; | 43 sidTune *currTune; |
44 guint8 *buf; | 44 guint8 *buf; |
45 size_t bufSize; | 45 size_t bufSize; |
46 } t_xs_sidplay1; | 46 } xs_sidplay1_t; |
47 | 47 |
48 | 48 |
49 /* We need to 'export' all this pseudo-C++ crap */ | 49 /* We need to 'export' all this pseudo-C++ crap */ |
50 extern "C" { | 50 extern "C" { |
51 | 51 |
54 */ | 54 */ |
55 #define TFUNCTION xs_sidplay1_getinfo | 55 #define TFUNCTION xs_sidplay1_getinfo |
56 #define TFUNCTION2 xs_sidplay1_updateinfo | 56 #define TFUNCTION2 xs_sidplay1_updateinfo |
57 #define TTUNEINFO sidTuneInfo | 57 #define TTUNEINFO sidTuneInfo |
58 #define TTUNE sidTune | 58 #define TTUNE sidTune |
59 #define TENGINE t_xs_sidplay1 | 59 #define TENGINE xs_sidplay1_t |
60 #include "xs_sidplay.h" | 60 #include "xs_sidplay.h" |
61 | 61 |
62 | 62 |
63 /* Check if we can play the given file | 63 /* Check if we can play the given file |
64 */ | 64 */ |
65 gboolean xs_sidplay1_probe(t_xs_file *f) | 65 gboolean xs_sidplay1_probe(xs_file_t *f) |
66 { | 66 { |
67 gchar tmpBuf[4]; | 67 gchar tmpBuf[4]; |
68 | 68 |
69 if (!f) return FALSE; | 69 if (!f) return FALSE; |
70 | 70 |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 /* Initialize SIDPlay1 | 81 /* Initialize SIDPlay1 |
82 */ | 82 */ |
83 gboolean xs_sidplay1_init(t_xs_status * myStatus) | 83 gboolean xs_sidplay1_init(xs_status_t * myStatus) |
84 { | 84 { |
85 gint tmpFreq; | 85 gint tmpFreq; |
86 t_xs_sidplay1 *myEngine; | 86 xs_sidplay1_t *myEngine; |
87 assert(myStatus); | 87 assert(myStatus); |
88 | 88 |
89 /* Allocate internal structures */ | 89 /* Allocate internal structures */ |
90 myEngine = (t_xs_sidplay1 *) g_malloc0(sizeof(t_xs_sidplay1)); | 90 myEngine = (xs_sidplay1_t *) g_malloc0(sizeof(xs_sidplay1_t)); |
91 if (!myEngine) return FALSE; | 91 if (!myEngine) return FALSE; |
92 | 92 |
93 /* Initialize engine */ | 93 /* Initialize engine */ |
94 myEngine->currEng = new emuEngine(); | 94 myEngine->currEng = new emuEngine(); |
95 if (!myEngine->currEng) { | 95 if (!myEngine->currEng) { |
96 xs_error(_("[SIDPlay1] Could not initialize emulation engine.\n")); | 96 xs_error("[SIDPlay1] Could not initialize emulation engine.\n"); |
97 g_free(myEngine); | 97 g_free(myEngine); |
98 return FALSE; | 98 return FALSE; |
99 } | 99 } |
100 | 100 |
101 /* Verify endianess */ | 101 /* Verify endianess */ |
102 if (!myEngine->currEng->verifyEndianess()) { | 102 if (!myEngine->currEng->verifyEndianess()) { |
103 xs_error(_("[SIDPlay1] Endianess verification failed.\n")); | 103 xs_error("[SIDPlay1] Endianess verification failed.\n"); |
104 delete myEngine->currEng; | 104 delete myEngine->currEng; |
105 g_free(myEngine); | 105 g_free(myEngine); |
106 return FALSE; | 106 return FALSE; |
107 } | 107 } |
108 | 108 |
233 myEngine->currConfig.filterFt = xs_cfg.sid1FilterFt; | 233 myEngine->currConfig.filterFt = xs_cfg.sid1FilterFt; |
234 | 234 |
235 | 235 |
236 /* Now set the emulator configuration */ | 236 /* Now set the emulator configuration */ |
237 if (!myEngine->currEng->setConfig(myEngine->currConfig)) { | 237 if (!myEngine->currEng->setConfig(myEngine->currConfig)) { |
238 xs_error(_("[SIDPlay1] Emulator engine configuration failed!\n")); | 238 xs_error("[SIDPlay1] Emulator engine configuration failed!\n"); |
239 return FALSE; | 239 return FALSE; |
240 } | 240 } |
241 | 241 |
242 /* Create sidtune object */ | 242 /* Create sidtune object */ |
243 myEngine->currTune = new sidTune(0); | 243 myEngine->currTune = new sidTune(0); |
244 if (!myEngine->currTune) { | 244 if (!myEngine->currTune) { |
245 xs_error(_("[SIDPlay1] Could not initialize SIDTune object.\n")); | 245 xs_error("[SIDPlay1] Could not initialize SIDTune object.\n"); |
246 return FALSE; | 246 return FALSE; |
247 } | 247 } |
248 | 248 |
249 return TRUE; | 249 return TRUE; |
250 } | 250 } |
251 | 251 |
252 | 252 |
253 /* Close SIDPlay1 engine | 253 /* Close SIDPlay1 engine |
254 */ | 254 */ |
255 void xs_sidplay1_close(t_xs_status * myStatus) | 255 void xs_sidplay1_close(xs_status_t * myStatus) |
256 { | 256 { |
257 t_xs_sidplay1 *myEngine; | 257 xs_sidplay1_t *myEngine; |
258 assert(myStatus); | 258 assert(myStatus); |
259 | 259 |
260 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; | 260 myEngine = (xs_sidplay1_t *) myStatus->sidEngine; |
261 | 261 |
262 /* Free internals */ | 262 /* Free internals */ |
263 if (myEngine->currEng) { | 263 if (myEngine->currEng) { |
264 delete myEngine->currEng; | 264 delete myEngine->currEng; |
265 myEngine->currEng = NULL; | 265 myEngine->currEng = NULL; |
277 } | 277 } |
278 | 278 |
279 | 279 |
280 /* Initialize current song and sub-tune | 280 /* Initialize current song and sub-tune |
281 */ | 281 */ |
282 gboolean xs_sidplay1_initsong(t_xs_status * myStatus) | 282 gboolean xs_sidplay1_initsong(xs_status_t * myStatus) |
283 { | 283 { |
284 t_xs_sidplay1 *myEngine; | 284 xs_sidplay1_t *myEngine; |
285 assert(myStatus); | 285 assert(myStatus); |
286 | 286 |
287 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; | 287 myEngine = (xs_sidplay1_t *) myStatus->sidEngine; |
288 if (!myEngine) return FALSE; | 288 if (!myEngine) return FALSE; |
289 | 289 |
290 if (!myEngine->currTune) { | 290 if (!myEngine->currTune) { |
291 xs_error(_("[SIDPlay1] SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n")); | 291 xs_error("[SIDPlay1] SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n"); |
292 return FALSE; | 292 return FALSE; |
293 } | 293 } |
294 | 294 |
295 if (!myEngine->currTune->getStatus()) { | 295 if (!myEngine->currTune->getStatus()) { |
296 xs_error(_("[SIDPlay1] SID-tune status check failed. This should not happen, report to XMMS-SID author.\n")); | 296 xs_error("[SIDPlay1] SID-tune status check failed. This should not happen, report to XMMS-SID author.\n"); |
297 return FALSE; | 297 return FALSE; |
298 } | 298 } |
299 | 299 |
300 myStatus->isInitialized = TRUE; | 300 myStatus->isInitialized = TRUE; |
301 | 301 |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 /* Emulate and render audio data to given buffer | 306 /* Emulate and render audio data to given buffer |
307 */ | 307 */ |
308 guint xs_sidplay1_fillbuffer(t_xs_status * myStatus, gchar * audioBuffer, guint audioBufSize) | 308 guint xs_sidplay1_fillbuffer(xs_status_t * myStatus, gchar * audioBuffer, guint audioBufSize) |
309 { | 309 { |
310 t_xs_sidplay1 *myEngine; | 310 xs_sidplay1_t *myEngine; |
311 assert(myStatus); | 311 assert(myStatus); |
312 | 312 |
313 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; | 313 myEngine = (xs_sidplay1_t *) myStatus->sidEngine; |
314 if (!myEngine) return 0; | 314 if (!myEngine) return 0; |
315 | 315 |
316 sidEmuFillBuffer(*myEngine->currEng, *myEngine->currTune, audioBuffer, audioBufSize); | 316 sidEmuFillBuffer(*myEngine->currEng, *myEngine->currTune, audioBuffer, audioBufSize); |
317 | 317 |
318 return audioBufSize; | 318 return audioBufSize; |
319 } | 319 } |
320 | 320 |
321 | 321 |
322 /* Load a given SID-tune file | 322 /* Load a given SID-tune file |
323 */ | 323 */ |
324 gboolean xs_sidplay1_load(t_xs_status * myStatus, gchar * pcFilename) | 324 gboolean xs_sidplay1_load(xs_status_t * myStatus, gchar * filename) |
325 { | 325 { |
326 t_xs_sidplay1 *myEngine; | 326 xs_sidplay1_t *myEngine; |
327 assert(myStatus); | 327 assert(myStatus); |
328 myStatus->isInitialized = FALSE; | 328 myStatus->isInitialized = FALSE; |
329 | 329 |
330 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; | 330 myEngine = (xs_sidplay1_t *) myStatus->sidEngine; |
331 if (!myEngine) return FALSE; | 331 if (!myEngine) return FALSE; |
332 | 332 |
333 /* Try to get the tune */ | 333 /* Try to get the tune */ |
334 if (!pcFilename) return FALSE; | 334 if (!filename) return FALSE; |
335 | 335 |
336 if (xs_fload_buffer(pcFilename, &(myEngine->buf), &(myEngine->bufSize)) != 0) | 336 if (xs_fload_buffer(filename, &(myEngine->buf), &(myEngine->bufSize)) != 0) |
337 return FALSE; | 337 return FALSE; |
338 | 338 |
339 if (!myEngine->currTune->load(myEngine->buf, myEngine->bufSize)) | 339 if (!myEngine->currTune->load(myEngine->buf, myEngine->bufSize)) |
340 return FALSE; | 340 return FALSE; |
341 | 341 |
343 } | 343 } |
344 | 344 |
345 | 345 |
346 /* Delete INTERNAL information | 346 /* Delete INTERNAL information |
347 */ | 347 */ |
348 void xs_sidplay1_delete(t_xs_status * myStatus) | 348 void xs_sidplay1_delete(xs_status_t * myStatus) |
349 { | 349 { |
350 t_xs_sidplay1 *myEngine; | 350 xs_sidplay1_t *myEngine; |
351 assert(myStatus); | 351 assert(myStatus); |
352 | 352 |
353 myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; | 353 myEngine = (xs_sidplay1_t *) myStatus->sidEngine; |
354 if (!myEngine) return; | 354 if (!myEngine) return; |
355 | 355 |
356 g_free(myEngine->buf); | 356 g_free(myEngine->buf); |
357 myEngine->buf = NULL; | 357 myEngine->buf = NULL; |
358 myEngine->bufSize = 0; | 358 myEngine->bufSize = 0; |