annotate src/xmms-sid.cc @ 5:5b7009eef767

Updated to 0.8
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 03 Jun 2003 11:07:00 +0000
parents 183e7cbc1036
children ac2972a7ccd5
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>
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
7 (few bits may still be by Willem Monsuwe)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 (at your option) any later version.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 GNU General Public License for more details.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 along with this program; if not, write to the Free Software
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 #include "xmms-sid.h"
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 #include <sidplay/player.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 #include <sidplay/myendian.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 #include <sidplay/fformat.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 extern "C" {
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 #include <pthread.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include <stdlib.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 #include <string.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 #include <stdio.h>
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
35 #include <errno.h>
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 #include <xmms/plugin.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #include <xmms/util.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
43 * Global variables
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 static struct emuConfig xs_emuConf;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 static emuEngine xs_emuEngine;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 static pthread_t xs_decode_thread;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
48 struct t_xs_cfg xs_cfg;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
49
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
50 struct {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
51 int s_error, s_playing, s_songs, s_allownext;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
52 sidTune *s_tune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
53 gchar *s_fname;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
54 } xs_status;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
55
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
56 pthread_mutex_t xs_mutex = PTHREAD_MUTEX_INITIALIZER;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
60 * Initialize XMMS-SID
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 void xs_init(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
64 XSDEBUG("xs_init()\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
66 /* Try to initialize libSIDPlay */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
67 if (!xs_emuEngine)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
68 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
69 XSERR("Couldn't start SIDPlay emulator engine!\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
70 return;
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
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
73 if (!xs_emuEngine.verifyEndianess())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
74 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
75 XSERR("Wrong hardware endianess (SIDPlay error)!\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
76 return;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
79 /* Initialize and get configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
80 memset(&xs_cfg, 0, sizeof(xs_cfg));
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
81 xs_get_configure();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
83 xs_status.s_error = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
84 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
85 xs_status.s_songs = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
86 xs_status.s_allownext = 1; // Initialize to TRUE to allow first song
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
87 xs_status.s_tune = NULL;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
88 xs_status.s_fname = NULL;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
89
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
90 /* Initialize STIL structures */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
91 // FIXME FIXME FIx ME
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
93 /* Create sub-song control window */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
94 // FIX ME FIXME
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
99 * Shut down XMMS-SID
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
100 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
101 void xs_close(void)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
103 XSDEBUG("shutting down...\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
105 /* Stop playing */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
106 xmms_sid_ip.stop();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
108 /* Free allocated memory */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
110 // FIXME FIXME: STIL-entries, songlendb
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 /*
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 * Check whether the given file is handled by this plugin
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
118 gint xs_is_our_file(char *fileName)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
120 char *pcExt;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
121
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
122 /* Check the filename */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
123 if (fileName == NULL)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
124 return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
125
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
126 /* Try to detect via libSIDPlay's detection routine, if required */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
127 if (xs_cfg.detectMagic) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
129 sidTune *testTune = new sidTune(fileName);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
131 if (!testTune) return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
132 if (!testTune->getStatus())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
133 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
134 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
135 return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
136 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
137
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
138 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
139 return TRUE;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
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 /* Detect just by checking filename extension */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
144 pcExt = strrchr(fileName, '.');
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
145 if (pcExt)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
146 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
147 pcExt++;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
148 if (!strcasecmp(pcExt, "psid")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
149 if (!strcasecmp(pcExt, "sid")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
150 if (!strcasecmp(pcExt, "dat")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
151 if (!strcasecmp(pcExt, "inf")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
152 if (!strcasecmp(pcExt, "info")) return TRUE;
1
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
155 return FALSE;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 /*
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 * Playing thread loop function
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
162 static void *xs_play_loop(void *argPointer)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
164 gchar plr_data[XMMS_SID_BUFSIZE];
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
165 struct sidTuneInfo plr_sidInf;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
166 gchar *plr_tune_title = NULL;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
167 gint plr_fxlen;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
168 enum AFormat plr_fmt;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
169 gint plr_tune_num;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
170 gint32 plr_tune_len;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
171
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
172
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
173 /* Don't allow next song to be set yet */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
174 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
175 xs_status.s_allownext = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
176 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
177
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
178
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
179 /* Check tune number */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
180 plr_tune_num = xs_status.s_playing;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
181
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
182 if (plr_tune_num <= 0)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
183 plr_tune_num = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
184
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
185 XSDEBUG("xs_play_loop(%d, %d)\n", plr_tune_num, xs_status.s_playing);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
186
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
187 /* Get song information */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
188 xs_status.s_tune->getInfo(plr_sidInf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
189 plr_tune_len = xs_get_length(xs_status.s_fname, plr_tune_num);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
190 plr_tune_title = xs_get_filetitle(&plr_sidInf, plr_tune_num);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
192 XSDEBUG("title='%s', len=%d\n", plr_tune_title, plr_tune_len);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
193
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
194
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
195 /* Initialize audio output */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
196 // FIXME FIXME: FMT_S16_XXX -- different architechtures??
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
197 // the patch may break something ...
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
198 plr_fmt = (xs_emuConf.bitsPerSample == 16) ? FMT_S16_NE : FMT_U8;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
199
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
201 if (!xmms_sid_ip.output->open_audio(plr_fmt, xs_emuConf.frequency, xs_emuConf.channels))
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
203 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
204 xs_status.s_error = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
205 if (plr_tune_title) g_free(plr_tune_title);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
206 if (xs_status.s_tune) delete xs_status.s_tune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
207 xs_status.s_allownext = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
208 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
209 return NULL;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
210 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
211
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
212
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
213 /* Initialize the SIDPlay-emulator for song */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
214 if (!sidEmuInitializeSong(xs_emuEngine, *xs_status.s_tune, plr_tune_num))
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
215 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
216 XSERR("Couldn't initialize SIDPlay emulator engine! This may be a problem with your sound settings, or possibly a bug in XMMS-SID.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
217 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
218 xs_status.s_error = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
219 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
220 goto pl_cleanup;
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
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
223
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
224 /* Set song title information */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
225 xmms_sid_ip.set_info(
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
226 plr_tune_title,
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
227 (plr_tune_len * 1000),
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
228 (1000 * (plr_sidInf.songSpeed ? plr_sidInf.songSpeed : (plr_sidInf.clockSpeed == SIDTUNE_CLOCK_NTSC) ? 60 : 50)),
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
229 xs_emuConf.frequency,
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
230 xs_emuConf.channels);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
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 /* Run playing loop: loop as long as xs_playing is same as current tune number */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
234 while (xs_status.s_playing == plr_tune_num)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
235 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
236 plr_fxlen = XMMS_SID_BUFSIZE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
237
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
238 /* Run emulator to fill output buffer with audio data */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
239 sidEmuFillBuffer(xs_emuEngine, *xs_status.s_tune, plr_data, plr_fxlen);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
240
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
241 /* If Max Playtime option set, check playtime */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
242 if (xs_cfg.playUseMaxTime)
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 if ((xmms_sid_ip.output->output_time() / 1000) >= xs_cfg.playMaxTime)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
245 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
246 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
247 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
248 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
249 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
250 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
252 /* Check playtime against database */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
253 if (xs_cfg.playMethod == XMMS_SID_PMETHOD_DATABASE)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
254 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
255 if ((xmms_sid_ip.output->output_time() / 1000) >= plr_tune_len)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
256 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
257 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
258 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
259 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
260 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
261
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
262 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
263 #if 0
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
264 else
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
266 /* Check for silence */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
267 if (xs_cfg.playMethod == XMMS_SID_PMETHOD_MAXSILENCE)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
268 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
269 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
270
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
271 /* Add static noise */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
272
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
273 /* Muffle waveform (low-pass filter) */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
275 #endif
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
276
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
277
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
278 /* Send audio data to visualization plugin */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 xmms_sid_ip.add_vis_pcm(xmms_sid_ip.output->written_time(),
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
280 plr_fmt, xs_emuConf.channels, plr_fxlen, plr_data);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
282 /* Wait for a while */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
283 while ((xs_status.s_playing == plr_tune_num) && (xmms_sid_ip.output->buffer_free() < plr_fxlen))
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 xmms_usleep(10000);
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
287 /* If playing, send final audio data to output plugin */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
288 if (xs_status.s_playing == plr_tune_num)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
289 xmms_sid_ip.output->write_audio(plr_data, plr_fxlen);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
291 } /* End of playerloop */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
292
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
293
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
294 pl_cleanup:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
295 XSDEBUG("cleaning up...\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
296
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
297 /* Cleanup & shutdown */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 xmms_sid_ip.output->close_audio();
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
300 if (plr_tune_title) g_free(plr_tune_title);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
302 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
303 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
304 if (xs_status.s_tune) delete xs_status.s_tune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
305 xs_status.s_allownext = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
306 pthread_mutex_unlock(&xs_mutex);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
308 XSDEBUG("exiting thread, bye.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
309 return NULL;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 /*
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 * Start playing the given file
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
316 void xs_play_file(char *fileName)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
318 sidTune *newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
319 struct sidTuneInfo sidInf;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
320
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
321 XSDEBUG("request to start '%s'\n", fileName);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
322
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
323 /* Wait until the previous song has finished for sure */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
324 if (!xs_status.s_allownext)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
325 pthread_join(xs_decode_thread, NULL);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
327 /* Try to get the tune */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
328 newTune = new sidTune(fileName);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
329 if (newTune == NULL) return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
330
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
331 XSDEBUG("tune ok, status %i\n", xs_status.s_playing);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
333 /* Get current configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
334 xs_emuEngine.getConfig(xs_emuConf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
335
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
336
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
337 /* Configure channels and stuff */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
338 switch (xs_cfg.fmtChannels) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 case XMMS_SID_CHN_AUTOPAN:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 xs_emuConf.autoPanning = SIDEMU_CENTEREDAUTOPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 xs_emuConf.volumeControl = SIDEMU_FULLPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 case XMMS_SID_CHN_STEREO:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 case XMMS_SID_CHN_MONO:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 xs_emuConf.channels = SIDEMU_MONO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
358 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
359 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
360 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
361 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
362 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
364 /* Memory mode settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
365 switch (xs_cfg.memoryMode) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 case XMMS_SID_MPU_BANK_SWITCHING:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 xs_emuConf.memoryMode = MPU_BANK_SWITCHING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 case XMMS_SID_MPU_TRANSPARENT_ROM:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 xs_emuConf.memoryMode = MPU_TRANSPARENT_ROM;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 case XMMS_SID_MPU_PLAYSID_ENVIRONMENT:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 xs_emuConf.memoryMode = MPU_PLAYSID_ENVIRONMENT;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
378 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
379 XSERR("Internal: Invalid memoryMode setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
380 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
381 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
382 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383
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 /* Clockspeed settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
386 switch (xs_cfg.clockSpeed) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 case XMMS_SID_CLOCK_PAL:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_PAL;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 case XMMS_SID_CLOCK_NTSC:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_NTSC;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
395 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
396 XSERR("Internal: Invalid clockSpeed setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
397 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
398 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
399 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
400
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
401
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
402 /* Configure rest of the emulation */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
403 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
404 xs_emuConf.frequency = xs_cfg.fmtFrequency;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
405 xs_emuConf.sampleFormat = SIDEMU_SIGNED_PCM;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
406 xs_emuConf.mos8580 = xs_cfg.mos8580;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
407 xs_emuConf.emulateFilter = xs_cfg.emulateFilter;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
408 xs_emuConf.filterFs = xs_cfg.filterFs;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
409 xs_emuConf.filterFm = xs_cfg.filterFm;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
410 xs_emuConf.filterFt = xs_cfg.filterFt;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
411
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
412 XSDEBUG("configuring engine..\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
413
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
414 /* Now set the emulator configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
415 xs_emuEngine.setConfig(xs_emuConf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
416 newTune->getInfo(sidInf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
417
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
418 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
419 xs_status.s_error = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
420 xs_status.s_playing = sidInf.startSong;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
421 xs_status.s_songs = sidInf.songs;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
422 xs_status.s_tune = newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
423 pthread_mutex_unlock(&xs_mutex);
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 XSDEBUG("starting thread!\n");
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 /* Start the playing thread! */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
428 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
429 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
430 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
431 delete newTune;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
434 /* Exit */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
435 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
436
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
439 * Stop playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441 void xs_stop(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
443 /* If playing, stop. */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
444 if (xs_status.s_playing)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
446 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
447 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
448 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
449
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
450 pthread_join(xs_decode_thread, NULL);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
451 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
456 * Pause the playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
457 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
458 void xs_pause(short pauseState)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
460 xmms_sid_ip.output->pause(pauseState);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
461 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
462
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
463
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
465 * Set the time-seek position
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
466 * (the playing thread will do the "seeking" aka song-change)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
468 void xs_seek(int iTime)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
470 #ifdef HAVE_SONG_POSITION
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
471 if ((iTime > 0) && (iTime <= xs_songs))
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
472 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
473 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
474 xs_status.s_playing = iTime;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
475 pthread_mutex_unlock(&xs_mutex);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
476 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
477 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
479
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
480
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
481 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
482 * Return the playing "position/time"
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
483 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 int xs_get_time(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
486 if (xs_status.s_error)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
487 return -2;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
488
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
489 if (!xs_status.s_playing)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
490 return -1;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
491
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
492 #ifdef HAVE_SONG_POSITION
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
493 set_song_position(xs_status.s_playing, 1, xs_status.s_songs);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
494 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
495
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
496 return xmms_sid_ip.output->output_time();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
500 /*
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
501 * Return song information
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
502 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
503 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
504 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
505 struct sidTuneInfo sidInf;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
506 sidTune *testTune = new sidTune(songFilename);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
507
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
508 /* Check if the tune exists and is readable */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
509 if (!testTune) return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
510 if (!testTune->getStatus())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
511 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
512 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
513 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
514 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
515
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
516 /* Get general tune information */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
517 testTune->getInfo(sidInf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
518 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
519
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
520 /* Get titlestring */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
521 *songTitle = xs_get_filetitle(&sidInf, sidInf.startSong);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
522
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
523 /* Get song length (in seconds), negative if no known length */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
524 *songLength = xs_get_length(songFilename, sidInf.startSong);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
525 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
526