Mercurial > hg > xmms-sid
annotate src/xmms-sid.cc @ 69:bf6a524cf7ca dev-0-8-0a1
Fixes, cleanups, etc.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 30 Jun 2003 17:16:02 +0000 |
parents | bf7b647b3239 |
children |
rev | line source |
---|---|
1 | 1 /* |
5 | 2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
1 | 3 |
4 Main source file | |
5 | |
5 | 6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org> |
1 | 7 |
8 This program is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation; either version 2 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
19 along with this program; if not, write to the Free Software | |
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
21 */ | |
28 | 22 #include <pthread.h> |
23 #include <stdlib.h> | |
24 #include <string.h> | |
25 #include <stdio.h> | |
26 #include <errno.h> | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
27 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
28 extern "C" { |
28 | 29 #include <xmms/plugin.h> |
30 #include <xmms/util.h> | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
31 #include <xmms/titlestring.h> |
42 | 32 #include "xs_interface.h" |
33 #include "xs_glade.h" | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
34 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
35 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
36 #include "xmms-sid.h" |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
37 #include "xs_support.h" |
22 | 38 #include "xs_config.h" |
39 #include "xs_length.h" | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
40 |
28 | 41 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
42 #ifdef HAVE_SIDPLAY1 |
1 | 43 #include <sidplay/player.h> |
44 #include <sidplay/myendian.h> | |
45 #include <sidplay/fformat.h> | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
46 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
47 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
48 #ifdef HAVE_SIDPLAY2 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
49 #include <sidplay/sidplay2.h> |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
50 #endif |
1 | 51 |
52 | |
53 /* | |
28 | 54 * Global variables |
1 | 55 */ |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
56 #ifdef HAVE_SIDPLAY1 |
63 | 57 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
|
58 typedef struct sidTuneInfo t_xs_tuneinfo; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
59 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
60 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
61 #ifdef HAVE_SIDPLAY2 |
63 | 62 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
|
63 typedef struct SidTuneInfo t_xs_tuneinfo; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
64 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
65 |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
66 #ifdef HAVE_SIDPLAY1 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
67 struct emuConfig xs_emuConf; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
68 emuEngine xs_emuEngine; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
69 #endif |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
70 #ifdef HAVE_SIDPLAY2 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
71 struct sid2_config_t xs_emuConf; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
72 sidplay2 xs_emuEngine; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
73 #endif |
56
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
74 |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
75 typedef struct { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
76 gboolean isError, isPlaying, allowNext; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
77 gint currSong, nSongs; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
78 t_xs_tune *currTune; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
79 gchar *currFileName; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
80 } t_xs_status; |
5 | 81 |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
82 static GtkWidget *xs_ctrlwin = NULL; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
83 static pthread_t xs_decode_thread; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
84 static pthread_mutex_t xs_mutex = PTHREAD_MUTEX_INITIALIZER; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
85 struct t_xs_cfg xs_cfg; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
86 t_xs_status xs_status; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
87 |
1 | 88 |
64 | 89 gchar *xs_filetitle_get(gchar *, t_xs_tuneinfo *, gint); |
90 | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
91 |
42 | 92 /* |
93 * Create sub-song control window | |
94 */ | |
95 void xs_ctrlwin_open(void) | |
96 { | |
97 /* Create sub-song control window */ | |
98 if (xs_ctrlwin != NULL) | |
99 { | |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
100 if (xs_cfg.alwaysRaise) |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
101 gdk_window_raise(xs_ctrlwin->window); |
42 | 102 return; |
103 } | |
104 | |
105 xs_ctrlwin = create_xs_ctrlwin(); | |
106 gtk_widget_show(xs_ctrlwin); | |
107 } | |
108 | |
1 | 109 |
110 /* | |
5 | 111 * Initialize XMMS-SID |
1 | 112 */ |
113 void xs_init(void) | |
114 { | |
5 | 115 XSDEBUG("xs_init()\n"); |
1 | 116 |
28 | 117 /* Initialize and get configuration */ |
118 memset(&xs_cfg, 0, sizeof(xs_cfg)); | |
119 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
120 xs_read_configuration(); |
28 | 121 |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
122 /* Initialize status */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
123 memset(&xs_status, 0, sizeof(xs_status)); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
124 xs_status.allowNext = TRUE; // Initialize to TRUE to allow first song |
28 | 125 |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
126 /* Try to initialize emulator engine(s) */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
127 XSDEBUG("initializing emulator engine(s)...\n"); |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
128 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
129 #ifdef HAVE_SIDPLAY1 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
130 if (!xs_emuEngine || !xs_emuEngine.verifyEndianess()) |
5 | 131 { |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
132 XSERR("Couldn't initialize SIDPlay1 emulator engine!\n"); |
5 | 133 return; |
1 | 134 } |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
135 #endif |
1 | 136 |
22 | 137 /* Read song-length database */ |
69 | 138 if (xs_cfg.songlenDBEnable && (xs_songlen_init() < 0)) |
22 | 139 { |
140 XSERR("Error initializing song-length database!\n"); | |
141 } | |
5 | 142 |
143 /* Initialize STIL structures */ | |
42 | 144 |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
145 // xs_ctrlwin_open(); |
42 | 146 |
5 | 147 // FIXME FIXME FIx ME |
1 | 148 |
69 | 149 XSDEBUG("OK\n"); |
1 | 150 } |
151 | |
152 | |
153 /* | |
5 | 154 * Shut down XMMS-SID |
155 */ | |
156 void xs_close(void) | |
1 | 157 { |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
158 XSDEBUG("xs_close(): shutting down...\n"); |
1 | 159 |
5 | 160 /* Stop playing */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
161 xs_stop(); |
1 | 162 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
163 /* Shutdown libSIDPlay(s) */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
164 #ifdef HAVE_SIDPLAY1 |
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 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
167 #ifdef HAVE_SIDPLAY2 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
168 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
169 |
28 | 170 /* Close sub-song control window */ |
171 | |
5 | 172 /* Free allocated memory */ |
22 | 173 xs_songlen_close(); |
1 | 174 |
28 | 175 // FIXME FIXME: STIL-entries |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
176 XSDEBUG("shutdown finished.\n"); |
1 | 177 } |
178 | |
179 | |
180 /* | |
28 | 181 * Check whether the given file is handled by this plugin |
1 | 182 */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
183 gint xs_is_our_file(gchar *pcFileName) |
1 | 184 { |
5 | 185 char *pcExt; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
186 t_xs_tune *testTune; |
5 | 187 |
188 /* Check the filename */ | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
189 if (pcFileName == NULL) |
5 | 190 return FALSE; |
191 | |
192 /* Try to detect via libSIDPlay's detection routine, if required */ | |
28 | 193 if (xs_cfg.detectMagic) |
194 { | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
195 testTune = new t_xs_tune(pcFileName); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
196 if (testTune == NULL) return FALSE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
197 if (testTune->getStatus()) |
5 | 198 { |
199 delete testTune; | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
200 return TRUE; |
5 | 201 } |
202 | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
203 /* We DON'T fall back to filename extension checking ... */ |
5 | 204 delete testTune; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
205 return FALSE; |
1 | 206 } |
207 | |
5 | 208 /* Detect just by checking filename extension */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
209 pcExt = xs_strrchr(pcFileName, '.'); |
5 | 210 if (pcExt) |
211 { | |
212 pcExt++; | |
56
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
213 if (!g_strcasecmp(pcExt, "psid")) return TRUE; |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
214 if (!g_strcasecmp(pcExt, "sid")) return TRUE; |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
215 if (!g_strcasecmp(pcExt, "dat")) return TRUE; |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
216 if (!g_strcasecmp(pcExt, "inf")) return TRUE; |
6a3ce7260ae1
Changed some standard functions to glib ones
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
217 if (!g_strcasecmp(pcExt, "info")) return TRUE; |
1 | 218 } |
5 | 219 |
220 return FALSE; | |
1 | 221 } |
222 | |
223 | |
224 /* | |
28 | 225 * Main playing thread loop |
1 | 226 */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
227 void *xs_play_loop(void *argPointer) |
1 | 228 { |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
229 t_xs_status myStatus; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
230 t_xs_tuneinfo tuneInfo; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
231 gboolean audioOpen; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
232 gint audioFreq, audioChannels, songLength; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
233 enum AFormat audioFmt; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
234 gchar audioBuffer[XS_BUFSIZE]; |
69 | 235 gchar *tmpStr; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
236 |
69 | 237 |
238 pthread_mutex_lock(&xs_mutex); | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
239 XSDEBUG("entering play thread\n"); |
69 | 240 |
241 /* No idea, if this is really required here, but better be | |
242 * careful since we're dealing with EVIL threads ... | |
243 */ | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
244 if (!xs_status.allowNext) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
245 { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
246 pthread_mutex_unlock(&xs_mutex); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
247 pthread_exit(NULL); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
248 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
249 |
5 | 250 /* Don't allow next song to be set yet */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
251 xs_status.allowNext = FALSE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
252 xs_status.isPlaying = TRUE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
253 memcpy(&myStatus, &xs_status, sizeof(t_xs_status)); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
254 pthread_mutex_unlock(&xs_mutex); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
255 |
69 | 256 |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
257 /* Copy and check audio options here (they might change in config while running) */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
258 #ifdef HAVE_UNSIGNEDPCM |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
259 audioFmt = (xs_cfg.fmtBitsPerSample == XS_RES_16BIT) ? FMT_U16_NE : FMT_U8; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
260 #else |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
261 audioFmt = (xs_cfg.fmtBitsPerSample == XS_RES_16BIT) ? FMT_S16_NE : FMT_S8; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
262 #endif |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
263 audioFreq = xs_cfg.fmtFrequency; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
264 audioChannels = (xs_cfg.fmtChannels == XS_CHN_MONO) ? 1 : 2; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
265 audioOpen = FALSE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
266 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
267 /* |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
268 * Main player loop: while not stopped, loop here - play subtunes |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
269 */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
270 while (xs_status.isPlaying) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
271 { |
5 | 272 pthread_mutex_lock(&xs_mutex); |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
273 myStatus.currSong = xs_status.currSong; |
69 | 274 myStatus.isPlaying = TRUE; |
5 | 275 pthread_mutex_unlock(&xs_mutex); |
276 | |
69 | 277 XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); |
278 | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
279 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
280 /* Get song length for current subtune */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
281 songLength = xs_songlen_get(myStatus.currFileName, myStatus.currSong); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
282 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
283 /* Initialize song */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
284 #ifdef HAVE_SIDPLAY1 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
285 if ((myStatus.currTune == NULL) || !myStatus.currTune->getStatus() || |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
286 !sidEmuInitializeSong(xs_emuEngine, *myStatus.currTune, myStatus.currSong)) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
287 #endif |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
288 #ifdef HAVE_SIDPLAY2 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
289 if () |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
290 #endif |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
291 { |
69 | 292 XSERR("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n", |
293 myStatus.currFileName, myStatus.currSong); | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
294 goto err_exit; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
295 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
296 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
297 myStatus.currTune->getInfo(tuneInfo); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
298 |
69 | 299 |
300 /* Set information for current sub-tune */ | |
301 tmpStr = xs_filetitle_get(myStatus.currFileName, &tuneInfo, myStatus.currSong); | |
302 | |
303 xs_plugin_ip.set_info(tmpStr, (songLength > 0) ? songLength * 1000 : -1, | |
304 1000 * (tuneInfo.songSpeed ? tuneInfo.songSpeed : (tuneInfo.clockSpeed == SIDTUNE_CLOCK_NTSC) ? 60 : 50), | |
305 audioFreq, audioChannels); | |
306 g_free(tmpStr); | |
307 | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
308 /* Open the audio output */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
309 if (!xs_plugin_ip.output->open_audio(audioFmt, audioFreq, audioChannels)) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
310 { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
311 XSERR("Couldn't open XMMS audio output!\n"); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
312 pthread_mutex_lock(&xs_mutex); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
313 xs_status.isError = TRUE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
314 pthread_mutex_unlock(&xs_mutex); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
315 goto err_exit; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
316 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
317 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
318 audioOpen = TRUE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
319 |
69 | 320 /* |
321 * Play the subtune | |
322 */ | |
323 while (xs_status.isPlaying && myStatus.isPlaying && (xs_status.currSong == myStatus.currSong)) | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
324 { |
69 | 325 /* Render audio data */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
326 #ifdef HAVE_SIDPLAY1 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
327 sidEmuFillBuffer(xs_emuEngine, *myStatus.currTune, audioBuffer, XS_BUFSIZE); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
328 #endif |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
329 #ifdef HAVE_SIDPLAY2 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
330 #endif |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
331 |
69 | 332 /* I <3 visualice/haujobb */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
333 xs_plugin_ip.add_vis_pcm( |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
334 xs_plugin_ip.output->written_time(), |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
335 audioFmt, audioChannels, XS_BUFSIZE, audioBuffer); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
336 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
337 /* Wait a little */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
338 while (xs_status.isPlaying && |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
339 (xs_status.currSong == myStatus.currSong) && |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
340 (xs_plugin_ip.output->buffer_free() < XS_BUFSIZE)) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
341 xmms_usleep(10000); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
342 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
343 /* Output audio */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
344 if (xs_status.isPlaying && (xs_status.currSong == myStatus.currSong)) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
345 xs_plugin_ip.output->write_audio(audioBuffer, XS_BUFSIZE); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
346 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
347 /* Check if we have played enough */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
348 if (xs_cfg.playMaxTimeEnable) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
349 { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
350 if (xs_cfg.playMaxTimeUnknown) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
351 { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
352 if ((songLength == -1) && |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
353 (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000))) |
69 | 354 myStatus.isPlaying = FALSE; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
355 } else { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
356 if (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000)) |
69 | 357 myStatus.isPlaying = FALSE; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
358 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
359 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
360 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
361 if (songLength > 0) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
362 { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
363 if (xs_plugin_ip.output->output_time() >= (songLength * 1000)) |
69 | 364 myStatus.isPlaying = FALSE; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
365 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
366 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
367 |
69 | 368 XSDEBUG("subtune ended/stopped\n"); |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
369 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
370 /* Close audio */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
371 if (audioOpen) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
372 { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
373 XSDEBUG("close audio #1\n"); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
374 xs_plugin_ip.output->close_audio(); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
375 audioOpen = FALSE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
376 } |
69 | 377 |
378 /* Now determine if we continue by selecting other subtune or something */ | |
379 if (!myStatus.isPlaying) xs_status.isPlaying = FALSE; | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
380 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
381 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
382 /* When exiting, delete data */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
383 err_exit: |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
384 pthread_mutex_lock(&xs_mutex); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
385 xs_status.isPlaying = FALSE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
386 pthread_mutex_unlock(&xs_mutex); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
387 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
388 if (audioOpen) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
389 { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
390 XSDEBUG("close audio #2\n"); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
391 xs_plugin_ip.output->close_audio(); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
392 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
393 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
394 if (myStatus.currTune != NULL) |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
395 { |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
396 delete myStatus.currTune; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
397 myStatus.currTune = NULL; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
398 } |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
399 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
400 g_free(myStatus.currFileName); |
5 | 401 |
49
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
402 /* Exit the playing thread */ |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
403 XSDEBUG("exiting thread, bye.\n"); |
69 | 404 |
405 /* Last thing we do is set allowNext to TRUE to flag | |
406 * that we have ended all action in the thread | |
407 */ | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
408 pthread_mutex_lock(&xs_mutex); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
409 xs_status.allowNext = TRUE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
410 pthread_mutex_unlock(&xs_mutex); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
411 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
412 pthread_exit(NULL); |
1 | 413 } |
414 | |
415 | |
416 /* | |
28 | 417 * Start playing the given file |
1 | 418 */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
419 void xs_play_file(char *pcFileName) |
1 | 420 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
421 t_xs_tune *newTune; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
422 t_xs_tuneinfo tuneInfo; |
5 | 423 |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
424 /* Can we set the next tune? */ |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
425 XSDEBUG("request to play '%s'\n", pcFileName); |
1 | 426 |
5 | 427 /* Try to get the tune */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
428 newTune = new t_xs_tune(pcFileName); |
5 | 429 if (newTune == NULL) return; |
430 | |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
431 #ifdef HAVE_SIDPLAY1 |
5 | 432 /* Get current configuration */ |
433 xs_emuEngine.getConfig(xs_emuConf); | |
434 | |
435 /* Configure channels and stuff */ | |
436 switch (xs_cfg.fmtChannels) { | |
1 | 437 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
438 case XS_CHN_AUTOPAN: |
1 | 439 xs_emuConf.channels = SIDEMU_STEREO; |
440 xs_emuConf.autoPanning = SIDEMU_CENTEREDAUTOPANNING; | |
441 xs_emuConf.volumeControl = SIDEMU_FULLPANNING; | |
442 break; | |
443 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
444 case XS_CHN_STEREO: |
1 | 445 xs_emuConf.channels = SIDEMU_STEREO; |
446 xs_emuConf.autoPanning = SIDEMU_NONE; | |
447 xs_emuConf.volumeControl = SIDEMU_NONE; | |
448 break; | |
449 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
450 case XS_CHN_MONO: |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
451 default: |
1 | 452 xs_emuConf.channels = SIDEMU_MONO; |
453 xs_emuConf.autoPanning = SIDEMU_NONE; | |
454 xs_emuConf.volumeControl = SIDEMU_NONE; | |
455 break; | |
5 | 456 } |
1 | 457 |
28 | 458 |
5 | 459 /* Memory mode settings */ |
460 switch (xs_cfg.memoryMode) { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
461 case XS_MPU_BANK_SWITCHING: |
1 | 462 xs_emuConf.memoryMode = MPU_BANK_SWITCHING; |
463 break; | |
464 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
465 case XS_MPU_TRANSPARENT_ROM: |
1 | 466 xs_emuConf.memoryMode = MPU_TRANSPARENT_ROM; |
467 break; | |
468 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
469 case XS_MPU_PLAYSID_ENVIRONMENT: |
1 | 470 xs_emuConf.memoryMode = MPU_PLAYSID_ENVIRONMENT; |
471 break; | |
472 | |
5 | 473 default: |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
474 xs_emuConf.memoryMode = MPU_BANK_SWITCHING; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
475 break; |
5 | 476 } |
1 | 477 |
478 | |
5 | 479 /* Clockspeed settings */ |
480 switch (xs_cfg.clockSpeed) { | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
481 case XS_CLOCK_NTSC: |
1 | 482 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_NTSC; |
483 break; | |
484 | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
485 case XS_CLOCK_PAL: |
5 | 486 default: |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
487 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_PAL; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
488 break; |
5 | 489 } |
490 | |
491 | |
492 /* Configure rest of the emulation */ | |
28 | 493 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample; |
494 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
|
495 #ifdef HAVE_UNSIGNEDPCM |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
496 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
|
497 #else |
28 | 498 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
|
499 #endif |
28 | 500 xs_emuConf.mos8580 = xs_cfg.mos8580; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
501 xs_emuConf.emulateFilter = xs_cfg.emulateFilters; |
28 | 502 xs_emuConf.filterFs = xs_cfg.filterFs; |
503 xs_emuConf.filterFm = xs_cfg.filterFm; | |
504 xs_emuConf.filterFt = xs_cfg.filterFt; | |
5 | 505 |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
506 /* Now set the emulator configuration */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
507 xs_emuEngine.setConfig(xs_emuConf); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
508 #endif |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
509 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
510 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
511 #ifdef HAVE_SIDPLAY2 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
512 /* Get current configuration */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
513 xs_emuConf = xs_emuEngine.config(); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
514 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
515 /* Configure channels and stuff */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
516 switch (xs_cfg.fmtChannels) { |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
517 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
518 case XS_CHN_AUTOPAN: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
519 xs_emuConf.playback = sid2_stereo; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
520 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
521 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
522 case XS_CHN_STEREO: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
523 xs_emuConf.playback = sid2_stereo; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
524 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
525 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
526 case XS_CHN_MONO: |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
527 default: |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
528 xs_emuConf.playback = sid2_mono; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
529 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
530 } |
5 | 531 |
28 | 532 |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
533 /* Memory mode settings */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
534 switch (xs_cfg.memoryMode) { |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
535 case XS_MPU_BANK_SWITCHING: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
536 xs_emuConf.environment = sid2_envBS; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
537 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
538 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
539 case XS_MPU_TRANSPARENT_ROM: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
540 xs_emuConf.environment = sid2_envTP; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
541 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
542 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
543 case XS_MPU_PLAYSID_ENVIRONMENT: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
544 xs_emuConf.environment = sid2_envPS; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
545 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
546 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
547 case XS_MPU_REAL: |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
548 default: |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
549 xs_emuConf.environment = sid2_envR; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
550 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
551 } |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
552 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
553 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
554 /* Clockspeed settings */ |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
555 switch (xs_cfg.clockSpeed) { |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
556 case XS_CLOCK_NTSC: |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
557 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
|
558 break; |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
559 |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
560 case XS_CLOCK_PAL: |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
561 default: |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
562 xs_emuConf.clockSpeed = xs_emuConf.clockDefault = SID2_CLOCK_PAL; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
563 break; |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
564 } |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
565 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
566 |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
567 /* Configure rest of the emulation */ |
64 | 568 xs_emuConf.precision = xs_cfg.fmtBitsPerSample; |
569 xs_emuConf.frequency = xs_cfg.fmtFrequency; | |
570 xs_emuConf.clockForced = xs_cfg.forceSpeed; | |
571 xs_emuConf.optimisation = (xs_cfg.optimiseLevel) ? 1 : 0; | |
572 xs_emuConf.sidDefault = xs_emuConf.sidModel = (xs_cfg.mos8580) ? SID2_MOS8580 : SID2_MOS6581; | |
573 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
|
574 |
49
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
575 #ifdef HAVE_UNSIGNEDPCM |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
576 #ifdef WORDS_BIGENDIAN |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
577 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
|
578 #else |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
579 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
|
580 #endif |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
581 #else |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
582 #ifdef WORDS_BIGENDIAN |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
583 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
|
584 #else |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
585 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
|
586 #endif |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
587 #endif |
3518ca5c8b0f
Support for compile-time big/little-endian optimizations in audio output
Matti Hamalainen <ccr@tnsp.org>
parents:
45
diff
changeset
|
588 |
5 | 589 /* 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
|
590 xs_emuEngine.config(xs_emuConf); |
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
591 #endif |
5 | 592 |
28 | 593 |
594 /* Initialize status information */ | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
595 XSDEBUG("starting playing thread!\n"); |
28 | 596 |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
597 newTune->getInfo(tuneInfo); |
44
90cd38b28a72
Various fixes and transmogrifying for dual emulation engine environment
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
598 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
599 xs_status.isPlaying = TRUE; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
600 xs_status.isError = FALSE; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
601 xs_status.currSong = tuneInfo.startSong; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
602 xs_status.nSongs = tuneInfo.songs; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
603 xs_status.currTune = newTune; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
604 xs_status.currFileName = g_strdup(pcFileName); |
5 | 605 |
606 /* Start the playing thread! */ | |
607 if (pthread_create(&xs_decode_thread, NULL, xs_play_loop, NULL) < 0) | |
608 { | |
609 XSERR("Couldn't start playing thread! Possible reason reported by system: %s\n", strerror(errno)); | |
610 delete newTune; | |
1 | 611 } |
612 | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
613 XSDEBUG("systems should be up?\n"); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
614 |
5 | 615 /* Exit */ |
1 | 616 } |
617 | |
618 | |
619 /* | |
5 | 620 * Stop playing |
1 | 621 */ |
622 void xs_stop(void) | |
623 { | |
5 | 624 /* If playing, stop. */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
625 XSDEBUG("STOP_REQ\n"); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
626 if (xs_status.isPlaying || !xs_status.allowNext) |
1 | 627 { |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
628 XSDEBUG("stopping...\n"); |
5 | 629 pthread_mutex_lock(&xs_mutex); |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
630 xs_status.isPlaying = FALSE; |
5 | 631 pthread_mutex_unlock(&xs_mutex); |
632 pthread_join(xs_decode_thread, NULL); | |
1 | 633 } |
634 } | |
635 | |
636 | |
637 /* | |
5 | 638 * Pause the playing |
1 | 639 */ |
5 | 640 void xs_pause(short pauseState) |
1 | 641 { |
24 | 642 xs_plugin_ip.output->pause(pauseState); |
1 | 643 } |
644 | |
645 | |
646 /* | |
5 | 647 * Set the time-seek position |
648 * (the playing thread will do the "seeking" aka song-change) | |
1 | 649 */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
650 void xs_seek(gint iTime) |
1 | 651 { |
69 | 652 /* If we have song-position patch, check settings */ |
5 | 653 #ifdef HAVE_SONG_POSITION |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
654 pthread_mutex_lock(&xs_mutex); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
655 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
656 if ((iTime > 0) && (iTime <= xs_status.nSongs) && xs_status.isPlaying) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
657 xs_status.currSong = iTime; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
658 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
659 pthread_mutex_unlock(&xs_mutex); |
5 | 660 #endif |
1 | 661 } |
662 | |
663 | |
664 /* | |
5 | 665 * Return the playing "position/time" |
1 | 666 */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
667 gint xs_get_time(void) |
1 | 668 { |
69 | 669 /* If errorflag is set, return -2 to signal it to XMMS's idle callback */ |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
670 if (xs_status.isError) |
5 | 671 return -2; |
672 | |
69 | 673 /* If tune has ended, return -1 */ |
674 if (xs_status.allowNext && !xs_status.isPlaying) | |
5 | 675 return -1; |
1 | 676 |
69 | 677 /* Obsolete? */ |
5 | 678 #ifdef HAVE_SONG_POSITION |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
679 pthread_mutex_lock(&xs_mutex); |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
680 set_song_position(xs_status.currSong, 1, xs_status.nSongs); |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
681 pthread_mutex_unlock(&xs_mutex); |
5 | 682 #endif |
1 | 683 |
69 | 684 /* Else, return output time reported by audio output plugin */ |
24 | 685 return xs_plugin_ip.output->output_time(); |
1 | 686 } |
687 | |
688 | |
5 | 689 /* |
690 * Return song information | |
691 */ | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
692 void xs_get_song_info(gchar *songFileName, gchar **songTitle, gint *songLength) |
5 | 693 { |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
694 t_xs_tuneinfo tuneInfo; |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
695 t_xs_tune *testTune; |
64 | 696 gint tmpInt; |
5 | 697 |
698 /* Check if the tune exists and is readable */ | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
699 testTune = new t_xs_tune(songFileName); |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
700 if (testTune == NULL) return; |
5 | 701 if (!testTune->getStatus()) |
702 { | |
703 delete testTune; | |
704 return; | |
705 } | |
706 | |
707 /* Get general tune information */ | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
708 testTune->getInfo(tuneInfo); |
5 | 709 delete testTune; |
710 | |
711 /* Get titlestring */ | |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
712 *songTitle = xs_filetitle_get(songFileName, &tuneInfo, tuneInfo.startSong); |
5 | 713 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
714 /* Get song length (in milliseconds), negative if no known length */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
715 tmpInt = xs_songlen_get(songFileName, tuneInfo.startSong); |
64 | 716 if (tmpInt >= 0) |
717 *songLength = (tmpInt * 1000); | |
718 else | |
719 *songLength = -1; | |
5 | 720 } |
721 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
722 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
723 /* |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
724 * 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
|
725 * formatted by the user-specified format-string. |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
726 */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
727 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
|
728 { |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
729 gint j, iLength; |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
730 gchar *pcStr, *pcResult; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
731 #ifdef HAVE_XMMSEXTRA |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
732 TitleInput *ptInput; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
733 #endif |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
734 |
69 | 735 /* FIXME FIXME: get STIL-information */ |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
736 |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
737 |
64 | 738 /* Check the info strings */ |
739 if (pfInfo->numberOfInfoStrings < 3) | |
740 { | |
741 if (pfInfo->numberOfInfoStrings < 1) | |
742 return 0; | |
743 | |
744 return g_strdup(pfInfo->infoString[0]); | |
745 } | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
746 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
747 #ifdef HAVE_XMMSEXTRA |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
748 /* Check if the titles are overridden or not */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
749 if (!xs_cfg.titleOverride) |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
750 { |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
751 /* Use generic XMMS titles */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
752 /* XMMS_NEW_TITLEINPUT(ptInput); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
753 * 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
|
754 */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
755 ptInput = (TitleInput *) g_malloc0(sizeof(TitleInput)); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
756 ptInput->__size = XMMS_TITLEINPUT_SIZE; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
757 ptInput->__version = XMMS_TITLEINPUT_VERSION; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
758 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
759 /* Create the input fields */ |
64 | 760 ptInput->file_name = pfInfo->dataFileName; |
761 ptInput->file_ext = g_strdup("sid"); | |
762 ptInput->file_path = pfInfo->path; | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
763 |
64 | 764 ptInput->track_name = pfInfo->infoString[0]; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
765 ptInput->track_number = iSubTune; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
766 ptInput->album_name = NULL; |
64 | 767 ptInput->performer = pfInfo->infoString[1]; |
768 ptInput->date = g_strdup((pfInfo->sidModel == SIDTUNE_SIDMODEL_6581) ? "6581" : "8580"); | |
769 | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
770 ptInput->year = 0; |
64 | 771 ptInput->genre = g_strdup("SID-tune"); |
772 ptInput->comment = pfInfo->infoString[2]; | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
773 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
774 /* Create the string */ |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
775 pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
776 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
777 /* Dispose all allocated memory */ |
64 | 778 g_free(ptInput->file_ext); |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
779 g_free(ptInput->date); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
780 g_free(ptInput->genre); |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
781 g_free(ptInput); |
64 | 782 } |
783 else | |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
784 #endif |
64 | 785 { |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
786 /* 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
|
787 pcStr = xs_cfg.titleFormat; |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
788 iLength = 0; |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
789 while (*pcStr) |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
790 { |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
791 if (*pcStr == '%') |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
792 { |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
793 switch (*(++pcStr)) { |
64 | 794 case '1': iLength += strlen(pfInfo->infoString[1]); break; |
795 case '2': iLength += strlen(pfInfo->infoString[0]); break; | |
796 case '3': iLength += strlen(pfInfo->infoString[2]); break; | |
797 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
|
798 case '%': iLength++; |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
799 } |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
800 } else |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
801 iLength++; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
802 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
803 pcStr++; |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
804 } |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
805 |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
806 /* Allocate memory */ |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
807 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
|
808 if (pcResult == NULL) |
64 | 809 return g_strdup(pfInfo->infoString[0]); |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
810 |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
811 /* Create the string */ |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
812 pcStr = xs_cfg.titleFormat; |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
813 j = 0; |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
814 while (*pcStr) |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
815 { |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
816 if (*pcStr == '%') |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
817 { |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
818 switch (*(++pcStr)) { |
64 | 819 case '1': xs_strpcat(pcResult, &j, pfInfo->infoString[1]); break; |
820 case '2': xs_strpcat(pcResult, &j, pfInfo->infoString[0]); break; | |
821 case '3': xs_strpcat(pcResult, &j, pfInfo->infoString[2]); break; | |
822 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
|
823 case '%': pcResult[j++] = '%'; break; |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
824 } |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
825 } else |
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
826 pcResult[j++] = *pcStr; |
65
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
827 |
bf7b647b3239
The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents:
64
diff
changeset
|
828 pcStr++; |
57
85811bcd049e
Improved, re-written configuration code and lots of minor fixes
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
829 } |
40
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
830 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
831 pcResult[j] = 0; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
832 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
833 |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
834 return pcResult; |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
835 } |
1788f4ce6a44
Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
836 |