annotate src/xmms-sid.c @ 324:dd201740a720

Changed copyright text.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 11 Jan 2005 04:11:02 +0000
parents b2707c970c9c
children 15c5b231efc9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 Main source file
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
324
dd201740a720 Changed copyright text.
Matti Hamalainen <ccr@tnsp.org>
parents: 313
diff changeset
6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
dd201740a720 Changed copyright text.
Matti Hamalainen <ccr@tnsp.org>
parents: 313
diff changeset
7 (C) Copyright 1999-2005 Tecnic Software productions (TNSP)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2 of the License, or
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 (at your option) any later version.
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 This program is distributed in the hope that it will be useful,
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 GNU General Public License for more details.
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 along with this program; if not, write to the Free Software
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 */
235
d04191d1ea64 Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
23 #include "xmms-sid.h"
d04191d1ea64 Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
24 #include "xs_support.h"
223
16e3b2446a73 On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents: 213
diff changeset
25
16e3b2446a73 On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents: 213
diff changeset
26 #ifdef HAVE_STDLIB_H
16e3b2446a73 On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents: 213
diff changeset
27 #include <stdlib.h>
16e3b2446a73 On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents: 213
diff changeset
28 #endif
16e3b2446a73 On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents: 213
diff changeset
29
297
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
30 #include <stdarg.h>
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
31
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include <xmms/plugin.h>
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
33 #include <xmms/util.h>
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
35 #include <gdk/gdkkeysyms.h>
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
36 #include <gtk/gtk.h>
235
d04191d1ea64 Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
37
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #include "xs_config.h"
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #include "xs_length.h"
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
40 #include "xs_stil.h"
313
b2707c970c9c #include "xs_filter.h"
Matti Hamalainen <ccr@tnsp.org>
parents: 308
diff changeset
41 #include "xs_filter.h"
235
d04191d1ea64 Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
42 #include "xs_fileinfo.h"
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 #include "xs_interface.h"
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 #include "xs_glade.h"
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 * Include player engines
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 */
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
49 #ifdef HAVE_SIDPLAY1
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 #include "xs_sidplay1.h"
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
51 #endif
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
52 #ifdef HAVE_SIDPLAY2
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 #include "xs_sidplay2.h"
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
54 #endif
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
55
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
56
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
57 /*
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
58 * List of players and links to their functions
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
59 */
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
60 t_xs_player xs_playerlist[] = {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
61 #ifdef HAVE_SIDPLAY1
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
62 { XS_ENG_SIDPLAY1,
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
63 xs_sidplay1_isourfile,
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
64 xs_sidplay1_init, xs_sidplay1_close,
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
65 xs_sidplay1_initsong, xs_sidplay1_fillbuffer,
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
66 xs_sidplay1_loadsid, xs_sidplay1_deletesid,
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
67 xs_sidplay1_getsidinfo
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
68 },
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
69 #endif
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
70 #ifdef HAVE_SIDPLAY2
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
71 { XS_ENG_SIDPLAY2,
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
72 xs_sidplay2_isourfile,
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
73 xs_sidplay2_init, xs_sidplay2_close,
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
74 xs_sidplay2_initsong, xs_sidplay2_fillbuffer,
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
75 xs_sidplay2_loadsid, xs_sidplay2_deletesid,
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
76 xs_sidplay2_getsidinfo
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
77 },
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
78 #endif
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
79 };
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
80
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
81 const gint xs_nplayerlist = (sizeof(xs_playerlist) / sizeof(t_xs_player));
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 * Global variables
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
87 t_xs_status xs_status;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
88 XS_MUTEX(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
89 static pthread_t xs_decode_thread;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
91 static GtkWidget *xs_subctrl = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
92 static GtkObject *xs_subctrl_adj = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
93 XS_MUTEX(xs_subctrl);
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
94
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
95 void xs_subctrl_close(void);
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
96 void xs_subctrl_update(void);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
98
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 /*
297
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
100 * Error messages
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
101 */
298
5db529b397bd xs_error() -> XSERR()
Matti Hamalainen <ccr@tnsp.org>
parents: 297
diff changeset
102 void XSERR(const char *fmt, ...)
297
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
103 {
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
104 va_list ap;
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
105 fprintf(stderr, "XMMS-SID: ");
299
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
106 va_start(ap, fmt);
297
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
107 vfprintf(stderr, fmt, ap);
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
108 va_end(ap);
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
109 }
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
110
299
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
111 #ifndef DEBUG_NP
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
112 void XSDEBUG(const char *fmt, ...)
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
113 {
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
114 #ifdef DEBUG
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
115 va_list ap;
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
116 fprintf(stderr, "XSDEBUG: ");
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
117 va_start(ap, fmt);
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
118 vfprintf(stderr, fmt, ap);
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
119 va_end(ap);
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
120 #endif
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
121 }
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
122 #endif
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
123
297
ac9a484e3430 Make XSERR into function.
Matti Hamalainen <ccr@tnsp.org>
parents: 294
diff changeset
124 /*
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
125 * Initialization functions
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 */
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
127 void xs_reinit(void)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 {
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
129 gint iPlayer;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
130 gboolean isInitialized;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
131
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
132 /* Stop playing, if we are */
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
133 XS_MUTEX_LOCK(xs_status);
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
134 if (xs_status.isPlaying)
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
135 {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
136 XS_MUTEX_UNLOCK(xs_status);
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
137 xs_stop();
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
138 } else {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
139 XS_MUTEX_UNLOCK(xs_status);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
140 }
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
141
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
142 /* Initialize status and sanitize configuration */
213
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
143 xs_memset(&xs_status, 0, sizeof(xs_status));
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
144
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
145 if (xs_cfg.audioFrequency < 8000)
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
146 xs_cfg.audioFrequency = 8000;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
147
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
148 if (xs_cfg.oversampleFactor < XS_MIN_OVERSAMPLE)
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
149 xs_cfg.oversampleFactor = XS_MIN_OVERSAMPLE;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
150 else
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
151 if (xs_cfg.oversampleFactor > XS_MAX_OVERSAMPLE)
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
152 xs_cfg.oversampleFactor = XS_MAX_OVERSAMPLE;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
153
307
b6481d876ec2 Disable oversampling if non-mono output; remove disabling of oversampling
Matti Hamalainen <ccr@tnsp.org>
parents: 306
diff changeset
154 if (xs_cfg.audioChannels != XS_CHN_MONO)
b6481d876ec2 Disable oversampling if non-mono output; remove disabling of oversampling
Matti Hamalainen <ccr@tnsp.org>
parents: 306
diff changeset
155 xs_cfg.oversampleEnable = FALSE;
b6481d876ec2 Disable oversampling if non-mono output; remove disabling of oversampling
Matti Hamalainen <ccr@tnsp.org>
parents: 306
diff changeset
156
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
157 xs_status.audioFrequency = xs_cfg.audioFrequency;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
158 xs_status.audioBitsPerSample = xs_cfg.audioBitsPerSample;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
159 xs_status.audioChannels = xs_cfg.audioChannels;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
160 xs_status.audioFormat = -1;
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
161 xs_status.oversampleEnable = xs_cfg.oversampleEnable;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
162 xs_status.oversampleFactor = xs_cfg.oversampleFactor;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
163
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
164 /* Try to initialize emulator engine */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
165 XSDEBUG("initializing emulator engine #%i...\n", xs_cfg.playerEngine);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
167 iPlayer = 0;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
168 isInitialized = FALSE;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
169 while ((iPlayer < xs_nplayerlist) && !isInitialized)
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
170 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
171 if (xs_playerlist[iPlayer].plrIdent == xs_cfg.playerEngine)
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
172 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
173 if (xs_playerlist[iPlayer].plrInit(&xs_status))
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
174 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
175 isInitialized = TRUE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
176 xs_status.sidPlayer = (t_xs_player *) &xs_playerlist[iPlayer];
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
177 }
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
178 }
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
179 iPlayer++;
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
180 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
182 XSDEBUG("init#1: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
184 iPlayer = 0;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
185 while ((iPlayer < xs_nplayerlist) && !isInitialized)
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
186 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
187 if (xs_playerlist[iPlayer].plrInit(&xs_status))
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
188 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
189 isInitialized = TRUE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
190 xs_status.sidPlayer = (t_xs_player *) &xs_playerlist[iPlayer];
253
fa463b3ca57b Compile-time optionally enabled themetune support in about-dialog (click the logo image)
Matti Hamalainen <ccr@tnsp.org>
parents: 243
diff changeset
191 xs_cfg.playerEngine = xs_playerlist[iPlayer].plrIdent;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
192 } else
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
193 iPlayer++;
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
194 }
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
195
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
196 XSDEBUG("init#2: %s, %i\n", (isInitialized) ? "OK" : "FAILED", iPlayer);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
198 /* Get settings back, in case the chosen emulator backend changed them */
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
199 xs_cfg.audioFrequency = xs_status.audioFrequency;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
200 xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
201 xs_cfg.audioChannels = xs_status.audioChannels;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
202 xs_cfg.oversampleEnable = xs_status.oversampleEnable;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
203
99
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
204 /* Initialize song-length database */
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
205 xs_songlen_close();
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
206 if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0))
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
207 {
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 XSERR("Error initializing song-length database!\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210
99
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
211 /* Initialize STIL database */
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
212 xs_stil_close();
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
213 if (xs_cfg.stilDBEnable && (xs_stil_init() != 0))
99
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
214 {
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
215 XSERR("Error initializing STIL database!\n");
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
216 }
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
217 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
219
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
220 /*
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
221 * Initialize XMMS-SID
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
222 */
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
223 void xs_init(void)
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
224 {
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
225 XSDEBUG("xs_init()\n");
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
226
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
227 /* Initialize and get configuration */
213
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
228 xs_memset(&xs_cfg, 0, sizeof(xs_cfg));
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
229 xs_init_configuration();
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
230 xs_read_configuration();
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
231
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
232 /* Initialize subsystems */
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
233 xs_reinit();
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
234
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 XSDEBUG("OK\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 * Shut down XMMS-SID
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 void xs_close(void)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 XSDEBUG("xs_close(): shutting down...\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
246 /* Stop playing, free structures */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 xs_stop();
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
249 xs_tuneinfo_free(xs_status.tuneInfo);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
250 xs_status.tuneInfo = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
251 xs_status.sidPlayer->plrDeleteSID(&xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
252 xs_status.sidPlayer->plrClose(&xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 xs_songlen_close();
99
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
255 xs_stil_close();
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
256
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 XSDEBUG("shutdown finished.\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 /*
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
262 * Check whether the given file is handled by this plugin
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
263 */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
264 gint xs_is_our_file(gchar *pcFilename)
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
265 {
225
2986069309c6 char -> gchar
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
266 gchar *pcExt;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
267 assert(xs_status.sidPlayer);
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
268
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
269 /* Check the filename */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
270 if (pcFilename == NULL)
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
271 return FALSE;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
272
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
273 /* Try to detect via detection routine, if required */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
274 if (xs_cfg.detectMagic && xs_status.sidPlayer->plrIsOurFile(pcFilename))
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
275 return TRUE;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
276
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
277 /* Detect just by checking filename extension */
212
ebb6e23f6015 Use xs_strrchr()
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
278 pcExt = xs_strrchr(pcFilename, '.');
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
279 if (pcExt)
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
280 {
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
281 pcExt++;
84
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
282 switch (xs_cfg.playerEngine) {
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
283 case XS_ENG_SIDPLAY1:
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
284 case XS_ENG_SIDPLAY2:
208
8ebef120d67f Use glib string functions more exclusively, moved fileinfo dialog
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
285 if (!g_strcasecmp(pcExt, "psid")) return TRUE;
8ebef120d67f Use glib string functions more exclusively, moved fileinfo dialog
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
286 if (!g_strcasecmp(pcExt, "sid")) return TRUE;
8ebef120d67f Use glib string functions more exclusively, moved fileinfo dialog
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
287 if (!g_strcasecmp(pcExt, "dat")) return TRUE;
8ebef120d67f Use glib string functions more exclusively, moved fileinfo dialog
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
288 if (!g_strcasecmp(pcExt, "inf")) return TRUE;
8ebef120d67f Use glib string functions more exclusively, moved fileinfo dialog
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
289 if (!g_strcasecmp(pcExt, "info")) return TRUE;
84
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
290 break;
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
291 }
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
292 }
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
293
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
294 return FALSE;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
295 }
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
296
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
297
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
298 /*
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 * Main playing thread loop
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 */
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
301 void *xs_playthread(void *argPointer)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 t_xs_status myStatus;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
304 t_xs_tuneinfo *myTune;
281
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
305 gboolean audioOpen = FALSE, doPlay = FALSE, isFound = FALSE;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
306 gboolean playedTune[XS_STIL_MAXENTRY];
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
307 gint audioGot, songLength, i;
241
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
308 #ifdef XS_BUF_DYNAMIC
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
309 gchar *audioBuffer = NULL, *oversampleBuffer = NULL;
241
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
310 #else
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
311 gchar audioBuffer[XS_AUDIOBUF_SIZE], oversampleBuffer[(XS_AUDIOBUF_SIZE * XS_MAX_OVERSAMPLE)];
241
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
312 #endif
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
314 /* Initialize */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
315 XSDEBUG("entering player thread\n");
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
316 XS_MUTEX_LOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 memcpy(&myStatus, &xs_status, sizeof(t_xs_status));
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
318 myTune = xs_status.tuneInfo;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
319 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320
281
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
321 xs_memset(&playedTune, 0, sizeof(playedTune));
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
322 audioBuffer = oversampleBuffer = NULL;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
323
241
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
324 /* Allocate audio buffer */
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
325 #ifdef XS_BUF_DYNAMIC
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
326 audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE);
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
327 if (audioBuffer == NULL)
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
328 {
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
329 XSERR("Couldn't allocate memory for audio data buffer!\n");
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
330 goto xs_err_exit;
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
331 }
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
332
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
333 if (myStatus.oversampleEnable)
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
334 {
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
335 oversampleBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE * myStatus.oversampleFactor);
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
336 if (oversampleBuffer == NULL)
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
337 {
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
338 XSERR("Couldn't allocate memory for audio oversampling buffer!\n");
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
339 goto xs_err_exit;
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
340 }
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
341 }
241
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
342 #endif
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
343
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 * Main player loop: while not stopped, loop here - play subtunes
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 */
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
347 audioOpen = FALSE;
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
348 doPlay = TRUE;
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
349 while (xs_status.isPlaying && doPlay)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 {
306
e6dec620b1b3 Improved locking, still some unlocked parts left, but nothing dangerous.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
351 /* Automatic sub-tune change logic */
e6dec620b1b3 Improved locking, still some unlocked parts left, but nothing dangerous.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
352 XS_MUTEX_LOCK(xs_cfg);
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
353 XS_MUTEX_LOCK(xs_status);
281
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
354 assert(xs_status.currSong >= 1);
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
355 assert(xs_status.currSong <= XS_STIL_MAXENTRY);
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
356 myStatus.isPlaying = TRUE;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
357
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
358 if (xs_cfg.subAutoEnable && (myStatus.currSong == xs_status.currSong))
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
359 {
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
360 /* Check if currently selected sub-tune has been played already */
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
361 if (playedTune[myStatus.currSong - 1])
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
362 {
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
363 /* Find a tune that has not been played */
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
364 XSDEBUG("tune #%i already played, finding next match ...\n", myStatus.currSong);
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
365 isFound = FALSE;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
366 i = 0;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
367 while (!isFound && (i < myTune->nsubTunes))
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
368 {
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
369 if (xs_cfg.subAutoMinOnly)
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
370 {
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
371 /* A tune with minimum length must be found */
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
372 if (!playedTune[i] && myTune->subTunes[i].tuneLength >= xs_cfg.subAutoMinTime)
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
373 isFound = TRUE;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
374 } else {
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
375 /* Any unplayed tune is okay */
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
376 if (!playedTune[i])
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
377 isFound = TRUE;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
378 }
306
e6dec620b1b3 Improved locking, still some unlocked parts left, but nothing dangerous.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
379
e6dec620b1b3 Improved locking, still some unlocked parts left, but nothing dangerous.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
380 /* currSong = i + 1 anyway, so we get it free here */
281
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
381 i++;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
382 }
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
383
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
384 if (isFound)
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
385 {
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
386 /* Set the new sub-tune */
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
387 XSDEBUG("found #%i\n", i);
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
388 xs_status.currSong = i;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
389 } else
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
390 /* This is the end */
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
391 doPlay = FALSE;
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
392
306
e6dec620b1b3 Improved locking, still some unlocked parts left, but nothing dangerous.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
393 XS_MUTEX_UNLOCK(xs_status);
e6dec620b1b3 Improved locking, still some unlocked parts left, but nothing dangerous.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
394 XS_MUTEX_UNLOCK(xs_cfg);
281
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
395 continue; /* This is ugly, but ... */
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
396 }
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
397 }
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
398
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
399 /* Tell that we are initializing, update sub-tune controls */
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
400 myStatus.currSong = xs_status.currSong;
306
e6dec620b1b3 Improved locking, still some unlocked parts left, but nothing dangerous.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
401 playedTune[myStatus.currSong - 1] = TRUE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
402 XS_MUTEX_UNLOCK(xs_status);
306
e6dec620b1b3 Improved locking, still some unlocked parts left, but nothing dangerous.
Matti Hamalainen <ccr@tnsp.org>
parents: 299
diff changeset
403 XS_MUTEX_UNLOCK(xs_cfg);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
405 XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
407 GDK_THREADS_ENTER();
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
408 xs_subctrl_update();
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
409 GDK_THREADS_LEAVE();
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
410
281
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
411 /* Check minimum playtime */
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
412 songLength = myTune->subTunes[myStatus.currSong - 1].tuneLength;
308
ae5795ba5c77 Remove "only when song-length unknown" option from minimum playtime, it
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
413 if (xs_cfg.playMinTimeEnable && (songLength >= 0))
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
414 {
308
ae5795ba5c77 Remove "only when song-length unknown" option from minimum playtime, it
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
415 if (songLength < xs_cfg.playMinTime)
ae5795ba5c77 Remove "only when song-length unknown" option from minimum playtime, it
Matti Hamalainen <ccr@tnsp.org>
parents: 307
diff changeset
416 songLength = xs_cfg.playMinTime;
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
417 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 /* Initialize song */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
420 if (!myStatus.sidPlayer->plrInitSong(&myStatus))
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422 XSERR("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n",
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
423 myTune->sidFilename, myStatus.currSong);
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
424 goto xs_err_exit;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
425 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
428 /* Open the audio output */
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
429 if (!xs_plugin_ip.output->open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels))
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
430 {
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
431 XSERR("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n",
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
432 myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels);
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
433
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
434 XS_MUTEX_LOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
435 xs_status.isError = TRUE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
436 XS_MUTEX_UNLOCK(xs_status);
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
437 goto xs_err_exit;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440 audioOpen = TRUE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
442 /* Set song information for current subtune */
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
443 xs_plugin_ip.set_info(
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
444 myTune->subTunes[myStatus.currSong - 1].tuneTitle,
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
445 (songLength > 0) ? (songLength * 1000) : -1,
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
446 (myTune->subTunes[myStatus.currSong - 1].tuneSpeed > 0) ? (myTune->subTunes[myStatus.currSong - 1].tuneSpeed * 1000) : -1,
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
447 myStatus.audioFrequency,
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
448 myStatus.audioChannels);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
449
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
450
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
451 XSDEBUG("playing\n");
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
452
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454 * Play the subtune
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455 */
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
456 while (xs_status.isPlaying && myStatus.isPlaying && (xs_status.currSong == myStatus.currSong))
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
457 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458 /* Render audio data */
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
459 if (myStatus.oversampleEnable)
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
460 {
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
461 /* Perform oversampled rendering */
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
462 audioGot = myStatus.sidPlayer->plrFillBuffer(&myStatus,
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
463 oversampleBuffer, (XS_AUDIOBUF_SIZE * myStatus.oversampleFactor));
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
464
277
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
465 audioGot /= myStatus.oversampleFactor;
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
466
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
467 /* Execute rate-conversion with filtering */
324
dd201740a720 Changed copyright text.
Matti Hamalainen <ccr@tnsp.org>
parents: 313
diff changeset
468 if (xs_filter_rateconv(audioBuffer, oversampleBuffer,
277
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
469 myStatus.audioFormat, myStatus.oversampleFactor,
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
470 audioGot) < 0)
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
471 {
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
472 XSERR("Oversampling rate-conversion pass failed.\n");
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
473 XS_MUTEX_LOCK(xs_status);
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
474 xs_status.isError = TRUE;
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
475 XS_MUTEX_UNLOCK(xs_status);
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
476 goto xs_err_exit;
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
477 }
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
478 } else
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
479 audioGot = myStatus.sidPlayer->plrFillBuffer(&myStatus, audioBuffer, XS_AUDIOBUF_SIZE);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
480
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
481 /* I <3 visualice/haujobb */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 xs_plugin_ip.add_vis_pcm(
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
483 xs_plugin_ip.output->written_time(),
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
484 myStatus.audioFormat, myStatus.audioChannels,
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
485 audioGot, audioBuffer);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487 /* Wait a little */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488 while (xs_status.isPlaying &&
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
489 (xs_status.currSong == myStatus.currSong) &&
277
c27763d388d9 Fixed oversampling buffer overflow problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
490 (xs_plugin_ip.output->buffer_free() < audioGot))
235
d04191d1ea64 Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
491 xmms_usleep(500);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493 /* Output audio */
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
494 if (xs_status.isPlaying && (xs_status.currSong == myStatus.currSong))
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
495 xs_plugin_ip.output->write_audio(audioBuffer, audioGot);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 /* Check if we have played enough */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 if (xs_cfg.playMaxTimeEnable)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
500 if (xs_cfg.playMaxTimeUnknown)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501 {
299
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
502 if ((songLength < 0) &&
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000)))
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504 myStatus.isPlaying = FALSE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505 } else {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 if (xs_plugin_ip.output->output_time() >= (xs_cfg.playMaxTime * 1000))
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507 myStatus.isPlaying = FALSE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510
299
Matti Hamalainen <ccr@tnsp.org>
parents: 298
diff changeset
511 if (songLength >= 0)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 if (xs_plugin_ip.output->output_time() >= (songLength * 1000))
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
514 myStatus.isPlaying = FALSE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
517
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518 XSDEBUG("subtune ended/stopped\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
519
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
520 /* Close audio output plugin */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521 if (audioOpen)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523 XSDEBUG("close audio #1\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524 xs_plugin_ip.output->close_audio();
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525 audioOpen = FALSE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
528 /* Now determine if we continue by selecting other subtune or something */
281
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
529 if (!myStatus.isPlaying && !xs_cfg.subAutoEnable)
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
530 doPlay = FALSE;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
531 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
533 xs_err_exit:
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
534 /* Close audio output plugin */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
535 if (audioOpen)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
536 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
537 XSDEBUG("close audio #2\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
538 xs_plugin_ip.output->close_audio();
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
540
241
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
541 #ifdef XS_BUF_DYNAMIC
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
542 g_free(audioBuffer);
273
f6daddca03c7 Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
543 g_free(oversampleBuffer);
241
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
544 #endif
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
545
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
546 /* Set playing status to false (stopped), thus when
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
547 * XMMS next calls xs_get_time(), it can return appropriate
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
548 * value "not playing" status and XMMS knows to move to
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
549 * next entry in the playlist .. or whatever it wishes.
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
550 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
551 XS_MUTEX_LOCK(xs_status);
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
552 xs_status.isPlaying = FALSE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
553 XS_MUTEX_UNLOCK(xs_status);
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
554
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
555 /* Exit the playing thread */
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
556 XSDEBUG("exiting thread, bye.\n");
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
557 pthread_exit(NULL);
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
558 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
559
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
560
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
561 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
562 * Start playing the given file
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
563 * Here we load the tune and initialize the playing thread.
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
564 * Usually you would also initialize the output-plugin, but
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
565 * this is XMMS-SID and we do it on the player thread instead.
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
567 void xs_play_file(gchar *pcFilename)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
569 assert(xs_status.sidPlayer);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
570
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
571 XSDEBUG("play '%s'\n", pcFilename);
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
572
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
573 /* Get tune information */
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
574 if ((xs_status.tuneInfo =
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
575 xs_status.sidPlayer->plrGetSIDInfo(pcFilename)) == NULL)
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
576 return;
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
577
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
578 /* Initialize the tune */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
579 if (!xs_status.sidPlayer->plrLoadSID(&xs_status, pcFilename))
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
580 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
581 xs_tuneinfo_free(xs_status.tuneInfo);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
582 xs_status.tuneInfo = NULL;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
583 return;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
584 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
585
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
586 XSDEBUG("load ok\n");
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
587
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
588 /* Set general status information */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
589 xs_status.isPlaying = TRUE;
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
590 xs_status.isError = FALSE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
591 xs_status.currSong = xs_status.tuneInfo->startTune;
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
592
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
593 /* Start the playing thread! */
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
594 if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0)
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
595 {
235
d04191d1ea64 Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents: 232
diff changeset
596 XSERR("Couldn't start playing thread!\n");
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
597 xs_tuneinfo_free(xs_status.tuneInfo);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
598 xs_status.tuneInfo = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
599 xs_status.sidPlayer->plrDeleteSID(&xs_status);
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
600 }
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
601
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
602 /* Okay, here the playing thread has started up and we
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
603 * return from here to XMMS. Rest is up to XMMS's GUI
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
604 * and playing thread.
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
605 */
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
606 XSDEBUG("systems should be up?\n");
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
607 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
608
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
609
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
610 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
611 * Stop playing
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
612 * Here we set the playing status to stop and wait for playing
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
613 * thread to shut down. In any "correctly" done plugin, this is
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
614 * also the function where you close the output-plugin, but since
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
615 * XMMS-SID has special behaviour (audio opened/closed in the
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
616 * playing thread), we don't do that here.
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
617 *
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
618 * Finally tune and other memory allocations are free'd.
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
619 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
620 void xs_stop(void)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
621 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
622 XSDEBUG("STOP_REQ\n");
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
623
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
624 /* Close the sub-tune control window, if any */
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
625 xs_subctrl_close();
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
626
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
627 /* Lock xs_status and stop playing thread */
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
628 XS_MUTEX_LOCK(xs_status);
74
8cb66a3f75f7 Testing
Matti Hamalainen <ccr@tnsp.org>
parents: 73
diff changeset
629 if (xs_status.isPlaying)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
630 {
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
631 /* Stop playing */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
632 XSDEBUG("stopping...\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633 xs_status.isPlaying = FALSE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
634 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
635 pthread_join(xs_decode_thread, NULL);
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
636 } else {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
637 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
638 }
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
639
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
640 /* Status is now stopped, update the sub-tune
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
641 * controller in fileinfo window (if open)
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
642 */
241
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
643 xs_fileinfo_update();
291715a519e2 Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
644
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
645 /* Free tune information */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
646 xs_status.sidPlayer->plrDeleteSID(&xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
647 xs_tuneinfo_free(xs_status.tuneInfo);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
648 xs_status.tuneInfo = NULL;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
649 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
650
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
651
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
652 /*
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
653 * Pause/unpause the playing
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
654 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
655 void xs_pause(short pauseState)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
656 {
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
657 XS_MUTEX_LOCK(xs_status);
281
d913f0f69487 Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents: 277
diff changeset
658 /* FIXME FIX ME todo: pause should disable sub-tune controls */
264
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
659 XS_MUTEX_UNLOCK(xs_status);
2316e524d67b Improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
660
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
661 xs_subctrl_close();
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
662 xs_fileinfo_update();
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
663 xs_plugin_ip.output->pause(pauseState);
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
664 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
665
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
666
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
667 /*
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
668 * Pop-up subtune selector
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
669 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
670 void xs_subctrl_setsong(void)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
671 {
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
672 gint n;
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
673
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
674 XS_MUTEX_LOCK(xs_status);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
675 XS_MUTEX_LOCK(xs_subctrl);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
676
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
677 if (xs_status.tuneInfo && xs_status.isPlaying)
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
678 {
294
f0ece2d20094 Do correct typecasts and declare xs_subctrl_open arguments as void.
Matti Hamalainen <ccr@tnsp.org>
parents: 281
diff changeset
679 n = (gint) GTK_ADJUSTMENT(xs_subctrl_adj)->value;
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
680 if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes))
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
681 xs_status.currSong = n;
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
682 }
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
683
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
684 XS_MUTEX_UNLOCK(xs_subctrl);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
685 XS_MUTEX_UNLOCK(xs_status);
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
686 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
687
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
688
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
689 void xs_subctrl_prevsong(void)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
690 {
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
691 XS_MUTEX_LOCK(xs_status);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
692
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
693 if (xs_status.tuneInfo && xs_status.isPlaying)
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
694 {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
695 if (xs_status.currSong > 1)
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
696 xs_status.currSong--;
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
697 }
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
698
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
699 XS_MUTEX_UNLOCK(xs_status);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
700
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
701 xs_subctrl_update();
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
702 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
703
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
704
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
705 void xs_subctrl_nextsong(void)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
706 {
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
707 XS_MUTEX_LOCK(xs_status);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
708
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
709 if (xs_status.tuneInfo && xs_status.isPlaying)
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
710 {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
711 if (xs_status.currSong < xs_status.tuneInfo->nsubTunes)
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
712 xs_status.currSong++;
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
713 }
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
714
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
715 XS_MUTEX_UNLOCK(xs_status);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
716
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
717 xs_subctrl_update();
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
718 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
719
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
720
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
721 void xs_subctrl_update(void)
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
722 {
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
723 GtkAdjustment *tmpAdj;
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
724
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
725 XS_MUTEX_LOCK(xs_status);
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
726 XS_MUTEX_LOCK(xs_subctrl);
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
727
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
728 /* Check if control window exists, we are currently playing and have a tune */
189
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
729 if (xs_subctrl)
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
730 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
731 if (xs_status.tuneInfo && xs_status.isPlaying)
189
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
732 {
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
733 tmpAdj = GTK_ADJUSTMENT(xs_subctrl_adj);
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
734
189
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
735 tmpAdj->value = xs_status.currSong;
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
736 tmpAdj->lower = 1;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
737 tmpAdj->upper = xs_status.tuneInfo->nsubTunes;
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
738 XS_MUTEX_UNLOCK(xs_status);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
739 XS_MUTEX_UNLOCK(xs_subctrl);
189
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
740 gtk_adjustment_value_changed(tmpAdj);
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
741 } else {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
742 XS_MUTEX_UNLOCK(xs_status);
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
743 XS_MUTEX_UNLOCK(xs_subctrl);
189
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
744 xs_subctrl_close();
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
745 }
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
746 } else {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
747 XS_MUTEX_UNLOCK(xs_subctrl);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
748 XS_MUTEX_UNLOCK(xs_status);
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
749 }
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
750
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
751 xs_fileinfo_update();
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
752 }
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
753
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
754
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
755 void xs_subctrl_close(void)
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
756 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
757 XS_MUTEX_LOCK(xs_subctrl);
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
758
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
759 if (xs_subctrl)
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
760 {
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
761 gtk_widget_destroy(xs_subctrl);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
762 xs_subctrl = NULL;
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
763 }
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
764
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
765 XS_MUTEX_UNLOCK(xs_subctrl);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
766 }
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
767
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
768
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
769 gboolean xs_subctrl_keypress(GtkWidget *win, GdkEventKey *ev)
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
770 {
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
771 if (ev->keyval == GDK_Escape)
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
772 xs_subctrl_close();
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
773
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
774 return FALSE;
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
775 }
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
776
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
777
294
f0ece2d20094 Do correct typecasts and declare xs_subctrl_open arguments as void.
Matti Hamalainen <ccr@tnsp.org>
parents: 281
diff changeset
778 void xs_subctrl_open(void)
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
779 {
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
780 GtkWidget *frame25, *hbox15, *subctrl_prev, *subctrl_current, *subctrl_next;
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
781
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
782 XS_MUTEX_LOCK(xs_subctrl);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
783 if (!xs_status.tuneInfo || !xs_status.isPlaying ||
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
784 xs_subctrl || (xs_status.tuneInfo->nsubTunes <= 1))
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
785 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
786 XS_MUTEX_UNLOCK(xs_subctrl);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
787 return;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
788 }
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
789
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
790 /* Create the pop-up window */
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
791 xs_subctrl = gtk_window_new (GTK_WINDOW_DIALOG);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
792 gtk_widget_set_name (xs_subctrl, "xs_subctrl");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
793 gtk_object_set_data (GTK_OBJECT (xs_subctrl), "xs_subctrl", xs_subctrl);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
794
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
795 gtk_window_set_title(GTK_WINDOW(xs_subctrl), "Subtune Control");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
796 gtk_window_set_position(GTK_WINDOW(xs_subctrl), GTK_WIN_POS_MOUSE);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
797 gtk_container_set_border_width(GTK_CONTAINER(xs_subctrl), 0);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
798 gtk_window_set_policy(GTK_WINDOW(xs_subctrl), FALSE, FALSE, FALSE);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
799
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
800 gtk_signal_connect(GTK_OBJECT(xs_subctrl), "destroy",
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
801 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &xs_subctrl);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
802
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
803 gtk_signal_connect(GTK_OBJECT(xs_subctrl), "focus_out_event",
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
804 GTK_SIGNAL_FUNC(xs_subctrl_close), NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
805
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
806 gtk_widget_realize(xs_subctrl);
294
f0ece2d20094 Do correct typecasts and declare xs_subctrl_open arguments as void.
Matti Hamalainen <ccr@tnsp.org>
parents: 281
diff changeset
807 gdk_window_set_decorations(xs_subctrl->window, (GdkWMDecoration) 0);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
808
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
809
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
810 /* Create the control widgets */
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
811 frame25 = gtk_frame_new (NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
812 gtk_container_add (GTK_CONTAINER (xs_subctrl), frame25);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
813 gtk_container_set_border_width (GTK_CONTAINER (frame25), 2);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
814 gtk_frame_set_shadow_type (GTK_FRAME (frame25), GTK_SHADOW_OUT);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
815
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
816 hbox15 = gtk_hbox_new (FALSE, 4);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
817 gtk_container_add (GTK_CONTAINER (frame25), hbox15);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
818
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
819 subctrl_prev = gtk_button_new_with_label (" < ");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
820 gtk_widget_set_name (subctrl_prev, "subctrl_prev");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
821 gtk_box_pack_start (GTK_BOX (hbox15), subctrl_prev, FALSE, FALSE, 0);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
822
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
823 xs_subctrl_adj = gtk_adjustment_new (xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes, 1, 1, 0);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
824 gtk_signal_connect (GTK_OBJECT (xs_subctrl_adj), "value_changed",
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
825 GTK_SIGNAL_FUNC (xs_subctrl_setsong), NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
826
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
827 subctrl_current = gtk_hscale_new (GTK_ADJUSTMENT(xs_subctrl_adj));
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
828 gtk_widget_set_name (subctrl_current, "subctrl_current");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
829 gtk_box_pack_start (GTK_BOX (hbox15), subctrl_current, FALSE, TRUE, 0);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
830 gtk_scale_set_digits (GTK_SCALE (subctrl_current), 0);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
831 gtk_range_set_update_policy (GTK_RANGE (subctrl_current), GTK_UPDATE_DELAYED);
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
832 gtk_widget_grab_focus (subctrl_current);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
833
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
834 subctrl_next = gtk_button_new_with_label (" > ");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
835 gtk_widget_set_name (subctrl_next, "subctrl_next");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
836 gtk_box_pack_start (GTK_BOX (hbox15), subctrl_next, FALSE, FALSE, 0);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
837
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
838 gtk_signal_connect (GTK_OBJECT (subctrl_prev), "clicked",
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
839 GTK_SIGNAL_FUNC (xs_subctrl_prevsong), NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
840
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
841 gtk_signal_connect (GTK_OBJECT (subctrl_next), "clicked",
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
842 GTK_SIGNAL_FUNC (xs_subctrl_nextsong), NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
843
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
844 gtk_signal_connect (GTK_OBJECT (xs_subctrl), "key_press_event",
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
845 GTK_SIGNAL_FUNC (xs_subctrl_keypress), NULL);
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
846
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
847 gtk_widget_show_all(xs_subctrl);
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
848
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
849 XS_MUTEX_UNLOCK(xs_subctrl);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
850 }
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
851
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
852
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
853 /*
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
854 * Set the time-seek position
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
855 * The playing thread will do the "seeking", which means sub-tune
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
856 * changing in XMMS-SID's case. iTime argument is time in seconds,
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
857 * in contrast to milliseconds used in other occasions.
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
858 *
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
859 * This function is called whenever position slider is clicked or
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
860 * other method of seeking is used (keyboard, etc.)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
861 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
862 void xs_seek(gint iTime)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
863 {
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
864 /* Check status */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
865 XS_MUTEX_LOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
866 if (!xs_status.tuneInfo || !xs_status.isPlaying)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
867 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
868 XS_MUTEX_UNLOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
869 return;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
870 }
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
871
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
872 /* Act according to settings */
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
873 switch (xs_cfg.subsongControl) {
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
874 case XS_SSC_SEEK:
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
875 if (iTime < xs_status.lastTime)
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
876 {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
877 if (xs_status.currSong > 1)
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
878 xs_status.currSong--;
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
879 } else
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
880 if (iTime > xs_status.lastTime)
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
881 {
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
882 if (xs_status.currSong < xs_status.tuneInfo->nsubTunes)
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
883 xs_status.currSong++;
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
884 }
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
885 break;
78
ab522ab65c85 Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
886
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
887 case XS_SSC_POPUP:
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
888 xs_subctrl_open();
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
889 break;
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
890
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
891 /* If we have song-position patch, check settings */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
892 #ifdef HAVE_SONG_POSITION
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
893 case XS_SSC_PATCH:
232
e613873c3379 Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
894 if ((iTime >= 1) && (iTime <= xs_status.tuneInfo->nsubTunes))
78
ab522ab65c85 Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
895 xs_status.currSong = iTime;
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
896 break;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
897 #endif
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
898 }
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
899
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
900 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
901 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
902
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
903
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
904 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
905 * Return the playing "position/time"
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
906 * Determine current position/time in song. Used by XMMS to update
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
907 * the song clock and position slider and MOST importantly to determine
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
908 * END OF SONG! Return value of -2 means error, XMMS opens an audio
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
909 * error dialog. -1 means end of song (if one was playing currently).
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
910 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
911 gint xs_get_time(void)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
912 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
913 /* If errorflag is set, return -2 to signal it to XMMS's idle callback */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
914 XS_MUTEX_LOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
915 if (xs_status.isError)
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
916 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
917 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
918 return -2;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
919 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
920
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
921 /* If there is no tune, return -1 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
922 if (!xs_status.tuneInfo)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
923 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
924 XS_MUTEX_UNLOCK(xs_status);
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
925 return -1;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
926 }
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
927
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
928 /* If tune has ended, return -1 */
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
929 if (!xs_status.isPlaying)
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
930 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
931 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
932 return -1;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
933 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
934
78
ab522ab65c85 Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
935 /* Let's see what we do */
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
936 switch (xs_cfg.subsongControl) {
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
937 case XS_SSC_SEEK:
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
938 xs_status.lastTime = (xs_plugin_ip.output->output_time() / 1000);
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
939 break;
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
940
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
941 #ifdef HAVE_SONG_POSITION
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
942 case XS_SSC_PATCH:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
943 set_song_position(xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes);
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
944 break;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
945 #endif
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
946 }
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
947
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
948 XS_MUTEX_UNLOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
949
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
950 /* Return output time reported by audio output plugin */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
951 return xs_plugin_ip.output->output_time();
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
952 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
953
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
954
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
955 /*
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
956 * Return song information
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
957 * This function is called by XMMS when initially loading the playlist.
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
958 * Subsequent changes to information are made by the player thread,
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
959 * which uses xs_plugin_ip.set_info();
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
960 */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
961 void xs_get_song_info(gchar *songFilename, gchar **songTitle, gint *songLength)
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
962 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
963 t_xs_tuneinfo *pInfo;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
964 gint tmpInt;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
965
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
966 /* Get tune information from emulation engine */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
967 pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename);
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
968 if (!pInfo) return;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
969
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
970 /* Get sub-tune information, if available */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
971 if ((pInfo->startTune >= 0) && (pInfo->startTune <= pInfo->nsubTunes))
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
972 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
973 (*songTitle) = g_strdup(pInfo->subTunes[pInfo->startTune - 1].tuneTitle);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
974
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
975 tmpInt = pInfo->subTunes[pInfo->startTune - 1].tuneLength;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
976 if (tmpInt < 0)
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
977 (*songLength) = -1;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
978 else
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
979 (*songLength) = (tmpInt * 1000);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
980 }
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
981
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
982 /* Free tune information */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
983 xs_tuneinfo_free(pInfo);
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
984 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
985
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
986
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
987 /* Allocate a new tune information structure
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
988 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
989 t_xs_tuneinfo *xs_tuneinfo_new(gchar *pcFilename, gint nsubTunes, gint startTune,
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
990 gchar *sidName, gchar *sidComposer, gchar *sidCopyright,
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
991 gint loadAddr, gint initAddr, gint playAddr, gint dataFileLen)
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
992 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
993 t_xs_tuneinfo *pResult;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
994
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
995 pResult = (t_xs_tuneinfo *) g_malloc0(sizeof(t_xs_tuneinfo));
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
996 if (!pResult) return NULL;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
997
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
998 pResult->sidFilename = g_strdup(pcFilename);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
999 if (!pResult->sidFilename)
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1000 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1001 g_free(pResult);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1002 return NULL;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1003 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1004
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1005 pResult->sidName = g_strdup(sidName);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1006 pResult->sidComposer = g_strdup(sidComposer);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1007 pResult->sidCopyright = g_strdup(sidCopyright);
106
98a72c44f56b Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
1008 pResult->nsubTunes = nsubTunes;
98a72c44f56b Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
1009 pResult->startTune = startTune;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1010
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1011 pResult->loadAddr = loadAddr;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1012 pResult->initAddr = initAddr;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1013 pResult->playAddr = playAddr;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1014 pResult->dataFileLen = dataFileLen;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1015
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1016 return pResult;
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
1017 }
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1018
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1019
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1020 /* Free given tune information structure
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1021 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1022 void xs_tuneinfo_free(t_xs_tuneinfo *pTune)
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1023 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1024 gint i;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1025 if (!pTune) return;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1026
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1027 g_free(pTune->sidFilename); pTune->sidFilename = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1028 g_free(pTune->sidName); pTune->sidName = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1029 g_free(pTune->sidComposer); pTune->sidComposer = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
1030 g_free(pTune->sidCopyright); pTune->sidCopyright = NULL;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1031
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1032 for (i = 0; i < pTune->nsubTunes; i++)
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1033 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1034 if (pTune->subTunes[i].tuneTitle)
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1035 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1036 g_free(pTune->subTunes[i].tuneTitle);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1037 pTune->subTunes[i].tuneTitle = NULL;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1038 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1039 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1040
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1041 g_free(pTune);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1042 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
1043