annotate src/xmms-sid.c @ 294:f0ece2d20094

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