annotate src/xmms-sid.c @ 297:ac9a484e3430

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