annotate src/xmms-sid.cc @ 40:1788f4ce6a44

Numerous changes towards 0.8
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 19 Jun 2003 22:38:01 +0000
parents 15250dd0c326
children 0f00ebab063d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 Main source file
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
6 Written by Matti "ccr" Hamalainen <ccr@tnsp.org>
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 This program is free software; you can redistribute it and/or modify
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 the Free Software Foundation; either version 2 of the License, or
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 (at your option) any later version.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 GNU General Public License for more details.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 along with this program; if not, write to the Free Software
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
22 extern "C" {
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
23 #include <pthread.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
24 #include <stdlib.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
25 #include <string.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
26 #include <stdio.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
27 #include <errno.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
28 #include <xmms/plugin.h>
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
29 #include <xmms/util.h>
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
30 #include <xmms/titlestring.h>
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 #include "xmms-sid.h"
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
32 #include "xs_support.h"
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
33 #include "xs_config.h"
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
34 #include "xs_length.h"
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
35 }
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
36
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
37 #ifdef HAVE_SIDPLAY1
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #include <sidplay/player.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #include <sidplay/myendian.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 #include <sidplay/fformat.h>
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
41 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
42
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
43 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
44 #include <sidplay/sidplay2.h>
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
45 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
49 * Global variables
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
51 #ifdef HAVE_SIDPLAY1
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 static struct emuConfig xs_emuConf;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 static emuEngine xs_emuEngine;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
54 typedef sidTune t_xs_tune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
55 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
56
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
57 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
58 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
59
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 static pthread_t xs_decode_thread;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
61 struct t_xs_cfg xs_cfg;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
62
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
63 struct {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
64 gboolean isError, isPlaying, allowNext;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
65 gint currSong, nSongs;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
66 t_xs_tune *currTune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
67 gchar *currFilename;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
68 } xs_status;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
69
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
70 pthread_mutex_t xs_mutex = PTHREAD_MUTEX_INITIALIZER;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
74 * Initialize XMMS-SID
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 void xs_init(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
78 XSDEBUG("xs_init()\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
80 /* Initialize and get configuration */
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
81 memset(&xs_cfg, 0, sizeof(xs_cfg));
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
82
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
83 xs_read_configuration();
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
84
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
85 xs_status.isError = FALSE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
86 xs_status.isPlaying = FALSE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
87 xs_status.nSongs = 0;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
88 xs_status.currSong = 0;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
89 xs_status.allowNext = TRUE; // Initialize to TRUE to allow first song
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
90 xs_status.currTune = NULL;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
91 xs_status.currFilename = NULL;
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
92
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
93
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
94 /* Try to initialize libSIDPlay(s) */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
95 #ifdef HAVE_SIDPLAY1
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
96 if (!xs_emuEngine || !xs_emuEngine.verifyEndianess())
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
97 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
98 XSERR("Couldn't start SIDPlay1 emulator engine!\n");
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
99 return;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 }
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
101 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
103 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
104 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
106 /* Read song-length database */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
107 if (xs_cfg.songlenDBEnable)
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
108 if (xs_songlen_init() < 0)
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
109 {
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
110 XSERR("Error initializing song-length database!\n");
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
111 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
112
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
113 /* Initialize STIL structures */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
114 // FIXME FIXME FIx ME
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
116 /* Create sub-song control window */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
117 // FIX ME FIXME
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
122 * Shut down XMMS-SID
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
123 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
124 void xs_close(void)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
126 XSDEBUG("shutting down...\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
128 /* Stop playing */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
129 xs_plugin_ip.stop();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
131 /* Shutdown libSIDPlay(s) */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
132 #ifdef HAVE_SIDPLAY1
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
133 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
134
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
135 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
136 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
137
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
138 /* Close sub-song control window */
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
139
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
140 /* Free allocated memory */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
141 xs_songlen_close();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
143 // FIXME FIXME: STIL-entries
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
148 * Check whether the given file is handled by this plugin
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
150 gint xs_is_our_file(char *fileName)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
152 char *pcExt;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
153
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
154 /* Check the filename */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
155 if (fileName == NULL)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
156 return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
157
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
158 /* Try to detect via libSIDPlay's detection routine, if required */
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
159 if (xs_cfg.detectMagic)
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
160 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
161 #ifdef HAVE_SIDPLAY1
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
162 t_xs_tune *testTune = new sidTune(fileName);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
163 if (!testTune) return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
164 if (!testTune->getStatus())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
165 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
166 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
167 return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
168 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
169
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
170 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
171 return TRUE;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
172 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
173 #ifdef HAVE_SIDPLAY2
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
174 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
177 /* Detect just by checking filename extension */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
178 pcExt = strrchr(fileName, '.');
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
179 if (pcExt)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
180 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
181 pcExt++;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
182 if (!strcasecmp(pcExt, "psid")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
183 if (!strcasecmp(pcExt, "sid")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
184 if (!strcasecmp(pcExt, "dat")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
185 if (!strcasecmp(pcExt, "inf")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
186 if (!strcasecmp(pcExt, "info")) return TRUE;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
188
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
189 return FALSE;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
194 * Main playing thread loop
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
196 static void *xs_play_loop(void *argPointer)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
198 /* Don't allow next song to be set yet */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
199 pthread_mutex_lock(&xs_mutex);
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
200 xs_status.allowNext = FALSE;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
201 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
202
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
203
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
204
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
205 XSDEBUG("exiting thread, bye.\n");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
206 return NULL;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 /*
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
211 * Start playing the given file
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
213 void xs_play_file(char *fileName)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
215 t_xs_tune *newTune;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
216 struct sidTuneInfo sidInf;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
217
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
218 XSDEBUG("request to load '%s'\n", fileName);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
219
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
220
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
221 /* Initialize audio output */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
222 XSDEBUG("opening audio output plugin...\n");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
223 if (!xs_plugin_ip.output->open_audio(
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
224 ((xs_cfg.fmtBitsPerSample == 16) ? FMT_S16_NE : FMT_U8), xs_cfg.fmtFrequency,
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
225 ((xs_cfg.fmtChannels == XS_CHN_MONO) ? 1 : 2)))
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
226 {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
227 XSERR("Couldn't open audio output plugin!\n");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
228 delete newTune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
229 return;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
230 }
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
231
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
233 /* Try to get the tune */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
234 newTune = new sidTune(fileName);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
235 if (newTune == NULL) return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
236
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
237 XSDEBUG("tune ok, configuring SIDPlay engine\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
239
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
240 /* Get current configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
241 xs_emuEngine.getConfig(xs_emuConf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
242
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
243
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
244 /* Configure channels and stuff */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
245 switch (xs_cfg.fmtChannels) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
247 case XS_CHN_AUTOPAN:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 xs_emuConf.autoPanning = SIDEMU_CENTEREDAUTOPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 xs_emuConf.volumeControl = SIDEMU_FULLPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
253 case XS_CHN_STEREO:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
259 case XS_CHN_MONO:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 xs_emuConf.channels = SIDEMU_MONO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
265 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
266 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
267 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
268 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
269 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
271
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
272 /* Memory mode settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
273 switch (xs_cfg.memoryMode) {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
274 case XS_MPU_BANK_SWITCHING:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 xs_emuConf.memoryMode = MPU_BANK_SWITCHING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
278 case XS_MPU_TRANSPARENT_ROM:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 xs_emuConf.memoryMode = MPU_TRANSPARENT_ROM;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
282 case XS_MPU_PLAYSID_ENVIRONMENT:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 xs_emuConf.memoryMode = MPU_PLAYSID_ENVIRONMENT;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
286 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
287 XSERR("Internal: Invalid memoryMode setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
288 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
289 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
290 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
293 /* Clockspeed settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
294 switch (xs_cfg.clockSpeed) {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
295 case XS_CLOCK_PAL:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_PAL;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
299 case XS_CLOCK_NTSC:
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_NTSC;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
303 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
304 XSERR("Internal: Invalid clockSpeed setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
305 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
306 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
307 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
308
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
309
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
310 /* Configure rest of the emulation */
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
311 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
312 xs_emuConf.frequency = xs_cfg.fmtFrequency;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
313 xs_emuConf.sampleFormat = SIDEMU_SIGNED_PCM;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
314 xs_emuConf.mos8580 = xs_cfg.mos8580;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
315 xs_emuConf.emulateFilter = xs_cfg.emulateFilters;
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
316 xs_emuConf.filterFs = xs_cfg.filterFs;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
317 xs_emuConf.filterFm = xs_cfg.filterFm;
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
318 xs_emuConf.filterFt = xs_cfg.filterFt;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
319
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
320 XSDEBUG("configuring engine..\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
321
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
322
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
323 /* Now set the emulator configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
324 xs_emuEngine.setConfig(xs_emuConf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
325 newTune->getInfo(sidInf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
326
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
327
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
328 /* Initialize status information */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
329 XSDEBUG("initializing and starting playing thread!\n");
28
15250dd0c326 Removed obsolete file
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
330
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
331 xs_status.isError = FALSE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
332 xs_status.isPlaying = TRUE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
333 xs_status.allowNext = TRUE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
334 xs_status.currSong = sidInf.startSong;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
335 xs_status.nSongs = sidInf.songs;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
336 xs_status.currTune = newTune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
337
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
338
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
339 /* Start the playing thread! */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
340 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
341 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
342 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
343 delete newTune;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
346 /* Exit */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
351 * Stop playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 void xs_stop(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
355 /* If playing, stop. */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
356 XSDEBUG("request to stop.\n");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
357
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
358 if (xs_status.isPlaying)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
360 XSDEBUG("stopping...\n");
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
361 pthread_mutex_lock(&xs_mutex);
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
362 xs_status.isPlaying = 0;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
363 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
364
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
365 pthread_join(xs_decode_thread, NULL);
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
366
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
367 xs_plugin_ip.output->close_audio();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
373 * Pause the playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
375 void xs_pause(short pauseState)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 {
24
271be59be975 Lots of changes
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
377 xs_plugin_ip.output->pause(pauseState);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
382 * Set the time-seek position
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
383 * (the playing thread will do the "seeking" aka song-change)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
385 void xs_seek(int iTime)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
387 #ifdef HAVE_SONG_POSITION
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
388 pthread_mutex_lock(&xs_mutex);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
389
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
390 if ((iTime > 0) && (iTime <= xs_status.nSongs) && xs_status.isPlaying)
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
391 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
392 xs_status.currSong = iTime;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 }
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
394
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
395 pthread_mutex_unlock(&xs_mutex);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
396 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
401 * Return the playing "position/time"
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 int xs_get_time(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 {
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
405 pthread_mutex_lock(&xs_mutex);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
406 if (xs_status.isError)
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
407 return -2;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
408
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
409 if (!xs_status.isPlaying)
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
410 return -1;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
412 #ifdef HAVE_SONG_POSITION
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
413 set_song_position(xs_status.currSong, 1, xs_status.nSongs);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
414 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
416 pthread_mutex_unlock(&xs_mutex);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
417
24
271be59be975 Lots of changes
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
418 return xs_plugin_ip.output->output_time();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
420
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
422 /*
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
423 * Return song information
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
424 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
425 void xs_get_song_info(char *songFilename, char **songTitle, int *songLength)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
426 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
427 struct sidTuneInfo sidInf;
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
428 t_xs_tune *testTune = new sidTune(songFilename);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
429
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
430 /* Check if the tune exists and is readable */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
431 if (!testTune) return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
432 if (!testTune->getStatus())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
433 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
434 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
435 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
436 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
437
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
438 /* Get general tune information */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
439 testTune->getInfo(sidInf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
440 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
441
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
442 /* Get titlestring */
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
443 *songTitle = NULL;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
444
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
445 /* Get song length (in milliseconds), negative if no known length */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
446 *songLength = xs_songlen_get(songFilename, sidInf.startSong) * 1000;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
447 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
448
40
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
449
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
450 /*
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
451 * 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
452 * formatted by the user-specified format-string.
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
453 */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
454 gchar *xs_filetitle_get(gchar *pcFilename, void *pfInfo, gint iSubTune)
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
455 {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
456 gint i, j, iLength;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
457 gchar *pcResult;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
458 struct sidTuneInfo *finfo = (struct sidTuneInfo *) pfInfo;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
459 #ifdef HAVE_XMMSEXTRA
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
460 TitleInput *ptInput;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
461 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
462
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
463 // FIXME FIXME: get STIL-info
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
464
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
465
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
466 #ifdef HAVE_XMMSEXTRA
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
467 /* Check if the titles are overridden or not */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
468 if (!xs_cfg.titleOverride)
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
469 {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
470 /* Use generic XMMS titles */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
471 /* XMMS_NEW_TITLEINPUT(ptInput);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
472 * 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
473 */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
474 ptInput = (TitleInput *) g_malloc0(sizeof(TitleInput));
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
475 ptInput->__size = XMMS_TITLEINPUT_SIZE;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
476 ptInput->__version = XMMS_TITLEINPUT_VERSION;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
477
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
478 /* Create the input fields */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
479 ptInput->file_name = pcFilename;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
480 ptInput->file_ext = pcFilename;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
481 ptInput->file_path = pcFilename;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
482
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
483 ptInput->track_name = finfo->nameString;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
484 ptInput->track_number = iSubTune;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
485 ptInput->album_name = NULL;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
486 ptInput->performer = finfo->authorString;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
487 xs_strcalloc(&ptInput->date, "");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
488 ptInput->year = 0;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
489 xs_strcalloc(&ptInput->genre, "SID-tune");
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
490 ptInput->comment = finfo->copyrightString;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
491
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
492 /* Create the string */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
493 pcResult = xmms_get_titlestring(xmms_get_gentitle_format(), ptInput);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
494
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
495 /* Dispose all allocated memory */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
496 g_free(ptInput->date);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
497 g_free(ptInput->genre);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
498 g_free(ptInput);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
499 } else {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
500 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
501 /* Check the info strings */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
502 if (finfo->numberOfInfoStrings != 3)
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
503 {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
504 if (finfo->numberOfInfoStrings < 1)
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
505 return 0;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
506
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
507 return g_strdup(finfo->infoString[0]);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
508 }
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
509
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
510 /* Check the format-string for NULL */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
511 if (xs_cfg.titleFormat == NULL)
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
512 return g_strdup_printf("%s - %s", finfo->nameString, finfo->authorString);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
513
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
514 /* Construct the final result info */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
515 for (j = i = 0; i < strlen(xs_cfg.titleFormat); i++)
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
516 {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
517 if (xs_cfg.titleFormat[i] == '%')
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
518 {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
519 switch (xs_cfg.titleFormat[++i]) {
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
520 case '1':
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
521 xs_strpcat(&pcResult, &j, finfo->authorString);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
522 break;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
523
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
524 case '2':
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
525 xs_strpcat(&pcResult, &j, finfo->nameString);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
526 break;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
527
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
528 case '3':
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
529 xs_strpcat(&pcResult, &j, finfo->copyrightString);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
530 break;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
531
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
532 case '4':
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
533 xs_strpcat(&pcResult, &j, finfo->formatString);
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
534 break;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
535 } /* case */
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
536 } else
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
537 pcResult[j++] = xs_cfg.titleFormat[i];
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
538 }
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
539
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
540 pcResult[j] = 0;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
541 #ifdef HAVE_XMMSEXTRA
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
542 }
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
543 #endif
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
544
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
545 return pcResult;
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
546 }
1788f4ce6a44 Numerous changes towards 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
547