comparison 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
comparison
equal deleted inserted replaced
871:d183ac29b879 872:b02f934d8224
1 /*
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
3
4 Backend handling
5
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
7 (C) Copyright 1999-2012 Tecnic Software productions (TNSP)
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License along
20 with this program; if not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23 #include "xs_backend.h"
24 #include "xs_config.h"
25
26 /* List of emulator engines
27 */
28 #ifdef HAVE_SIDPLAY1
29 # include "xs_sidplay1.h"
30 #endif
31 #ifdef HAVE_SIDPLAY2
32 # include "xs_sidplay2.h"
33 #endif
34 #ifdef HAVE_SIDPLAYFP
35 # include "xs_sidplayfp.h"
36 #endif
37
38
39 static XSEngine xs_enginelist[] =
40 {
41 #ifdef HAVE_SIDPLAY1
42 {
43 XS_ENG_SIDPLAY1,
44 xs_sidplay1_probe,
45 xs_sidplay1_init, xs_sidplay1_close,
46 xs_sidplay1_initsong, xs_sidplay1_fillbuffer,
47 xs_sidplay1_load, xs_sidplay1_delete,
48 xs_sidplay1_getinfo, xs_sidplay1_updateinfo,
49 NULL
50 },
51 #endif
52 #ifdef HAVE_SIDPLAY2
53 {
54 XS_ENG_SIDPLAY2,
55 xs_sidplay2_probe,
56 xs_sidplay2_init, xs_sidplay2_close,
57 xs_sidplay2_initsong, xs_sidplay2_fillbuffer,
58 xs_sidplay2_load, xs_sidplay2_delete,
59 xs_sidplay2_getinfo, xs_sidplay2_updateinfo,
60 xs_sidplay2_flush
61 },
62 #endif
63 #ifdef HAVE_SIDPLAYFP
64 {
65 XS_ENG_SIDPLAYFP,
66 xs_sidplayfp_probe,
67 xs_sidplayfp_init, xs_sidplayfp_close,
68 xs_sidplayfp_initsong, xs_sidplayfp_fillbuffer,
69 xs_sidplayfp_load, xs_sidplayfp_delete,
70 xs_sidplayfp_getinfo, xs_sidplayfp_updateinfo,
71 xs_sidplayfp_flush
72 },
73 #endif
74 };
75
76 static const gint xs_nenginelist = sizeof(xs_enginelist) / sizeof(xs_enginelist[0]);
77
78
79 gboolean xs_initialize_emu_backend(XSEngineState *state, gint *preferred)
80 {
81 gint engine;
82 gboolean initialized = FALSE;
83
84 XSDEBUG("trying emulator engine #%i...\n", *preferred);
85
86 for (engine = 0; engine < xs_nenginelist && !initialized; engine++)
87 {
88 if (xs_enginelist[engine].plrIdent == *preferred &&
89 xs_enginelist[engine].plrInit(state))
90 {
91 initialized = TRUE;
92 state->engine = &xs_enginelist[engine];
93 }
94 }
95
96 XSDEBUG("init#1: %s, %i\n", initialized ? "OK" : "FAILED", *preferred);
97 return initialized;
98 }