Mercurial > hg > xmms-sid
diff src/xs_sidplay1.cc @ 527:fe8b41abd923
Now everything necessary should be using the VFS functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 20 Feb 2007 18:09:04 +0000 |
parents | fa95d942f226 |
children | d837d2f06456 |
line wrap: on
line diff
--- a/src/xs_sidplay1.cc Tue Feb 20 16:53:05 2007 +0000 +++ b/src/xs_sidplay1.cc Tue Feb 20 18:09:04 2007 +0000 @@ -41,6 +41,8 @@ emuEngine *currEng; emuConfig currConfig; sidTune *currTune; + guint8 *buf; + size_t bufSize; } t_xs_sidplay1; @@ -91,14 +93,14 @@ /* Initialize engine */ myEngine->currEng = new emuEngine(); if (!myEngine->currEng) { - xs_error(_("Could not initialize libSIDPlay1 emulation engine.\n")); + xs_error(_("[SIDPlay1] Could not initialize emulation engine.\n")); g_free(myEngine); return FALSE; } /* Verify endianess */ if (!myEngine->currEng->verifyEndianess()) { - xs_error(_("Endianess verification failed.\n")); + xs_error(_("[SIDPlay1] Endianess verification failed.\n")); delete myEngine->currEng; g_free(myEngine); return FALSE; @@ -233,10 +235,17 @@ /* Now set the emulator configuration */ if (!myEngine->currEng->setConfig(myEngine->currConfig)) { - xs_error(_("Emulator engine configuration failed!\n")); + xs_error(_("[SIDPlay1] Emulator engine configuration failed!\n")); return FALSE; } - + + /* Create sidtune object */ + myEngine->currTune = new sidTune(0); + if (!myEngine->currTune) { + xs_error(_("[SIDPlay1] Could not initialize SIDTune object.\n")); + return FALSE; + } + return TRUE; } @@ -256,6 +265,13 @@ myEngine->currEng = NULL; } + if (myEngine->currTune) { + delete myEngine->currTune; + myEngine->currTune = NULL; + } + + xs_sidplay1_delete(myStatus); + g_free(myEngine); myStatus->sidEngine = NULL; } @@ -272,15 +288,17 @@ if (!myEngine) return FALSE; if (!myEngine->currTune) { - xs_error(_("SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n")); + xs_error(_("[SIDPlay1] SID-tune struct pointer was NULL. This should not happen, report to XMMS-SID author.\n")); return FALSE; } if (!myEngine->currTune->getStatus()) { - xs_error(_("SID-tune status check failed. This should not happen, report to XMMS-SID author.\n")); + xs_error(_("[SIDPlay1] SID-tune status check failed. This should not happen, report to XMMS-SID author.\n")); return FALSE; } + myStatus->isInitialized = TRUE; + return sidEmuInitializeSong(*myEngine->currEng, *myEngine->currTune, myStatus->currSong); } @@ -306,19 +324,20 @@ gboolean xs_sidplay1_load(t_xs_status * myStatus, gchar * pcFilename) { t_xs_sidplay1 *myEngine; - sidTune *newTune; assert(myStatus); + myStatus->isInitialized = FALSE; myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; if (!myEngine) return FALSE; - /* Try to load the file/tune */ + /* Try to get the tune */ if (!pcFilename) return FALSE; - - newTune = new sidTune(pcFilename); - if (!newTune) return FALSE; - - myEngine->currTune = newTune; + + if (xs_fload_buffer(pcFilename, &(myEngine->buf), &(myEngine->bufSize)) != 0) + return FALSE; + + if (!myEngine->currTune->load(myEngine->buf, myEngine->bufSize)) + return FALSE; return TRUE; } @@ -333,11 +352,10 @@ myEngine = (t_xs_sidplay1 *) myStatus->sidEngine; if (!myEngine) return; - - if (myEngine->currTune) { - delete myEngine->currTune; - myEngine->currTune = NULL; - } + + g_free(myEngine->buf); + myEngine->buf = NULL; + myEngine->bufSize = 0; }