diff src/xs_sidplayfp.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 fa926296e161
children d03e5c73eb51
line wrap: on
line diff
--- a/src/xs_sidplayfp.cpp	Fri Nov 09 03:59:19 2012 +0200
+++ b/src/xs_sidplayfp.cpp	Fri Nov 09 04:00:27 2012 +0200
@@ -364,11 +364,18 @@
 gboolean xs_sidplayfp_load(XSEngineState * state, gchar * filename)
 {
     XSSIDPlayFP *engine = (XSSIDPlayFP *) state->internal;
+    gboolean res = FALSE;
+    guint8 *buf = NULL;
+    size_t bufSize;
 
-    if (!engine || !filename)
+    if (!engine)
         return FALSE;
+
+    if (!xs_fload_buffer(filename, &buf, &bufSize, XS_SIDBUF_SIZE, TRUE))
+        goto error;
+
+    engine->tune.read(buf, bufSize);
     
-    engine->tune.load(filename);
 #ifdef HAVE_SIDPLAYFP_V1
     if (!engine->tune.getStatus())
 #else
@@ -376,10 +383,14 @@
 #endif
     {
         xs_error("Could not load file '%s'\n", filename);
-        return FALSE;
+        goto error;
     }
 
-    return TRUE;
+    res = TRUE;
+
+error:
+    g_free(buf);
+    return res;
 }
 
 
@@ -413,24 +424,32 @@
  */
 XSTuneInfo *xs_sidplayfp_getinfo(const gchar *filename)
 {
-    XSTuneInfo *res;
-    SidTune *tune;
+    XSTuneInfo *res = NULL;
+    SidTune *tune = NULL;
+    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 */
+    {
 #ifdef HAVE_SIDPLAYFP_V1
     const SidTuneInfo *info = tune->getInfo();
 
@@ -452,8 +471,13 @@
         info.sidModel1
         );
 #endif
+    }
 
-    delete tune;
+error:
+    if (tune)
+        delete tune;
+
+    g_free(buf);
     return res;
 }