# HG changeset patch # User Matti Hamalainen # Date 1352157328 -7200 # Node ID f145ba458acdf088c73c4b0781389f9c3c8ae29a # Parent cf644ac89b5406038d1159f3ca5e81cb3fd7fb1b Cleanups. diff -r cf644ac89b54 -r f145ba458acd src/xs_sidplay2.cc --- a/src/xs_sidplay2.cc Tue Nov 06 01:13:51 2012 +0200 +++ b/src/xs_sidplay2.cc Tue Nov 06 01:15:28 2012 +0200 @@ -458,11 +458,10 @@ */ gboolean xs_sidplay2_initsong(XSEngineState * state) { - XSSIDPlay2 *engine; - assert(state); + XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; - engine = (XSSIDPlay2 *) state->internal; - if (!engine) return FALSE; + if (!engine) + return FALSE; if (!engine->tune->selectSong(state->currSong)) { xs_error("[SIDPlay2] tune->selectSong() failed\n"); @@ -484,13 +483,12 @@ */ guint xs_sidplay2_fillbuffer(XSEngineState * state, gchar * audioBuffer, guint audioBufSize) { - XSSIDPlay2 *engine; - assert(state); + XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; - engine = (XSSIDPlay2 *) state->internal; - if (!engine) return 0; + if (!engine) + return 0; - return engine->emu->play((short *) audioBuffer, audioBufSize / sizeof(short)); + return engine->emu.play((short *) audioBuffer, (audioBufSize / sizeof(short))); } @@ -498,12 +496,12 @@ */ gboolean xs_sidplay2_load(XSEngineState * state, gchar * filename) { - XSSIDPlay2 *engine; - assert(state); + XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; + state->isInitialized = FALSE; - engine = (XSSIDPlay2 *) state->internal; - if (!engine) return FALSE; + if (!engine) + return FALSE; if (xs_fload_buffer(filename, &(engine->buf), &(engine->bufSize)) != 0) return FALSE; @@ -519,22 +517,20 @@ */ void xs_sidplay2_delete(XSEngineState * state) { - XSSIDPlay2 *engine; - assert(state); + XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; - engine = (XSSIDPlay2 *) state->internal; - if (!engine) - return; + if (engine) + { + if (engine->tune) + { + delete engine->tune; + engine->tune = NULL; + } - if (engine->tune) - { - delete engine->tune; - engine->tune = NULL; + g_free(engine->buf); + engine->buf = NULL; + engine->bufSize = 0; } - - g_free(engine->buf); - engine->buf = NULL; - engine->bufSize = 0; } @@ -542,17 +538,19 @@ */ void xs_sidplay2_flush(XSEngineState * state) { - assert(state); + (void) state; #ifdef HAVE_HARDSID_BUILDER + if (xs_cfg.sid2Builder == XS_BLD_HARDSID) + { #ifdef HSID_SID2_COM - IfPtr hs(state->builder); - if (hs) - hs->flush(); + IfPtr hs(state->config.sidEmulation); + if (hs) + hs->flush(); #else - if (xs_cfg.sid2Builder == XS_BLD_HARDSID) - ((HardSIDBuilder *) state->builder)->flush(); + ((HardSIDBuilder *) state->config.sidEmulation)->flush(); #endif + } #endif }