Mercurial > hg > xmms-sid
diff src/xs_sidplay2.cpp @ 869:3a9bf45178ff
Use xs_fload_buffer() again, to support potential VFS backends.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 09 Nov 2012 04:00:27 +0200 |
parents | 011ba70e271e |
children | a5b118c853f5 |
line wrap: on
line diff
--- a/src/xs_sidplay2.cpp Fri Nov 09 03:59:19 2012 +0200 +++ b/src/xs_sidplay2.cpp Fri Nov 09 04:00:27 2012 +0200 @@ -395,19 +395,29 @@ gboolean xs_sidplay2_load(XSEngineState * state, gchar * filename) { XSSIDPlay2 *engine = (XSSIDPlay2 *) state->internal; + gboolean res = FALSE; + guint8 *buf = NULL; + size_t bufSize; - if (!engine || !filename) + if (!engine) return FALSE; - - engine->tune.load(filename); + + if (!xs_fload_buffer(filename, &buf, &bufSize, XS_SIDBUF_SIZE, TRUE)) + goto error; + + engine->tune.read(buf, bufSize); if (!engine->tune) { xs_error("Could not load file '%s': %s\n", filename, (engine->tune.getInfo()).statusString); - return FALSE; + goto error; } - - return TRUE; + + res = TRUE; + +error: + g_free(buf); + return res; } @@ -441,22 +451,29 @@ */ XSTuneInfo *xs_sidplay2_getinfo(const gchar *filename) { - XSTuneInfo *res; - SidTune *tune; + XSTuneInfo *res = NULL; + SidTune *tune = NULL; SidTuneInfo info; + guint8 *buf = NULL; + size_t bufSize; /* Check if the tune exists and is readable */ - if ((tune = new SidTune(filename)) == NULL) + if (!xs_fload_buffer(filename, &buf, &bufSize, XS_SIDBUF_SIZE, TRUE)) + { + XSDEBUG("could not load file '%s'.\n", filename); + goto error; + } + + if ((tune = new SidTune(buf, bufSize)) == NULL) { XSDEBUG("could not initialize tune from '%s'.\n", filename); - return NULL; + goto error; } if (!tune->getStatus()) { XSDEBUG("tune->getStatus() returned false for '%s'.\n", filename); - delete tune; - return NULL; + goto error; } /* Get general tune information */ @@ -470,8 +487,12 @@ info.dataFileLen, info.formatString, info.sidModel ); - - delete tune; + +error: + if (tune) + delete tune; + + g_free(buf); return res; }