diff src/xs_backend.c @ 872:b02f934d8224

Move some code to xs_backend.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 09 Nov 2012 04:37:25 +0200
parents
children 50111e99456a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/xs_backend.c	Fri Nov 09 04:37:25 2012 +0200
@@ -0,0 +1,98 @@
+/*
+   XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
+
+   Backend handling
+
+   Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
+   (C) Copyright 1999-2012 Tecnic Software productions (TNSP)
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation, Inc.,
+   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+#include "xs_backend.h"
+#include "xs_config.h"
+
+/* List of emulator engines
+ */
+#ifdef HAVE_SIDPLAY1
+#  include "xs_sidplay1.h"
+#endif
+#ifdef HAVE_SIDPLAY2
+#  include "xs_sidplay2.h"
+#endif
+#ifdef HAVE_SIDPLAYFP
+#  include "xs_sidplayfp.h"
+#endif
+
+
+static XSEngine xs_enginelist[] =
+{
+#ifdef HAVE_SIDPLAY1
+    {
+        XS_ENG_SIDPLAY1,
+        xs_sidplay1_probe,
+        xs_sidplay1_init, xs_sidplay1_close,
+        xs_sidplay1_initsong, xs_sidplay1_fillbuffer,
+        xs_sidplay1_load, xs_sidplay1_delete,
+        xs_sidplay1_getinfo, xs_sidplay1_updateinfo,
+        NULL
+    },
+#endif
+#ifdef HAVE_SIDPLAY2
+    {
+        XS_ENG_SIDPLAY2,
+        xs_sidplay2_probe,
+        xs_sidplay2_init, xs_sidplay2_close,
+        xs_sidplay2_initsong, xs_sidplay2_fillbuffer,
+        xs_sidplay2_load, xs_sidplay2_delete,
+        xs_sidplay2_getinfo, xs_sidplay2_updateinfo,
+        xs_sidplay2_flush
+    },
+#endif
+#ifdef HAVE_SIDPLAYFP
+    {
+        XS_ENG_SIDPLAYFP,
+        xs_sidplayfp_probe,
+        xs_sidplayfp_init, xs_sidplayfp_close,
+        xs_sidplayfp_initsong, xs_sidplayfp_fillbuffer,
+        xs_sidplayfp_load, xs_sidplayfp_delete,
+        xs_sidplayfp_getinfo, xs_sidplayfp_updateinfo,
+        xs_sidplayfp_flush
+    },
+#endif
+};
+
+static const gint xs_nenginelist = sizeof(xs_enginelist) / sizeof(xs_enginelist[0]);
+
+
+gboolean xs_initialize_emu_backend(XSEngineState *state, gint *preferred)
+{
+    gint engine;
+    gboolean initialized = FALSE;
+
+    XSDEBUG("trying emulator engine #%i...\n", *preferred);
+
+    for (engine = 0; engine < xs_nenginelist && !initialized; engine++)
+    {
+        if (xs_enginelist[engine].plrIdent == *preferred &&
+            xs_enginelist[engine].plrInit(state))
+        {
+            initialized = TRUE;
+            state->engine = &xs_enginelist[engine];
+        }
+    }
+
+    XSDEBUG("init#1: %s, %i\n", initialized ? "OK" : "FAILED", *preferred);
+    return initialized;
+}