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
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 */
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
22 #include <pthread.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
23 #include <stdlib.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
24 #include <string.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
25 #include <stdio.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
29 #include <xmms/plugin.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
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"
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
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
38 #include "xs_config.h"
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
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
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
41
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
42 #ifdef HAVE_SIDPLAY1
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 #include <sidplay/player.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 #include <sidplay/myendian.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
54 * Global variables
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
56 #ifdef HAVE_SIDPLAY1
63
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
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
05220299c6e8 Kuumaa paskaa
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
89 gchar *xs_filetitle_get(gchar *, t_xs_tuneinfo *, gint);
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
90
65
bf7b647b3239 The fabled 0.8-rewrite now works to some extent
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
91
42
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
92 /*
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
93 * Create sub-song control window
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
94 */
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
95 void xs_ctrlwin_open(void)
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
96 {
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
97 /* Create sub-song control window */
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
98 if (xs_ctrlwin != NULL)
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
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
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
102 return;
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
103 }
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
104
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
105 xs_ctrlwin = create_xs_ctrlwin();
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
106 gtk_widget_show(xs_ctrlwin);
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
107 }
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
108
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
111 * Initialize XMMS-SID
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 void xs_init(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
115 XSDEBUG("xs_init()\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
117 /* Initialize and get configuration */
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
118 memset(&xs_cfg, 0, sizeof(xs_cfg));
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
119
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
120 xs_read_configuration();
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
133 return;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 }
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
135 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
137 /* Read song-length database */
69
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
138 if (xs_cfg.songlenDBEnable && (xs_songlen_init() < 0))
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
139 {
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
140 XSERR("Error initializing song-length database!\n");
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
141 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
142
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
143 /* Initialize STIL structures */
42
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
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
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
146
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
147 // FIXME FIXME FIx ME
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148
69
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
149 XSDEBUG("OK\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
154 * Shut down XMMS-SID
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
155 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
156 void xs_close(void)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
170 /* Close sub-song control window */
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
171
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
172 /* Free allocated memory */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
173 xs_songlen_close();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
181 * Check whether the given file is handled by this plugin
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
187
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
190 return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
191
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
192 /* Try to detect via libSIDPlay's detection routine, if required */
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
193 if (xs_cfg.detectMagic)
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
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;
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
201 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
210 if (pcExt)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
211 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
219
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
220 return FALSE;
1
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
225 * Main playing thread loop
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
237
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
240
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
241 /* No idea, if this is really required here, but better be
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
242 * careful since we're dealing with EVIL threads ...
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
274 myStatus.isPlaying = TRUE;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
275 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
276
69
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
277 XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong);
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
292 XSERR("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n",
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
299
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
300 /* Set information for current sub-tune */
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
301 tmpStr = xs_filetitle_get(myStatus.currFileName, &tuneInfo, myStatus.currSong);
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
302
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
303 xs_plugin_ip.set_info(tmpStr, (songLength > 0) ? songLength * 1000 : -1,
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
304 1000 * (tuneInfo.songSpeed ? tuneInfo.songSpeed : (tuneInfo.clockSpeed == SIDTUNE_CLOCK_NTSC) ? 60 : 50),
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
305 audioFreq, audioChannels);
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
306 g_free(tmpStr);
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
320 /*
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
321 * Play the subtune
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
322 */
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
377
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
378 /* Now determine if we continue by selecting other subtune or something */
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
404
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
405 /* Last thing we do is set allowNext to TRUE to flag
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
406 * that we have ended all action in the thread
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
417 * Start playing the given file
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
429 if (newTune == NULL) return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
432 /* Get current configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
433 xs_emuEngine.getConfig(xs_emuConf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
434
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
435 /* Configure channels and stuff */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
436 switch (xs_cfg.fmtChannels) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
438 case XS_CHN_AUTOPAN:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440 xs_emuConf.autoPanning = SIDEMU_CENTEREDAUTOPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441 xs_emuConf.volumeControl = SIDEMU_FULLPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
444 case XS_CHN_STEREO:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
447 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452 xs_emuConf.channels = SIDEMU_MONO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455 break;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
456 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
457
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
458
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
459 /* Memory mode settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
462 xs_emuConf.memoryMode = MPU_BANK_SWITCHING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
463 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
465 case XS_MPU_TRANSPARENT_ROM:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
466 xs_emuConf.memoryMode = MPU_TRANSPARENT_ROM;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
469 case XS_MPU_PLAYSID_ENVIRONMENT:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470 xs_emuConf.memoryMode = MPU_PLAYSID_ENVIRONMENT;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
476 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
477
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
479 /* Clockspeed settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_NTSC;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
483 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
489 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
490
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
491
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
492 /* Configure rest of the emulation */
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
493 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
502 xs_emuConf.filterFs = xs_cfg.filterFs;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
503 xs_emuConf.filterFm = xs_cfg.filterFm;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
504 xs_emuConf.filterFt = xs_cfg.filterFt;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
531
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
568 xs_emuConf.precision = xs_cfg.fmtBitsPerSample;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
569 xs_emuConf.frequency = xs_cfg.fmtFrequency;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
570 xs_emuConf.clockForced = xs_cfg.forceSpeed;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
571 xs_emuConf.optimisation = (xs_cfg.optimiseLevel) ? 1 : 0;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
572 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
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
592
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
593
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
605
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
606 /* Start the playing thread! */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
607 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
608 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
609 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
610 delete newTune;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
611 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
615 /* Exit */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
616 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
617
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
618
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
619 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
620 * Stop playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
621 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
622 void xs_stop(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
623 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
627 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
628 XSDEBUG("stopping...\n");
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
631 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
632 pthread_join(xs_decode_thread, NULL);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
634 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
635
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
636
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
637 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
638 * Pause the playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
639 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
640 void xs_pause(short pauseState)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
641 {
24
271be59be975 Lots of changes
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
642 xs_plugin_ip.output->pause(pauseState);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
643 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
644
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
645
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
646 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
647 * Set the time-seek position
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
648 * (the playing thread will do the "seeking" aka song-change)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
651 {
69
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
652 /* If we have song-position patch, check settings */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
660 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
661 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
663
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
664 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
665 * Return the playing "position/time"
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
668 {
69
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
671 return -2;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
672
69
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
673 /* If tune has ended, return -1 */
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
674 if (xs_status.allowNext && !xs_status.isPlaying)
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
675 return -1;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
676
69
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
677 /* Obsolete? */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
682 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
683
69
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
684 /* Else, return output time reported by audio output plugin */
24
271be59be975 Lots of changes
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
685 return xs_plugin_ip.output->output_time();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
686 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
687
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
688
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
689 /*
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
690 * Return song information
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
696 gint tmpInt;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
697
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
701 if (!testTune->getStatus())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
702 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
703 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
704 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
705 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
706
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
709 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
710
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
716 if (tmpInt >= 0)
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
717 *songLength = (tmpInt * 1000);
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
718 else
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
719 *songLength = -1;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
720 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
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
bf6a524cf7ca Fixes, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 65
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
738 /* Check the info strings */
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
739 if (pfInfo->numberOfInfoStrings < 3)
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
740 {
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
741 if (pfInfo->numberOfInfoStrings < 1)
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
742 return 0;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
743
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
744 return g_strdup(pfInfo->infoString[0]);
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
760 ptInput->file_name = pfInfo->dataFileName;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
761 ptInput->file_ext = g_strdup("sid");
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
762 ptInput->file_path = pfInfo->path;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
763
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
767 ptInput->performer = pfInfo->infoString[1];
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
768 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
769
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
770 ptInput->year = 0;
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
771 ptInput->genre = g_strdup("SID-tune");
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
782 }
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
783 else
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
784 #endif
64
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
794 case '1': iLength += strlen(pfInfo->infoString[1]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
795 case '2': iLength += strlen(pfInfo->infoString[0]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
796 case '3': iLength += strlen(pfInfo->infoString[2]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
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
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
819 case '1': xs_strpcat(pcResult, &j, pfInfo->infoString[1]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
820 case '2': xs_strpcat(pcResult, &j, pfInfo->infoString[0]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
821 case '3': xs_strpcat(pcResult, &j, pfInfo->infoString[2]); break;
d3bb914e3af3 Fixes for sidplay2 stuff
Matti Hamalainen <ccr@tnsp.org>
parents: 63
diff changeset
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