annotate src/xmms-sid.cc @ 64:d3bb914e3af3

Fixes for sidplay2 stuff
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 29 Jun 2003 01:17:01 +0000
parents 05220299c6e8
children bf7b647b3239
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 Main source file
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org>
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 This program is free software; you can redistribute it and/or modify
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 the Free Software Foundation; either version 2 of the License, or
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 (at your option) any later version.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 GNU General Public License for more details.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 along with this program; if not, write to the Free Software
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
22 extern "C" {
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
23 #include <pthread.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
24 #include <stdlib.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
25 #include <string.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
26 #include <stdio.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
27 #include <errno.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
28 #include <xmms/plugin.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
29 #include <xmms/util.h>
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
30 #include <xmms/titlestring.h>
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 #include "xmms-sid.h"
42
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
32 #include "xs_interface.h"
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
33 #include "xs_glade.h"
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
34 #include "xs_support.h"
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
35 #include "xs_config.h"
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
36 #include "xs_length.h"
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
37 }
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
38
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
39 #ifdef HAVE_SIDPLAY1
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 #include <sidplay/player.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 #include <sidplay/myendian.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 #include <sidplay/fformat.h>
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
43 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
44
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
45 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
46 #include <sidplay/sidplay2.h>
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
47 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
51 * Global variables
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
53 #ifdef HAVE_SIDPLAY1
63
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
54 static struct emuConfig xs_emuConf;
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
55 static emuEngine xs_emuEngine;
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
56 typedef sidTune t_xs_tune;
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
57 typedef struct sidTuneInfo t_xs_tuneinfo;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
58 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
59
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
60 #ifdef HAVE_SIDPLAY2
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
61 static struct sid2_config_t xs_emuConf;
63
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
62 static sidplay2 xs_emuEngine;
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
63 typedef SidTune t_xs_tune;
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
64 typedef struct SidTuneInfo t_xs_tuneinfo;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
65 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
66
63
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
67 static GtkWidget *xs_ctrlwin = NULL;
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
68 static pthread_t xs_decode_thread;
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
69 struct t_xs_cfg xs_cfg;
56
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
70
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
71 struct {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
72 gboolean isError, isPlaying, allowNext;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
73 gint currSong, nSongs;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
74 t_xs_tune *currTune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
75 gchar *currFilename;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
76 } xs_status;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
77
63
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
78 pthread_mutex_t xs_mutex = PTHREAD_MUTEX_INITIALIZER;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
80 gchar *xs_filetitle_get(gchar *, t_xs_tuneinfo *, gint);
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
81
42
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
82 /*
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
83 * Create sub-song control window
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
84 */
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
85 void xs_ctrlwin_open(void)
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
86 {
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
87 /* Create sub-song control window */
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
88 if (xs_ctrlwin != NULL)
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
89 {
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
90 if (xs_cfg.alwaysRaise)
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
91 gdk_window_raise(xs_ctrlwin->window);
42
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
92 return;
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
93 }
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
94
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
95 xs_ctrlwin = create_xs_ctrlwin();
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
96 gtk_widget_show(xs_ctrlwin);
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
97 }
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
98
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
101 * Initialize XMMS-SID
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 void xs_init(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
105 XSDEBUG("xs_init()\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
107 /* Initialize and get configuration */
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
108 memset(&xs_cfg, 0, sizeof(xs_cfg));
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
109
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
110 xs_read_configuration();
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
111
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
112 /* Initialize status */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
113 xs_status.isError = FALSE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
114 xs_status.isPlaying = FALSE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
115 xs_status.nSongs = 0;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
116 xs_status.currSong = 0;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
117 xs_status.allowNext = TRUE; // Initialize to TRUE to allow first song
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
118 xs_status.currTune = NULL;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
119 xs_status.currFilename = NULL;
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
120
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
121
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
122 /* Try to initialize libSIDPlay(s) */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
123 #ifdef HAVE_SIDPLAY1
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
124 if (!xs_emuEngine || !xs_emuEngine.verifyEndianess())
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
125 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
126 XSERR("Couldn't start SIDPlay1 emulator engine!\n");
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
127 return;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 }
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
129 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
131 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
132 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
134 /* Read song-length database */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
135 if (xs_cfg.songlenDBEnable)
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
136 if (xs_songlen_init() < 0)
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
137 {
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
138 XSERR("Error initializing song-length database!\n");
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
139 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
140
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
141 /* Initialize STIL structures */
42
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
142
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
143 // xs_ctrlwin_open();
42
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
144
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
145 // FIXME FIXME FIx ME
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
151 * Shut down XMMS-SID
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
152 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
153 void xs_close(void)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
155 XSDEBUG("shutting down...\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
157 /* Stop playing */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
158 xs_plugin_ip.stop();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
160 /* Shutdown libSIDPlay(s) */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
161 #ifdef HAVE_SIDPLAY1
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
162 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
163
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
164 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
165 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
166
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
167 /* Close sub-song control window */
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
168
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
169 /* Free allocated memory */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
170 xs_songlen_close();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
172 // FIXME FIXME: STIL-entries
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
177 * Check whether the given file is handled by this plugin
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
179 gint xs_is_our_file(char *fileName)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
181 char *pcExt;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
182
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
183 /* Check the filename */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
184 if (fileName == NULL)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
185 return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
186
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
187 /* Try to detect via libSIDPlay's detection routine, if required */
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
188 if (xs_cfg.detectMagic)
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
189 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
190 #ifdef HAVE_SIDPLAY1
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
191 t_xs_tune *testTune = new sidTune(fileName);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
192 if (!testTune) return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
193 if (!testTune->getStatus())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
194 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
195 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
196 return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
197 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
198
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
199 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
200 return TRUE;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
201 #endif
56
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
202
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
203 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
204 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
207 /* Detect just by checking filename extension */
56
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
208 pcExt = xs_strrchr(fileName, '.');
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
209 if (pcExt)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
210 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
211 pcExt++;
56
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
212 if (!g_strcasecmp(pcExt, "psid")) return TRUE;
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
213 if (!g_strcasecmp(pcExt, "sid")) return TRUE;
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
214 if (!g_strcasecmp(pcExt, "dat")) return TRUE;
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
215 if (!g_strcasecmp(pcExt, "inf")) return TRUE;
6a3ce7260ae1 Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
216 if (!g_strcasecmp(pcExt, "info")) return TRUE;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
218
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
219 return FALSE;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
224 * Main playing thread loop
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
226 static void *xs_play_loop(void *argPointer)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
228 /* Don't allow next song to be set yet */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
229 pthread_mutex_lock(&xs_mutex);
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
230 xs_status.allowNext = FALSE;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
231 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
232
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
233
49
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
234 /* Exit the playing thread */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
235 XSDEBUG("exiting thread, bye.\n");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
236 return NULL;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
241 * Start playing the given file
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
243 void xs_play_file(char *fileName)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
245 t_xs_tune *newTune;
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
246 t_xs_tuneinfo sidInf;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
247
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
248 XSDEBUG("request to load '%s'\n", fileName);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
249
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
250
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
251 /* Initialize audio output */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
252 XSDEBUG("opening audio output plugin...\n");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
253 if (!xs_plugin_ip.output->open_audio(
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
254 ((xs_cfg.fmtBitsPerSample == 16) ? FMT_S16_NE : FMT_U8), xs_cfg.fmtFrequency,
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
255 ((xs_cfg.fmtChannels == XS_CHN_MONO) ? 1 : 2)))
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
256 {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
257 XSERR("Couldn't open audio output plugin!\n");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
258 delete newTune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
259 return;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
260 }
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
261
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
263 /* Try to get the tune */
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
264 newTune = new t_xs_tune(fileName);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
265 if (newTune == NULL) return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
266
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
267 XSDEBUG("tune ok, configuring SIDPlay engine\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
269
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
270 #ifdef HAVE_SIDPLAY1
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
271 /* Get current configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
272 xs_emuEngine.getConfig(xs_emuConf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
273
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
274 /* Configure channels and stuff */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
275 switch (xs_cfg.fmtChannels) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
277 case XS_CHN_AUTOPAN:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 xs_emuConf.autoPanning = SIDEMU_CENTEREDAUTOPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 xs_emuConf.volumeControl = SIDEMU_FULLPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
283 case XS_CHN_STEREO:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
289 case XS_CHN_MONO:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 xs_emuConf.channels = SIDEMU_MONO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
295 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
296 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
297 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
298 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
299 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
301
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
302 /* Memory mode settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
303 switch (xs_cfg.memoryMode) {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
304 case XS_MPU_BANK_SWITCHING:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 xs_emuConf.memoryMode = MPU_BANK_SWITCHING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
308 case XS_MPU_TRANSPARENT_ROM:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 xs_emuConf.memoryMode = MPU_TRANSPARENT_ROM;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
312 case XS_MPU_PLAYSID_ENVIRONMENT:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 xs_emuConf.memoryMode = MPU_PLAYSID_ENVIRONMENT;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
316 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
317 XSERR("Internal: Invalid memoryMode setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
318 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
319 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
320 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
323 /* Clockspeed settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
324 switch (xs_cfg.clockSpeed) {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
325 case XS_CLOCK_PAL:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_PAL;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
329 case XS_CLOCK_NTSC:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_NTSC;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
333 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
334 XSERR("Internal: Invalid clockSpeed setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
335 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
336 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
337 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
338
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
339
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
340 /* Configure rest of the emulation */
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
341 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
342 xs_emuConf.frequency = xs_cfg.fmtFrequency;
49
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
343 #ifdef HAVE_UNSIGNEDPCM
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
344 xs_emuConf.sampleFormat = SIDEMU_UNSIGNED_PCM;
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
345 #else
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
346 xs_emuConf.sampleFormat = SIDEMU_SIGNED_PCM;
49
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
347 #endif
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
348 xs_emuConf.mos8580 = xs_cfg.mos8580;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
349 xs_emuConf.emulateFilter = xs_cfg.emulateFilters;
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
350 xs_emuConf.filterFs = xs_cfg.filterFs;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
351 xs_emuConf.filterFm = xs_cfg.filterFm;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
352 xs_emuConf.filterFt = xs_cfg.filterFt;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
353
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
354 /* Now set the emulator configuration */
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
355 xs_emuEngine.setConfig(xs_emuConf);
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
356 #endif
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
357
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
358
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
359
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
360 #ifdef HAVE_SIDPLAY2
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
361 /* Get current configuration */
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
362 xs_emuConf = xs_emuEngine.config();
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
363
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
364 /* Configure channels and stuff */
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
365 switch (xs_cfg.fmtChannels) {
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
366
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
367 case XS_CHN_AUTOPAN:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
368 xs_emuConf.playback = sid2_stereo;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
369 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
370
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
371 case XS_CHN_STEREO:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
372 xs_emuConf.playback = sid2_stereo;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
373 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
374
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
375 case XS_CHN_MONO:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
376 xs_emuConf.playback = sid2_mono;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
377 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
378
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
379 default:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
380 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n");
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
381 delete newTune;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
382 return;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
383 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
384
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
385
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
386 /* Memory mode settings */
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
387 switch (xs_cfg.memoryMode) {
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
388 case XS_MPU_BANK_SWITCHING:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
389 xs_emuConf.environment = sid2_envBS;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
390 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
391
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
392 case XS_MPU_TRANSPARENT_ROM:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
393 xs_emuConf.environment = sid2_envTP;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
394 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
395
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
396 case XS_MPU_PLAYSID_ENVIRONMENT:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
397 xs_emuConf.environment = sid2_envPS;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
398 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
399
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
400 case XS_MPU_REAL:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
401 xs_emuConf.environment = sid2_envR;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
402 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
403
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
404 default:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
405 XSERR("Internal: Invalid memoryMode setting. Possibly corrupted configuration file.\n");
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
406 delete newTune;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
407 return;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
408 }
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
409
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
410
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
411 /* Clockspeed settings */
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
412 switch (xs_cfg.clockSpeed) {
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
413 case XS_CLOCK_PAL:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
414 xs_emuConf.clockSpeed = xs_emuConf.clockDefault = SID2_CLOCK_PAL;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
415 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
416
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
417 case XS_CLOCK_NTSC:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
418 xs_emuConf.clockSpeed = xs_emuConf.clockDefault = SID2_CLOCK_NTSC;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
419 break;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
420
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
421 default:
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
422 XSERR("Internal: Invalid clockSpeed setting. Possibly corrupted configuration file.\n");
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
423 delete newTune;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
424 return;
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
425 }
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
426
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
427
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
428 /* Configure rest of the emulation */
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
429 xs_emuConf.precision = xs_cfg.fmtBitsPerSample;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
430 xs_emuConf.frequency = xs_cfg.fmtFrequency;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
431 xs_emuConf.clockForced = xs_cfg.forceSpeed;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
432 xs_emuConf.optimisation = (xs_cfg.optimiseLevel) ? 1 : 0;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
433 xs_emuConf.sidDefault = xs_emuConf.sidModel = (xs_cfg.mos8580) ? SID2_MOS8580 : SID2_MOS6581;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
434 xs_emuConf.sidSamples = TRUE; // FIXME FIX ME, make configurable!
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
435
49
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
436 #ifdef HAVE_UNSIGNEDPCM
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
437 #ifdef WORDS_BIGENDIAN
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
438 xs_emuConf.sampleFormat = SID2_BIG_UNSIGNED;
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
439 #else
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
440 xs_emuConf.sampleFormat = SID2_LITTLE_UNSIGNED;
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
441 #endif
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
442 #else
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
443 #ifdef WORDS_BIGENDIAN
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
444 xs_emuConf.sampleFormat = SID2_BIG_SIGNED;
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
445 #else
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
446 xs_emuConf.sampleFormat = SID2_LITTLE_SIGNED;
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
447 #endif
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
448 #endif
3518ca5c8b0f Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents: 45
diff changeset
449
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
450 /* Now set the emulator configuration */
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
451 xs_emuEngine.config(xs_emuConf);
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
452 #endif
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
453
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
454
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
455 /* Initialize status information */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
456 XSDEBUG("initializing and starting playing thread!\n");
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
457
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
458 newTune->getInfo(sidInf);
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
459
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
460 xs_status.isError = FALSE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
461 xs_status.isPlaying = TRUE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
462 xs_status.allowNext = TRUE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
463 xs_status.currSong = sidInf.startSong;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
464 xs_status.nSongs = sidInf.songs;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
465 xs_status.currTune = newTune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
466
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
467
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
468 /* Start the playing thread! */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
469 if (pthread_create(&xs_decode_thread, NULL, xs_play_loop, NULL) < 0)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
470 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
471 XSERR("Couldn't start playing thread! Possible reason reported by system: %s\n", strerror(errno));
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
472 delete newTune;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
474
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
475 /* Exit */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
476 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
477
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
479 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
480 * Stop playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
481 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 void xs_stop(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
483 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
484 /* If playing, stop. */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
485 XSDEBUG("request to stop.\n");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
486
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
487 if (xs_status.isPlaying)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
489 XSDEBUG("stopping...\n");
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
490 pthread_mutex_lock(&xs_mutex);
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
491 xs_status.isPlaying = 0;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
492 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
493
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
494 pthread_join(xs_decode_thread, NULL);
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
495
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
496 xs_plugin_ip.output->close_audio();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
500
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
502 * Pause the playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
504 void xs_pause(short pauseState)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505 {
24
271be59be975 Lots of changes
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
506 xs_plugin_ip.output->pause(pauseState);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
511 * Set the time-seek position
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
512 * (the playing thread will do the "seeking" aka song-change)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
514 void xs_seek(int iTime)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
516 #ifdef HAVE_SONG_POSITION
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
517 pthread_mutex_lock(&xs_mutex);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
518
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
519 if ((iTime > 0) && (iTime <= xs_status.nSongs) && xs_status.isPlaying)
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
520 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
521 xs_status.currSong = iTime;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522 }
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
523
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
524 pthread_mutex_unlock(&xs_mutex);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
525 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
528
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
529 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
530 * Return the playing "position/time"
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
531 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532 int xs_get_time(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
533 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
534 pthread_mutex_lock(&xs_mutex);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
535 if (xs_status.isError)
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
536 return -2;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
537
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
538 if (!xs_status.isPlaying)
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
539 return -1;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
540
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
541 #ifdef HAVE_SONG_POSITION
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
542 set_song_position(xs_status.currSong, 1, xs_status.nSongs);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
543 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
545 pthread_mutex_unlock(&xs_mutex);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
546
24
271be59be975 Lots of changes
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
547 return xs_plugin_ip.output->output_time();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
548 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
550
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
551 /*
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
552 * Return song information
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
553 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
554 void xs_get_song_info(char *songFilename, char **songTitle, int *songLength)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
555 {
44
90cd38b28a72 Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents: 42
diff changeset
556 t_xs_tuneinfo sidInf;
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
557 t_xs_tune *testTune = new t_xs_tune(songFilename);
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
558 gint tmpInt;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
559
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
560 /* Check if the tune exists and is readable */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
561 if (!testTune) return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
562 if (!testTune->getStatus())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
563 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
564 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
565 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
566 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
567
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
568 /* Get general tune information */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
569 testTune->getInfo(sidInf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
570 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
571
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
572 /* Get titlestring */
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
573 *songTitle = xs_filetitle_get(songFilename, &sidInf, sidInf.startSong);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
574
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
575 /* Get song length (in milliseconds), negative if no known length */
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
576 tmpInt = xs_songlen_get(songFilename, sidInf.startSong);
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
577 if (tmpInt >= 0)
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
578 *songLength = (tmpInt * 1000);
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
579 else
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
580 *songLength = -1;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
581 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
582
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
583
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
584 /*
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
585 * Create the SID-tune description string from the tune's information
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
586 * formatted by the user-specified format-string.
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
587 */
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
588 gchar *xs_filetitle_get(gchar *pcFilename, t_xs_tuneinfo *pfInfo, gint iSubTune)
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
589 {
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
590 gint j, iLength;
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
591 gchar *pcStr, *pcResult;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
592 #ifdef HAVE_XMMSEXTRA
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
593 TitleInput *ptInput;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
594 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
595
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
596 // FIXME FIXME: get STIL-info
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
597
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
598 /* Check the info strings */
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
599 if (pfInfo->numberOfInfoStrings < 3)
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
600 {
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
601 if (pfInfo->numberOfInfoStrings < 1)
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
602 return 0;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
603
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
604 return g_strdup(pfInfo->infoString[0]);
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
605 }
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
606
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
607 #ifdef HAVE_XMMSEXTRA
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
608 /* Check if the titles are overridden or not */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
609 if (!xs_cfg.titleOverride)
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
610 {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
611 /* Use generic XMMS titles */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
612 /* XMMS_NEW_TITLEINPUT(ptInput);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
613 * We duplicate and add typecast to the code here due to XMMS's braindead headers
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
614 */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
615 ptInput = (TitleInput *) g_malloc0(sizeof(TitleInput));
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
616 ptInput->__size = XMMS_TITLEINPUT_SIZE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
617 ptInput->__version = XMMS_TITLEINPUT_VERSION;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
618
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
619 /* Create the input fields */
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
620 ptInput->file_name = pfInfo->dataFileName;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
621 ptInput->file_ext = g_strdup("sid");
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
622 ptInput->file_path = pfInfo->path;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
623
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
624 ptInput->track_name = pfInfo->infoString[0];
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
625 ptInput->track_number = iSubTune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
626 ptInput->album_name = NULL;
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
627 ptInput->performer = pfInfo->infoString[1];
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
628 ptInput->date = g_strdup((pfInfo->sidModel == SIDTUNE_SIDMODEL_6581) ? "6581" : "8580");
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
629
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
630 ptInput->year = 0;
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
631 ptInput->genre = g_strdup("SID-tune");
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
632 ptInput->comment = pfInfo->infoString[2];
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
633
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
634 /* Create the string */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
635 pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
636
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
637 /* Dispose all allocated memory */
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
638 g_free(ptInput->file_ext);
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
639 g_free(ptInput->date);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
640 g_free(ptInput->genre);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
641 g_free(ptInput);
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
642 }
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
643 else
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
644 #endif
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
645 {
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
646 /* Estimate the length of the string */
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
647 pcStr = xs_cfg.titleFormat;
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
648 iLength = 0;
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
649 while (*pcStr)
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
650 {
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
651 if (*pcStr == '%')
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
652 {
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
653 switch (*(++pcStr)) {
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
654 case '1': iLength += strlen(pfInfo->infoString[1]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
655 case '2': iLength += strlen(pfInfo->infoString[0]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
656 case '3': iLength += strlen(pfInfo->infoString[2]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
657 case '4': iLength += strlen(pfInfo->formatString); break;
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
658 case '%': iLength++;
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
659 }
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
660 } else
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
661 iLength++;
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
662 }
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
663
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
664 /* Allocate memory */
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
665 pcResult = (gchar *) g_malloc(iLength + 2);
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
666 if (pcResult == NULL)
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
667 return g_strdup(pfInfo->infoString[0]);
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
668
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
669 /* Create the string */
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
670 pcStr = xs_cfg.titleFormat;
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
671 j = 0;
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
672 while (*pcStr)
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
673 {
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
674 if (*pcStr == '%')
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
675 {
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
676 switch (*(++pcStr)) {
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
677 case '1': xs_strpcat(pcResult, &j, pfInfo->infoString[1]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
678 case '2': xs_strpcat(pcResult, &j, pfInfo->infoString[0]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
679 case '3': xs_strpcat(pcResult, &j, pfInfo->infoString[2]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
680 case '4': xs_strpcat(pcResult, &j, pfInfo->formatString); break;
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
681 case '%': pcResult[j++] = '%'; break;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
682 }
57
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
683 } else
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
684 pcResult[j++] = *pcStr;
85811bcd049e Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
685 }
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
686
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
687 pcResult[j] = 0;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
688 }
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
689
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
690 return pcResult;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
691 }
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
692