annotate src/xmms-sid.cc @ 22:ac2972a7ccd5

Fixed typos and stuff.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Jun 2003 21:22:04 +0000
parents 5b7009eef767
children 271be59be975
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"
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
25 #include "xs_config.h"
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
26 #include "xs_length.h"
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 #include <sidplay/player.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 #include <sidplay/myendian.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 #include <sidplay/fformat.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 extern "C" {
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include <pthread.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 #include <stdlib.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 #include <string.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 #include <stdio.h>
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
37 #include <errno.h>
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #include <xmms/plugin.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 #include <xmms/util.h>
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
45 * Global variables
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 static struct emuConfig xs_emuConf;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 static emuEngine xs_emuEngine;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 static pthread_t xs_decode_thread;
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
50 struct t_xs_cfg xs_cfg;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
51
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
52 struct {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
53 int s_error, s_playing, s_songs, s_allownext;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
54 sidTune *s_tune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
55 gchar *s_fname;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
56 } xs_status;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
57
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
58 pthread_mutex_t xs_mutex = PTHREAD_MUTEX_INITIALIZER;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
62 * Initialize XMMS-SID
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 void xs_init(void)
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 XSDEBUG("xs_init()\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
68 /* Try to initialize libSIDPlay */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
69 if (!xs_emuEngine)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
70 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
71 XSERR("Couldn't start SIDPlay emulator engine!\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
72 return;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
75 if (!xs_emuEngine.verifyEndianess())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
76 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
77 XSERR("Wrong hardware endianess (SIDPlay error)!\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
78 return;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
81 /* Initialize and get configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
82 memset(&xs_cfg, 0, sizeof(xs_cfg));
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
83 xs_get_configure();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
85 xs_status.s_error = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
86 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
87 xs_status.s_songs = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
88 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
89 xs_status.s_tune = NULL;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
90 xs_status.s_fname = NULL;
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
91
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
92 /* Read song-length database */
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
93 if (xs_songlen_init() < 0)
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
94 {
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
95 XSERR("Error initializing song-length database!\n");
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
96 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
97
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
98 /* Initialize STIL structures */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
99 // FIXME FIXME FIx ME
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
101 /* Create sub-song control window */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
102 // FIX ME FIXME
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
107 * Shut down XMMS-SID
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
108 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
109 void xs_close(void)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
111 XSDEBUG("shutting down...\n");
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
113 /* Stop playing */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
114 xs_plugin_ip.stop();
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 /* Free allocated memory */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
117 xs_songlen_close();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
119 // FIXME FIXME: STIL-entries, songlendb
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 /*
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 * Check whether the given file is handled by this plugin
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 gint xs_is_our_file(char *fileName)
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 char *pcExt;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
129
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
130 /* Check the filename */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
131 if (fileName == NULL)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
132 return FALSE;
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 /* Try to detect via libSIDPlay's detection routine, if required */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
135 if (xs_cfg.detectMagic) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
137 sidTune *testTune = new sidTune(fileName);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
139 if (!testTune) return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
140 if (!testTune->getStatus())
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
141 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
142 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
143 return FALSE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
144 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
145
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
146 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
147 return TRUE;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 }
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
151 /* Detect just by checking filename extension */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
152 pcExt = strrchr(fileName, '.');
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
153 if (pcExt)
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 pcExt++;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
156 if (!strcasecmp(pcExt, "psid")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
157 if (!strcasecmp(pcExt, "sid")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
158 if (!strcasecmp(pcExt, "dat")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
159 if (!strcasecmp(pcExt, "inf")) return TRUE;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
160 if (!strcasecmp(pcExt, "info")) return TRUE;
1
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
163 return FALSE;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 /*
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 * Playing thread loop function
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
170 static void *xs_play_loop(void *argPointer)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
172 gchar plr_data[XMMS_SID_BUFSIZE];
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
173 struct sidTuneInfo plr_sidInf;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
174 gchar *plr_tune_title = NULL;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
175 gint plr_fxlen;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
176 enum AFormat plr_fmt;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
177 gint plr_tune_num;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
178 gint32 plr_tune_len;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
179
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 /* Don't allow next song to be set yet */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
182 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
183 xs_status.s_allownext = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
184 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
185
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 /* Check tune number */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
188 plr_tune_num = xs_status.s_playing;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
189
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
190 if (plr_tune_num <= 0)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
191 plr_tune_num = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
192
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
193 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
194
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
195 /* Get song information */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
196 xs_status.s_tune->getInfo(plr_sidInf);
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
197 plr_tune_len = xs_songlen_get(xs_status.s_fname, plr_tune_num);
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
198 plr_tune_title = xs_filetitle_get(&plr_sidInf, plr_tune_num);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
200 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
201
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 /* Initialize audio output */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
204 // FIXME FIXME: FMT_S16_XXX -- different architechtures??
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
205 // the patch may break something ...
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
206 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
207
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
209 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
210 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
211 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
212 xs_status.s_error = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
213 if (plr_tune_title) g_free(plr_tune_title);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
214 if (xs_status.s_tune) delete xs_status.s_tune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
215 xs_status.s_allownext = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
216 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
217 return NULL;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
218 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
219
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
220
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
221 /* Initialize the SIDPlay-emulator for song */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
222 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
223 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
224 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
225 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
226 xs_status.s_error = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
227 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
228 goto pl_cleanup;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
231
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
232 /* Set song title information */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
233 xmms_sid_ip.set_info(
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
234 plr_tune_title,
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
235 (plr_tune_len * 1000),
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
236 (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
237 xs_emuConf.frequency,
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
238 xs_emuConf.channels);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
239
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
241 /* 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
242 while (xs_status.s_playing == plr_tune_num)
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 plr_fxlen = XMMS_SID_BUFSIZE;
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 /* Run emulator to fill output buffer with audio data */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
247 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
248
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
249 /* If Max Playtime option set, check playtime */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
250 if (xs_cfg.playUseMaxTime)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
251 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
252 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
253 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
254 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
255 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
256 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
257 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
258 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
260 /* Check playtime against database */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
261 if (xs_cfg.playMethod == XMMS_SID_PMETHOD_DATABASE)
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 ((xmms_sid_ip.output->output_time() / 1000) >= plr_tune_len)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
264 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
265 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
266 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
267 pthread_mutex_unlock(&xs_mutex);
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 #if 0
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
272 else
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
274 /* Check for silence */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
275 if (xs_cfg.playMethod == XMMS_SID_PMETHOD_MAXSILENCE)
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
279 /* Add static noise */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
280
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
281 /* Muffle waveform (low-pass filter) */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
283 #endif
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
284
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
285
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
286 /* Send audio data to visualization plugin */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 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
288 plr_fmt, xs_emuConf.channels, plr_fxlen, plr_data);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
290 /* Wait for a while */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
291 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
292 xmms_usleep(10000);
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
294
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
295 /* If playing, send final audio data to output plugin */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
296 if (xs_status.s_playing == plr_tune_num)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
297 xmms_sid_ip.output->write_audio(plr_data, plr_fxlen);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
299 } /* End of playerloop */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
300
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
301
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
302 pl_cleanup:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
303 XSDEBUG("cleaning up...\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
304
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
305 /* Cleanup & shutdown */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 xmms_sid_ip.output->close_audio();
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 if (plr_tune_title) g_free(plr_tune_title);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
310 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
311 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
312 if (xs_status.s_tune) delete xs_status.s_tune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
313 xs_status.s_allownext = 1;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
314 pthread_mutex_unlock(&xs_mutex);
1
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 XSDEBUG("exiting thread, bye.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
317 return NULL;
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 /*
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 * Start playing the given file
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
324 void xs_play_file(char *fileName)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
326 sidTune *newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
327 struct sidTuneInfo sidInf;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
328
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
329 XSDEBUG("request to start '%s'\n", fileName);
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 /* Wait until the previous song has finished for sure */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
332 if (!xs_status.s_allownext)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
333 pthread_join(xs_decode_thread, NULL);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
335 /* Try to get the tune */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
336 newTune = new sidTune(fileName);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
337 if (newTune == NULL) return;
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 XSDEBUG("tune ok, status %i\n", xs_status.s_playing);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
341 /* Get current configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
342 xs_emuEngine.getConfig(xs_emuConf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
343
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
344
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
345 /* Configure channels and stuff */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
346 switch (xs_cfg.fmtChannels) {
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 case XMMS_SID_CHN_AUTOPAN:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 xs_emuConf.autoPanning = SIDEMU_CENTEREDAUTOPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 xs_emuConf.volumeControl = SIDEMU_FULLPANNING;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 case XMMS_SID_CHN_STEREO:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 xs_emuConf.channels = SIDEMU_STEREO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 case XMMS_SID_CHN_MONO:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 xs_emuConf.channels = SIDEMU_MONO;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 xs_emuConf.autoPanning = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 xs_emuConf.volumeControl = SIDEMU_NONE;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
366 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
367 XSERR("Internal: Invalid channels setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
368 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
369 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
370 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
372 /* Memory mode settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
373 switch (xs_cfg.memoryMode) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 case XMMS_SID_MPU_BANK_SWITCHING:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 xs_emuConf.memoryMode = MPU_BANK_SWITCHING;
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
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 case XMMS_SID_MPU_TRANSPARENT_ROM:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 xs_emuConf.memoryMode = MPU_TRANSPARENT_ROM;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 case XMMS_SID_MPU_PLAYSID_ENVIRONMENT:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 xs_emuConf.memoryMode = MPU_PLAYSID_ENVIRONMENT;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
386 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
387 XSERR("Internal: Invalid memoryMode setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
388 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
389 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
390 }
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
393 /* Clockspeed settings */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
394 switch (xs_cfg.clockSpeed) {
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 case XMMS_SID_CLOCK_PAL:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_PAL;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 case XMMS_SID_CLOCK_NTSC:
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 xs_emuConf.clockSpeed = SIDTUNE_CLOCK_NTSC;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 break;
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
403 default:
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
404 XSERR("Internal: Invalid clockSpeed setting. Possibly corrupted configuration file.\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
405 delete newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
406 return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
407 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
408
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
409
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
410 /* Configure rest of the emulation */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
411 xs_emuConf.bitsPerSample = xs_cfg.fmtBitsPerSample;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
412 xs_emuConf.frequency = xs_cfg.fmtFrequency;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
413 xs_emuConf.sampleFormat = SIDEMU_SIGNED_PCM;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
414 xs_emuConf.mos8580 = xs_cfg.mos8580;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
415 xs_emuConf.emulateFilter = xs_cfg.emulateFilter;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
416 xs_emuConf.filterFs = xs_cfg.filterFs;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
417 xs_emuConf.filterFm = xs_cfg.filterFm;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
418 xs_emuConf.filterFt = xs_cfg.filterFt;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
419
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
420 XSDEBUG("configuring engine..\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
421
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
422 /* Now set the emulator configuration */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
423 xs_emuEngine.setConfig(xs_emuConf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
424 newTune->getInfo(sidInf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
425
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
426 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
427 xs_status.s_error = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
428 xs_status.s_playing = sidInf.startSong;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
429 xs_status.s_songs = sidInf.songs;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
430 xs_status.s_tune = newTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
431 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
432
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
433 XSDEBUG("starting thread!\n");
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
434
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
435 /* Start the playing thread! */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
436 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
437 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
438 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
439 delete newTune;
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
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
442 /* Exit */
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
444
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
447 * Stop playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
449 void xs_stop(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
450 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
451 /* If playing, stop. */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
452 if (xs_status.s_playing)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
454 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
455 xs_status.s_playing = 0;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
456 pthread_mutex_unlock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
457
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
458 pthread_join(xs_decode_thread, NULL);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
460 }
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 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
464 * Pause the playing
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
466 void xs_pause(short pauseState)
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 xmms_sid_ip.output->pause(pauseState);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
473 * Set the time-seek position
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
474 * (the playing thread will do the "seeking" aka song-change)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
475 */
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
476 void xs_seek(int iTime)
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
477 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
478 #ifdef HAVE_SONG_POSITION
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
479 if ((iTime > 0) && (iTime <= xs_songs))
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
480 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
481 pthread_mutex_lock(&xs_mutex);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
482 xs_status.s_playing = iTime;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
483 pthread_mutex_unlock(&xs_mutex);
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 }
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
485 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
489 /*
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
490 * Return the playing "position/time"
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
491 */
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492 int xs_get_time(void)
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493 {
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
494 if (xs_status.s_error)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
495 return -2;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
496
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
497 if (!xs_status.s_playing)
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
498 return -1;
1
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 #ifdef HAVE_SONG_POSITION
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
501 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
502 #endif
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
504 return xmms_sid_ip.output->output_time();
1
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505 }
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506
183e7cbc1036 Initial revision
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
508 /*
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
509 * Return song information
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
510 */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
511 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
512 {
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
513 struct sidTuneInfo sidInf;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
514 sidTune *testTune = new sidTune(songFilename);
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 /* Check if the tune exists and is readable */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
517 if (!testTune) return;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
518 if (!testTune->getStatus())
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 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
521 return;
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
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
524 /* Get general tune information */
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
525 testTune->getInfo(sidInf);
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
526 delete testTune;
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
527
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
528 /* Get titlestring */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
529 *songTitle = xs_filetitle_get(&sidInf, sidInf.startSong);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
530
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
531 /* Get song length (in seconds), negative if no known length */
22
ac2972a7ccd5 Fixed typos and stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
532 *songLength = xs_songlen_get(songFilename, sidInf.startSong);
5
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
533 }
5b7009eef767 Updated to 0.8
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
534