Mercurial > hg > xmms-sid
comparison src/xs_sidplay2.cc @ 768:f145ba458acd
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 06 Nov 2012 01:15:28 +0200 |
parents | 19e2745f75d8 |
children | 120d6f247f1b |
comparison
equal
deleted
inserted
replaced
767:cf644ac89b54 | 768:f145ba458acd |
---|---|
456 | 456 |
457 /* Initialize current song and sub-tune | 457 /* Initialize current song and sub-tune |
458 */ | 458 */ |
459 gboolean xs_sidplay2_initsong(XSEngineState * state) | 459 gboolean xs_sidplay2_initsong(XSEngineState * state) |
460 { | 460 { |
461 XSSIDPlay2 *engine; | 461 XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; |
462 assert(state); | 462 |
463 | 463 if (!engine) |
464 engine = (XSSIDPlay2 *) state->internal; | 464 return FALSE; |
465 if (!engine) return FALSE; | |
466 | 465 |
467 if (!engine->tune->selectSong(state->currSong)) { | 466 if (!engine->tune->selectSong(state->currSong)) { |
468 xs_error("[SIDPlay2] tune->selectSong() failed\n"); | 467 xs_error("[SIDPlay2] tune->selectSong() failed\n"); |
469 return FALSE; | 468 return FALSE; |
470 } | 469 } |
482 | 481 |
483 /* Emulate and render audio data to given buffer | 482 /* Emulate and render audio data to given buffer |
484 */ | 483 */ |
485 guint xs_sidplay2_fillbuffer(XSEngineState * state, gchar * audioBuffer, guint audioBufSize) | 484 guint xs_sidplay2_fillbuffer(XSEngineState * state, gchar * audioBuffer, guint audioBufSize) |
486 { | 485 { |
487 XSSIDPlay2 *engine; | 486 XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; |
488 assert(state); | 487 |
489 | 488 if (!engine) |
490 engine = (XSSIDPlay2 *) state->internal; | 489 return 0; |
491 if (!engine) return 0; | 490 |
492 | 491 return engine->emu.play((short *) audioBuffer, (audioBufSize / sizeof(short))); |
493 return engine->emu->play((short *) audioBuffer, audioBufSize / sizeof(short)); | |
494 } | 492 } |
495 | 493 |
496 | 494 |
497 /* Load a given SID-tune file | 495 /* Load a given SID-tune file |
498 */ | 496 */ |
499 gboolean xs_sidplay2_load(XSEngineState * state, gchar * filename) | 497 gboolean xs_sidplay2_load(XSEngineState * state, gchar * filename) |
500 { | 498 { |
501 XSSIDPlay2 *engine; | 499 XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; |
502 assert(state); | 500 |
503 state->isInitialized = FALSE; | 501 state->isInitialized = FALSE; |
504 | 502 |
505 engine = (XSSIDPlay2 *) state->internal; | 503 if (!engine) |
506 if (!engine) return FALSE; | 504 return FALSE; |
507 | 505 |
508 if (xs_fload_buffer(filename, &(engine->buf), &(engine->bufSize)) != 0) | 506 if (xs_fload_buffer(filename, &(engine->buf), &(engine->bufSize)) != 0) |
509 return FALSE; | 507 return FALSE; |
510 | 508 |
511 if (!(engine->tune = new SidTune(filename))) | 509 if (!(engine->tune = new SidTune(filename))) |
517 | 515 |
518 /* Delete INTERNAL information | 516 /* Delete INTERNAL information |
519 */ | 517 */ |
520 void xs_sidplay2_delete(XSEngineState * state) | 518 void xs_sidplay2_delete(XSEngineState * state) |
521 { | 519 { |
522 XSSIDPlay2 *engine; | 520 XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; |
523 assert(state); | 521 |
524 | 522 if (engine) |
525 engine = (XSSIDPlay2 *) state->internal; | 523 { |
526 if (!engine) | 524 if (engine->tune) |
527 return; | 525 { |
528 | 526 delete engine->tune; |
529 if (engine->tune) | 527 engine->tune = NULL; |
530 { | 528 } |
531 delete engine->tune; | 529 |
532 engine->tune = NULL; | 530 g_free(engine->buf); |
533 } | 531 engine->buf = NULL; |
534 | 532 engine->bufSize = 0; |
535 g_free(engine->buf); | 533 } |
536 engine->buf = NULL; | |
537 engine->bufSize = 0; | |
538 } | 534 } |
539 | 535 |
540 | 536 |
541 /* Hardware backend flushing | 537 /* Hardware backend flushing |
542 */ | 538 */ |
543 void xs_sidplay2_flush(XSEngineState * state) | 539 void xs_sidplay2_flush(XSEngineState * state) |
544 { | 540 { |
545 assert(state); | 541 (void) state; |
546 | 542 |
547 #ifdef HAVE_HARDSID_BUILDER | 543 #ifdef HAVE_HARDSID_BUILDER |
544 if (xs_cfg.sid2Builder == XS_BLD_HARDSID) | |
545 { | |
548 #ifdef HSID_SID2_COM | 546 #ifdef HSID_SID2_COM |
549 IfPtr<HardSIDBuilder> hs(state->builder); | 547 IfPtr<HardSIDBuilder> hs(state->config.sidEmulation); |
550 if (hs) | 548 if (hs) |
551 hs->flush(); | 549 hs->flush(); |
552 #else | 550 #else |
553 if (xs_cfg.sid2Builder == XS_BLD_HARDSID) | 551 ((HardSIDBuilder *) state->config.sidEmulation)->flush(); |
554 ((HardSIDBuilder *) state->builder)->flush(); | 552 #endif |
555 #endif | 553 } |
556 #endif | 554 #endif |
557 } | 555 } |
558 | 556 |
559 | 557 |
560 } /* extern "C" */ | 558 } /* extern "C" */ |