# HG changeset patch # User Matti Hamalainen # Date 1352407476 -7200 # Node ID 5b93bd8c7814c5ae53896942e359b7d37dafa91e # Parent 7b11ba6fc4cc45f89a0602161350786c90bbaa89 Cleanups, adjust backend configuration sequences, more error checking, improved debug output. diff -r 7b11ba6fc4cc -r 5b93bd8c7814 src/xs_sidplay1.cpp --- a/src/xs_sidplay1.cpp Thu Nov 08 22:43:45 2012 +0200 +++ b/src/xs_sidplay1.cpp Thu Nov 08 22:44:36 2012 +0200 @@ -86,9 +86,12 @@ XSSIDPlay1 *engine; assert(state); + XSDEBUG("SIDPlay1 backend initializing.\n"); + /* Allocate internal structures */ engine = (XSSIDPlay1 *) g_malloc0(sizeof(XSSIDPlay1)); - if (!engine) return FALSE; + if (!engine) + return FALSE; /* Initialize engine */ engine->emu = new emuEngine(); @@ -110,6 +113,8 @@ state->internal = engine; + XSDEBUG("SIDPlay1 emulation configuration\n"); + /* Get current configuration */ engine->emu->getConfig(engine->currConfig); @@ -258,6 +263,8 @@ XSSIDPlay1 *engine; assert(state); + XSDEBUG("SIDPlay1 backend shutdown.\n"); + engine = (XSSIDPlay1 *) state->internal; /* Free internals */ diff -r 7b11ba6fc4cc -r 5b93bd8c7814 src/xs_sidplay2.cpp --- a/src/xs_sidplay2.cpp Thu Nov 08 22:43:45 2012 +0200 +++ b/src/xs_sidplay2.cpp Thu Nov 08 22:44:36 2012 +0200 @@ -113,6 +113,8 @@ gint i; assert(state); + XSDEBUG("SIDPlay2 backend initializing.\n"); + /* Allocate internal structures */ engine = new XSSIDPlay2(); state->internal = engine; @@ -120,6 +122,7 @@ return FALSE; /* Get current configuration */ + XSDEBUG("SIDPlay2 emulation configuration\n"); engine->config = engine->emu.config(); /* Configure channels and stuff */ @@ -225,67 +228,6 @@ tmpFilter.cutoff[i][1] = f->points[i].y; } - /* Initialize builder object */ - XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (engine->emu.info()).maxsids); - - switch (xs_cfg.sid2Builder) - { -#ifdef HAVE_RESID_BUILDER - case XS_BLD_RESID: - { - ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder"); - if (rs) - { - engine->config.sidEmulation = rs; - if (!*rs) return FALSE; - rs->create((engine->emu.info()).maxsids); - if (!*rs) return FALSE; - } - } - break; -#endif - -#ifdef HAVE_HARDSID_BUILDER - case XS_BLD_HARDSID: - { - HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder (FP)"); - engine->config.sidEmulation = (sidbuilder *) hs; - if (hs) - { - hs->create((engine->emu.info()).maxsids); - if (!*hs) - { - xs_error("hardSID->create() failed.\n"); - return FALSE; - } - } - } - break; -#endif - - default: - xs_error("[SIDPlay2] Invalid or unsupported builder selected.\n"); - break; - } - - if (!engine->config.sidEmulation) - { - xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n"); - return FALSE; - } - -#if 0 - // Setup filter - engine->config.sidEmulation->filter(xs_cfg.emulateFilters); - if (!*(engine->config.sidEmulation)) - { - xs_error("builder->filter(%d) failed.\n", xs_cfg.emulateFilters); - return FALSE; - } -#endif - - XSDEBUG("%s\n", engine->config.sidEmulation->credits()); - /* Clockspeed settings */ switch (xs_cfg.clockSpeed) { @@ -327,6 +269,69 @@ engine->config.sidModel = xs_cfg.forceModel ? engine->config.sidDefault : SID2_MODEL_CORRECT; engine->config.sidSamples = TRUE; + + /* Initialize builder object */ + XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (engine->emu.info()).maxsids); + + switch (xs_cfg.sid2Builder) + { +#ifdef HAVE_RESID_BUILDER + case XS_BLD_RESID: + { + ReSIDBuilder *rs = new ReSIDBuilder("ReSID builder"); + if (rs) + { + engine->config.sidEmulation = rs; + if (!*rs) return FALSE; + rs->create((engine->emu.info()).maxsids); + if (!*rs) return FALSE; + } + } + break; +#endif + +#ifdef HAVE_HARDSID_BUILDER + case XS_BLD_HARDSID: + { + HardSIDBuilder *hs = new HardSIDBuilder("HardSID builder (FP)"); + engine->config.sidEmulation = (sidbuilder *) hs; + if (hs) + { + hs->create((engine->emu.info()).maxsids); + if (!*hs) + { + xs_error("hardSID->create() failed.\n"); + return FALSE; + } + } + } + break; +#endif + + default: + xs_error("[SIDPlay2] Invalid or unsupported builder selected.\n"); + return FALSE; + } + + if (!engine->config.sidEmulation) + { + xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n"); + return FALSE; + } + +#if 0 + // Setup filter + engine->config.sidEmulation->filter(xs_cfg.emulateFilters); + if (!*(engine->config.sidEmulation)) + { + xs_error("builder->filter(%d) failed.\n", xs_cfg.emulateFilters); + return FALSE; + } +#endif + + XSDEBUG("%s\n", engine->config.sidEmulation->credits()); + + return TRUE; } @@ -337,6 +342,8 @@ { XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; + XSDEBUG("SIDPlay2 backend shutdown.\n"); + xs_sidplay2_delete(state); if (engine) @@ -439,4 +446,5 @@ } /* extern "C" */ -#endif /* HAVE_SIDPLAY2 */ +#endif /* HAVE_SIDPLAY2 + */ diff -r 7b11ba6fc4cc -r 5b93bd8c7814 src/xs_sidplayfp.cpp --- a/src/xs_sidplayfp.cpp Thu Nov 08 22:43:45 2012 +0200 +++ b/src/xs_sidplayfp.cpp Thu Nov 08 22:44:36 2012 +0200 @@ -130,13 +130,15 @@ } -/* Initialize SIDPlay2 +/* Initialize SIDPlayFP */ gboolean xs_sidplayfp_init(XSEngineState * state) { XSSIDPlayFP *engine; assert(state); + XSDEBUG("SIDPlayFP backend initializing.\n"); + /* Allocate internal structures */ engine = new XSSIDPlayFP(); state->internal = engine; @@ -144,6 +146,7 @@ return FALSE; /* Get current configuration */ + XSDEBUG("SIDPlayFP emulation configuration\n"); engine->config = engine->emu.config(); /* Configure channels and stuff */ @@ -154,11 +157,37 @@ engine->config.samplingMethod = SID2_RESAMPLE_INTERPOLATE; engine->config.frequency = state->audioFrequency; + /* Clockspeed settings */ + switch (xs_cfg.clockSpeed) + { + case XS_CLOCK_NTSC: + engine->config.clockDefault = SID2_CLOCK_NTSC; + break; + + default: + case XS_CLOCK_PAL: + engine->config.clockDefault = SID2_CLOCK_PAL; + xs_cfg.clockSpeed = XS_CLOCK_PAL; + break; + } + + + /* Configure rest of the emulation */ + engine->config.sidDefault = xs_cfg.mos8580 ? SID2_MOS8580 : SID2_MOS6581; + engine->config.clockForced = xs_cfg.forceSpeed; + +#ifndef HAVE_SIDPLAYFP_V1 + engine->config.sidSamples = TRUE; + engine->config.sidModel = xs_cfg.forceModel ? engine->config.sidDefault : SID2_MODEL_CORRECT; + engine->config.clockSpeed = xs_cfg.forceSpeed ? engine->config.clockDefault : SID2_CLOCK_CORRECT; +#endif + /* Initialize builder object */ XSDEBUG("init builder #%i, maxsids=%i\n", xs_cfg.sid2Builder, (engine->emu.info()).maxsids); switch (xs_cfg.sid2Builder) { +#if 0 #ifdef HAVE_RESID_BUILDER case XS_BLD_RESID: { @@ -168,30 +197,30 @@ { } #else - if (rs) + if (rs && *rs) { engine->config.sidEmulation = rs; - if (!*rs) return FALSE; + if (!(*rs)) return FALSE; rs->create((engine->emu.info()).maxsids); - if (!*rs) return FALSE; + if (!(*rs)) return FALSE; rs->bias(0.0f); } #endif // HAVE_SIDPLAYFP_V1 } break; #endif // HAVE_RESID_BUILDER - +#endif #ifdef HAVE_RESID_FP_BUILDER case XS_BLD_RESID_FP: { ReSIDfpBuilder *rs = new ReSIDfpBuilder("ReSID builder FP!"); - if (rs) + if (rs && *rs) { engine->config.sidEmulation = rs; - if (!*rs) return FALSE; + if (!(*rs)) return FALSE; rs->create((engine->emu.info()).maxsids); - if (!*rs) return FALSE; + if (!(*rs)) return FALSE; rs->filter6581Curve(0.0); rs->filter8580Curve(0.0); @@ -219,13 +248,13 @@ #endif default: - xs_error("[SIDPlay2] Invalid or unsupported builder selected.\n"); - break; + xs_error("[SIDPlayFP] Invalid or unsupported builder selected.\n"); + return FALSE; } if (!engine->config.sidEmulation) { - xs_error("[SIDPlay2] Could not initialize SIDBuilder object.\n"); + xs_error("[SIDPlayFP] Could not initialize SIDBuilder object.\n"); return FALSE; } @@ -239,41 +268,19 @@ XSDEBUG("%s\n", engine->config.sidEmulation->credits()); - /* Clockspeed settings */ - switch (xs_cfg.clockSpeed) - { - case XS_CLOCK_NTSC: - engine->config.clockDefault = SID2_CLOCK_NTSC; - break; - - default: - case XS_CLOCK_PAL: - engine->config.clockDefault = SID2_CLOCK_PAL; - xs_cfg.clockSpeed = XS_CLOCK_PAL; - break; - } - - - /* Configure rest of the emulation */ - engine->config.sidDefault = xs_cfg.mos8580 ? SID2_MOS8580 : SID2_MOS6581; - engine->config.clockForced = xs_cfg.forceSpeed; - -#ifndef HAVE_SIDPLAYFP_V1 - engine->config.sidSamples = TRUE; - engine->config.sidModel = xs_cfg.forceModel ? engine->config.sidDefault : SID2_MODEL_CORRECT; - engine->config.clockSpeed = xs_cfg.forceSpeed ? engine->config.clockDefault : SID2_CLOCK_CORRECT; -#endif return TRUE; } -/* Close SIDPlay2 engine +/* Close SIDPlayFP engine */ void xs_sidplayfp_close(XSEngineState * state) { XSSIDPlayFP *engine = (XSSIDPlayFP *) state->internal; + XSDEBUG("SIDPlayFP backend shutdown.\n"); + xs_sidplayfp_delete(state); if (engine) @@ -297,19 +304,19 @@ if (!engine->tune.selectSong(state->currSong)) { - xs_error("[SIDPlay2] tune.selectSong() failed\n"); + xs_error("[SIDPlayFP] tune.selectSong() failed\n"); return FALSE; } if (engine->emu.load(&(engine->tune)) < 0) { - xs_error("[SIDPlay2] emu.load() failed\n"); + xs_error("[SIDPlayFP] emu.load() failed\n"); return FALSE; } if (engine->emu.config(engine->config) < 0) { - xs_error("[SIDPlay2] Emulator engine configuration failed!\n"); + xs_error("[SIDPlayFP] Emulator engine configuration failed!\n"); return FALSE; }