Mercurial > hg > xmms-sid
diff src/xs_sidplay1.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_sidplay1.cpp Fri Nov 09 03:59:19 2012 +0200 +++ b/src/xs_sidplay1.cpp Fri Nov 09 04:00:27 2012 +0200 @@ -321,20 +321,29 @@ */ gboolean xs_sidplay1_load(XSEngineState * state, gchar * filename) { - XSSIDPlay1 *engine; - assert(state); + XSSIDPlay1 *engine = (XSSIDPlay1 *) state->internal; + gboolean res = FALSE; + guint8 *buf = NULL; + size_t bufSize; - engine = (XSSIDPlay1 *) state->internal; if (!engine) return FALSE; - if (!filename) - return FALSE; - - if (!engine->tune->open(filename)) - return FALSE; + if (!xs_fload_buffer(filename, &buf, &bufSize, XS_SIDBUF_SIZE, TRUE)) + goto error; - return TRUE; + if (!engine->tune->load(buf, bufSize)) + { + xs_error("could not initialize tune from buffer, %p:%d '%s'.\n", + buf, bufSize, filename); + goto error; + } + + res = TRUE; + +error: + g_free(buf); + return res; } @@ -352,22 +361,29 @@ */ XSTuneInfo *xs_sidplay1_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 */ @@ -382,7 +398,11 @@ info.sidModel ); - delete tune; +error: + if (tune) + delete tune; + + g_free(buf); return res; }