annotate src/xmms-sid.c @ 230:608f31f6c095

Raw cleanup.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 21 Dec 2004 09:25:03 +0000
parents 2986069309c6
children e613873c3379
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 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 #include <pthread.h>
213
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
23
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
24 #ifdef HAVE_STRING_H
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 #include <string.h>
213
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
26 #else
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
27 #ifdef HAVE_STRINGS_H
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
28 #include <strings.h>
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
29 #endif
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
30 #endif
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
31
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 #include <stdio.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
33
16e3b2446a73 On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents: 213
diff changeset
34 #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
35 #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
36 #endif
16e3b2446a73 On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents: 213
diff changeset
37
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 #include <errno.h>
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 #include <xmms/plugin.h>
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
41 #include <xmms/util.h>
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
43 #include <gdk/gdkkeysyms.h>
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
44 #include <gtk/gtk.h>
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 #include "xs_support.h"
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 #include "xs_config.h"
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 #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
48 #include "xs_stil.h"
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 #include "xs_interface.h"
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 #include "xs_glade.h"
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
52
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 * Include player engines
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 */
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
56 #ifdef HAVE_SIDPLAY1
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 #include "xs_sidplay1.h"
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
58 #endif
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
59 #ifdef HAVE_SIDPLAY2
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 #include "xs_sidplay2.h"
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
61 #endif
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
62
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
63
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
64 /*
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
65 * List of players and links to their functions
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
66 */
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
67 t_xs_player xs_playerlist[] = {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
68 #ifdef HAVE_SIDPLAY1
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
69 { XS_ENG_SIDPLAY1,
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
70 xs_sidplay1_isourfile,
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
71 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
72 xs_sidplay1_initsong, xs_sidplay1_fillbuffer,
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
73 xs_sidplay1_loadsid, xs_sidplay1_deletesid,
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
74 xs_sidplay1_getsidinfo
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
75 },
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
76 #endif
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
77 #ifdef HAVE_SIDPLAY2
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
78 { XS_ENG_SIDPLAY2,
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
79 xs_sidplay2_isourfile,
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
80 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
81 xs_sidplay2_initsong, xs_sidplay2_fillbuffer,
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
82 xs_sidplay2_loadsid, xs_sidplay2_deletesid,
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
83 xs_sidplay2_getsidinfo
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
84 },
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
85 #endif
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
86 };
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
87
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
88 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
89
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 * Global variables
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
94 t_xs_status xs_status;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
95 XS_MUTEX(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
96 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
97
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
98 static GtkWidget *xs_subctrl = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
99 static GtkObject *xs_subctrl_adj = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
100 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
101
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
102 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
103 void xs_subctrl_update(void);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
105
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 /*
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
107 * Initialization functions
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 */
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
109 void xs_reinit(void)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 {
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
111 gint iPlayer;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
112 gboolean isInitialized;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
113
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
114 /* Stop playing, if we are */
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
115 if (xs_status.isPlaying)
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
116 xs_stop();
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
117
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 /* Initialize status */
213
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
119 xs_memset(&xs_status, 0, sizeof(xs_status));
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
120 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
121 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
122 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
123 xs_status.audioFormat = -1;
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
124
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
125 /* Try to initialize emulator engine */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
126 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
127
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
128 iPlayer = 0;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
129 isInitialized = FALSE;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
130 while ((iPlayer < xs_nplayerlist) && !isInitialized)
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
131 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
132 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
133 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
134 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
135 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
136 isInitialized = TRUE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
137 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
138 }
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
139 }
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
140 iPlayer++;
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
141 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
143 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
144
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
145 iPlayer = 0;
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
146 while ((iPlayer < xs_nplayerlist) && !isInitialized)
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
147 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
148 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
149 {
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
150 isInitialized = TRUE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
151 xs_status.sidPlayer = (t_xs_player *) &xs_playerlist[iPlayer];
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
152 } else
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
153 iPlayer++;
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
154 }
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
155
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
156 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
157
99
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
158 /* Initialize song-length database */
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
159 xs_songlen_close();
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
160 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
161 {
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 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
163 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164
99
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
165 /* Initialize STIL database */
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
166 xs_stil_close();
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
167 if (xs_cfg.stilDBEnable && (xs_stil_init() != 0))
99
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
168 {
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
169 XSERR("Error initializing STIL database!\n");
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
170 }
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
171 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
173
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
174 /*
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
175 * Initialize XMMS-SID
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
176 */
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
177 void xs_init(void)
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
178 {
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
179 XSDEBUG("xs_init()\n");
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
180
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
181 /* Initialize and get configuration */
213
405b647cbd8d Use xs_memset() instead of memset() directly
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
182 xs_memset(&xs_cfg, 0, sizeof(xs_cfg));
147
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
183 xs_read_configuration();
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
184
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
185 /* Initialize subsystems */
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
186 xs_reinit();
a7abcda7a86c SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents: 140
diff changeset
187
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 XSDEBUG("OK\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 * Shut down XMMS-SID
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 void xs_close(void)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 XSDEBUG("xs_close(): shutting down...\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
199 /* Stop playing, free structures */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 xs_stop();
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
202 xs_tuneinfo_free(xs_status.tuneInfo);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
203 xs_status.tuneInfo = NULL;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
204
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
205 xs_status.sidPlayer->plrDeleteSID(&xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
206 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
207
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 xs_songlen_close();
99
2bc56809ec0b STIL-support fixes, variable renaming
Matti Hamalainen <ccr@tnsp.org>
parents: 91
diff changeset
209 xs_stil_close();
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
210
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 XSDEBUG("shutdown finished.\n");
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
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 /*
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
216 * 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
217 */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
218 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
219 {
225
2986069309c6 char -> gchar
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
220 gchar *pcExt;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
221 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
222
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
223 /* Check the filename */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
224 if (pcFilename == NULL)
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
225 return FALSE;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
226
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
227 /* Try to detect via detection routine, if required */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
228 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
229 return TRUE;
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
230
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
231 /* Detect just by checking filename extension */
212
ebb6e23f6015 Use xs_strrchr()
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
232 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
233 if (pcExt)
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
234 {
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
235 pcExt++;
84
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
236 switch (xs_cfg.playerEngine) {
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
237 case XS_ENG_SIDPLAY1:
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
238 case XS_ENG_SIDPLAY2:
208
8ebef120d67f Use glib string functions more exclusively, moved fileinfo dialog
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
239 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
240 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
241 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
242 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
243 if (!g_strcasecmp(pcExt, "info")) return TRUE;
84
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
244 break;
b6966a2447bc Added some stuff for NanoSID
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
245 }
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
246 }
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
247
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
248 return FALSE;
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
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
251
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
252 /*
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 * Main playing thread loop
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 void *xs_play_loop(void *argPointer)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 t_xs_status myStatus;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
258 t_xs_tuneinfo *myTune;
106
98a72c44f56b Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
259 gboolean audioOpen = FALSE, doPlay = FALSE;
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
260 guint audioGot;
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
261 gint songLength;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 gchar audioBuffer[XS_BUFSIZE];
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
264 /* Initialize */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
265 XSDEBUG("entering player thread\n");
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
266 XS_MUTEX_LOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 memcpy(&myStatus, &xs_status, sizeof(t_xs_status));
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
268 myTune = xs_status.tuneInfo;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
269 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270
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 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 * 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
274 */
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
275 doPlay = TRUE;
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
276 while (xs_status.isPlaying && doPlay)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
278 XS_MUTEX_LOCK(xs_status);
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
279 myStatus.currSong = xs_status.currSong;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
280 XS_MUTEX_UNLOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
281 XS_MUTEX_LOCK(xs_subctrl);
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
282 xs_subctrl_update();
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
283 XS_MUTEX_UNLOCK(xs_subctrl);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
285 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
286
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
287 songLength = myTune->subTunes[myStatus.currSong - 1].tuneLength;
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
288
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
289 /* Check minimum playtime */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
290 XS_MUTEX_LOCK(xs_cfg);
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
291 if (xs_cfg.playMinTimeEnable)
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
292 {
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
293 if (songLength < xs_cfg.playMinTime)
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
294 songLength = xs_cfg.playMinTime;
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
295 }
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
296 XS_MUTEX_UNLOCK(xs_cfg);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 /* Initialize song */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
299 if (!myStatus.sidPlayer->plrInitSong(&myStatus))
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 XSERR("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n",
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
302 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
303 goto xs_err_exit;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
307 /* Get song information for current subtune */
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
308 xs_plugin_ip.set_info(
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
309 myTune->subTunes[myStatus.currSong - 1].tuneTitle,
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
310 (songLength > 0) ? (songLength * 1000) : -1,
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
311 (myTune->subTunes[myStatus.currSong - 1].tuneSpeed > 0) ? (myTune->subTunes[myStatus.currSong - 1].tuneSpeed * 1000) : -1,
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
312 myStatus.audioFrequency,
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
313 myStatus.audioChannels);
78
ab522ab65c85 Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
314
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 /* 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
317 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
318 {
127
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
319 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
320 myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels);
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
321
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
322 XS_MUTEX_LOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 xs_status.isError = TRUE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
324 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
325 goto xs_err_exit;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 audioOpen = TRUE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 * Play the subtune
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 */
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
333 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
334 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 /* Render audio data */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
336 audioGot = myStatus.sidPlayer->plrFillBuffer(&myStatus, audioBuffer, XS_BUFSIZE);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 /* I <3 visualice/haujobb */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 xs_plugin_ip.add_vis_pcm(
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 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
341 myStatus.audioFormat, myStatus.audioChannels,
ddb513bd2610 Improved audio format support, now supported formats are "queried" from
Matti Hamalainen <ccr@tnsp.org>
parents: 118
diff changeset
342 audioGot, audioBuffer);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 /* Wait a little */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 while (xs_status.isPlaying &&
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
346 (xs_status.currSong == myStatus.currSong) &&
106
98a72c44f56b Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
347 ((guint) xs_plugin_ip.output->buffer_free() < audioGot))
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 xmms_usleep(10000);
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 /* Output audio */
91
f9063960f04e Fixed sub-song changing
Matti Hamalainen <ccr@tnsp.org>
parents: 87
diff changeset
351 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
352 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
353
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 /* Check if we have played enough */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
355 XS_MUTEX_LOCK(xs_cfg);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 if (xs_cfg.playMaxTimeEnable)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 if (xs_cfg.playMaxTimeUnknown)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 if ((songLength == -1) &&
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 (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
362 myStatus.isPlaying = FALSE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 } else {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 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
365 myStatus.isPlaying = FALSE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 }
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
368 XS_MUTEX_UNLOCK(xs_cfg);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 if (songLength > 0)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 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
373 myStatus.isPlaying = FALSE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 XSDEBUG("subtune ended/stopped\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 /* Close audio */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 if (audioOpen)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 XSDEBUG("close audio #1\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 xs_plugin_ip.output->close_audio();
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 audioOpen = FALSE;
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 /* Now determine if we continue by selecting other subtune or something */
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
388 if (!myStatus.isPlaying) doPlay = FALSE;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
391 xs_err_exit:
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
392 /* Close audio */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 if (audioOpen)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 XSDEBUG("close audio #2\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396 xs_plugin_ip.output->close_audio();
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 /* Exit the playing thread */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 XSDEBUG("exiting thread, bye.\n");
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
402 XS_MUTEX_LOCK(xs_status);
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
403 xs_status.isPlaying = FALSE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
404 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 pthread_exit(NULL);
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 * Start playing the given file
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
411 * Here we load the tune and initialize the playing thread.
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
412 * Usually you would also initialize the output-plugin, but
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
413 * 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
414 */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
415 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
416 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
417 assert(xs_status.sidPlayer);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
418
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
419 XSDEBUG("play '%s'\n", pcFilename);
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
420
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
421 /* Get tune information */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
422 if ((xs_status.tuneInfo = 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
423 return;
72
e3b205a6bc7e Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
424
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
425 /* Initialize the tune */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
426 if (!xs_status.sidPlayer->plrLoadSID(&xs_status, pcFilename))
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
427 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
428 xs_tuneinfo_free(xs_status.tuneInfo);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
429 xs_status.tuneInfo = NULL;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
430 return;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
431 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
432
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
433 XSDEBUG("load ok\n");
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
434
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
435 /* Set general status information */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
436 xs_status.isPlaying = TRUE;
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
437 xs_status.isError = FALSE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
438 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
439
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
440 /* Start the playing thread! */
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
441 if (pthread_create(&xs_decode_thread, NULL, xs_play_loop, NULL) < 0)
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
442 {
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
443 XSERR("Couldn't start playing thread! Possible reason reported by system: %s\n", strerror(errno));
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
444 xs_tuneinfo_free(xs_status.tuneInfo);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
445 xs_status.tuneInfo = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
446 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
447 }
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
448
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
449 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
450 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
451
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454 * Stop playing
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
455 * Here we set the playing status to stop and wait for playing
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
456 * thread to shut down. In any "correctly" done plugin, this is
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
457 * also the function where you close the output-plugin, but since
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
458 * XMMS-SID's special behaviour, we don't do that here.
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
459 *
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
460 * 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
461 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
462 void xs_stop(void)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
463 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 XSDEBUG("STOP_REQ\n");
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
465
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
466 xs_subctrl_close();
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
467
74
8cb66a3f75f7 Testing
Matti Hamalainen <ccr@tnsp.org>
parents: 73
diff changeset
468 if (xs_status.isPlaying)
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469 {
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
470 /* Stop playing */
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471 XSDEBUG("stopping...\n");
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
472 XS_MUTEX_LOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473 xs_status.isPlaying = FALSE;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
474 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
475 pthread_join(xs_decode_thread, NULL);
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
476 }
75
653c9b0d1320 SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents: 74
diff changeset
477
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
478 /* Free tune information */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
479 xs_status.sidPlayer->plrDeleteSID(&xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
480 xs_tuneinfo_free(xs_status.tuneInfo);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
481 xs_status.tuneInfo = NULL;
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
482
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
483 /* Update subtune control */
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
484 xs_subctrl_update();
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485 }
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
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488 /*
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
489 * Pause/unpause the playing
71
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 void xs_pause(short pauseState)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492 {
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
493 xs_subctrl_close();
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
494 xs_plugin_ip.output->pause(pauseState);
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
495 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 /*
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
499 * Set or change sub-tune
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
500 */
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
501 void xs_set_subtune(int n)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
502 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
503 XS_MUTEX_LOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
504
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
505 if (xs_status.tuneInfo && xs_status.isPlaying)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
506 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
507 if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes))
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
508 xs_status.currSong = n;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
509 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
510
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
511 XS_MUTEX_UNLOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
512
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
513 xs_subctrl_update();
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
514 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
515
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
516
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
517 void xs_change_subtune(int n)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
518 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
519 XS_MUTEX_LOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
520
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
521 if (xs_status.tuneInfo && xs_status.isPlaying)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
522 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
523 n += xs_status.currSong;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
524
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
525 if ((n >= 1) && (n <= xs_status.tuneInfo->nsubTunes))
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
526 xs_status.currSong = n;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
527 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
528
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
529 XS_MUTEX_UNLOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
530
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
531 xs_subctrl_update();
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
532 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
533
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
534
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
535 /*
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
536 * Pop-up subtune selector
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
537 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
538 void xs_subctrl_setsong(void)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
539 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
540 xs_set_subtune(GTK_ADJUSTMENT(xs_subctrl_adj)->value);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
541 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
542
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
543
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
544 void xs_subctrl_prevsong(void)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
545 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
546 xs_change_subtune(-1);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
547 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
548
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
549
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
550 void xs_subctrl_nextsong(void)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
551 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
552 xs_change_subtune( 1);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
553 }
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
554
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
555
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
556 void xs_subctrl_update(void)
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
557 {
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
558 GtkAdjustment *tmpAdj;
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
559 gboolean isEnabled;
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
560
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
561 XS_MUTEX_LOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
562
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
563 /* 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
564 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
565 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
566 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
567 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
568 XS_MUTEX_LOCK(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
569 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
570
189
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
571 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
572 tmpAdj->lower = 1;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
573 tmpAdj->upper = xs_status.tuneInfo->nsubTunes;
189
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
574 gtk_adjustment_value_changed(tmpAdj);
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
575 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
576 } else
e9e97670f7d7 Cosmetic fix: remove pop-up subsong control window if song changes and
Matti Hamalainen <ccr@tnsp.org>
parents: 184
diff changeset
577 xs_subctrl_close();
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
578 }
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
579
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
580 XS_MUTEX_UNLOCK(xs_status);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
581 }
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
582
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
583
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
584 void xs_subctrl_close(void)
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
585 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
586 XS_MUTEX_LOCK(xs_subctrl);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
587 if (xs_subctrl)
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
588 {
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
589 gtk_widget_destroy(xs_subctrl);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
590 xs_subctrl = NULL;
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
591 }
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
592 XS_MUTEX_UNLOCK(xs_subctrl);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
593 }
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
594
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
595
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
596 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
597 {
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
598 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
599 xs_subctrl_close();
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
600
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
601 return FALSE;
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
602 }
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
603
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
604
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
605 void xs_subctrl_open()
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
606 {
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
607 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
608
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
609 XS_MUTEX_LOCK(xs_subctrl);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
610
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
611 if (!xs_status.tuneInfo || !xs_status.isPlaying ||
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
612 xs_subctrl || (xs_status.tuneInfo->nsubTunes <= 1))
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
613 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
614 XS_MUTEX_UNLOCK(xs_subctrl);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
615 return;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
616 }
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
617
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
618 /* Create the pop-up window */
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
619 xs_subctrl = gtk_window_new (GTK_WINDOW_DIALOG);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
620 gtk_widget_set_name (xs_subctrl, "xs_subctrl");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
621 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
622
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
623 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
624 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
625 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
626 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
627
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
628 gtk_signal_connect(GTK_OBJECT(xs_subctrl), "destroy",
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
629 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &xs_subctrl);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
630
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
631 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
632 GTK_SIGNAL_FUNC(xs_subctrl_close), NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
633
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
634 gtk_widget_realize(xs_subctrl);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
635 gdk_window_set_decorations(xs_subctrl->window, 0);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
636
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
637
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
638 /* Create the control widgets */
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
639 frame25 = gtk_frame_new (NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
640 gtk_container_add (GTK_CONTAINER (xs_subctrl), frame25);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
641 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
642 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
643
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
644 hbox15 = gtk_hbox_new (FALSE, 4);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
645 gtk_container_add (GTK_CONTAINER (frame25), hbox15);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
646
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
647 subctrl_prev = gtk_button_new_with_label (" < ");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
648 gtk_widget_set_name (subctrl_prev, "subctrl_prev");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
649 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
650
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
651 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
652 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
653 GTK_SIGNAL_FUNC (xs_subctrl_setsong), NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
654
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
655 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
656 gtk_widget_set_name (subctrl_current, "subctrl_current");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
657 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
658 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
659 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
660 gtk_widget_grab_focus (subctrl_current);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
661
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
662 subctrl_next = gtk_button_new_with_label (" > ");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
663 gtk_widget_set_name (subctrl_next, "subctrl_next");
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
664 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
665
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
666 gtk_signal_connect (GTK_OBJECT (subctrl_prev), "clicked",
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
667 GTK_SIGNAL_FUNC (xs_subctrl_prevsong), NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
668
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
669 gtk_signal_connect (GTK_OBJECT (subctrl_next), "clicked",
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
670 GTK_SIGNAL_FUNC (xs_subctrl_nextsong), NULL);
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
671
184
4406e91d2da3 Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents: 177
diff changeset
672 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
673 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
674
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
675 gtk_widget_show_all(xs_subctrl);
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 XS_MUTEX_UNLOCK(xs_subctrl);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
678 }
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
679
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
680
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
681 /*
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
682 * Set the time-seek position
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
683 * The playing thread will do the "seeking", which means sub-tune
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
684 * changing in XMMS-SID's case. iTime argument is time in seconds,
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
685 * in contrast to milliseconds used in other occasions.
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
686 *
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
687 * This function is called whenever position slider is clicked or
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
688 * 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
689 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
690 void xs_seek(gint iTime)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
691 {
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
692 /* Check status */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
693 XS_MUTEX_LOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
694 if (!xs_status.tuneInfo || !xs_status.isPlaying)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
695 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
696 XS_MUTEX_UNLOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
697 return;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
698 }
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
699
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
700 /* Act according to settings */
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
701 XS_MUTEX_LOCK(xs_cfg);
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
702 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
703 case XS_SSC_SEEK:
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
704 if (iTime < xs_status.lastTime)
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
705 xs_change_subtune(-1);
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
706 else
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
707 if (iTime > xs_status.lastTime)
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
708 xs_change_subtune(1);
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
709 break;
78
ab522ab65c85 Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
710
140
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
711 case XS_SSC_POPUP:
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
712 xs_subctrl_open();
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
713 break;
8b9c14540e53 - Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents: 138
diff changeset
714
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
715 /* 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
716 #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
717 case XS_SSC_PATCH:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
718 if ((iTime > 0) && (iTime <= xs_status.tuneInfo->nsubTunes))
78
ab522ab65c85 Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
719 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
720 break;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
721 #endif
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
722 }
103
fe83646e6baa Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
723
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
724 XS_MUTEX_UNLOCK(xs_cfg);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
725 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
726 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
727
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
728
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
729 /*
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
730 * Return the playing "position/time"
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
731 * Determine current position/time in song. Used by XMMS to update
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
732 * the song clock and position slider and MOST importantly to determine
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
733 * 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
734 * 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
735 */
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
736 gint xs_get_time(void)
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
737 {
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
738 /* 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
739 XS_MUTEX_LOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
740
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
741 if (xs_status.isError)
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
742 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
743 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
744 return -2;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
745 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
746
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
747 /* If there is no tune, return -1 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
748 if (!xs_status.tuneInfo)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
749 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
750 XS_MUTEX_UNLOCK(xs_status);
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
751 return -1;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
752 }
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
753
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
754 /* 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
755 if (!xs_status.isPlaying)
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
756 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
757 XS_MUTEX_UNLOCK(xs_status);
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
758 return -1;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
759 }
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
760
78
ab522ab65c85 Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
761 /* Let's see what we do */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
762 XS_MUTEX_LOCK(xs_cfg);
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
763 switch (xs_cfg.subsongControl) {
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
764 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
765 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
766 break;
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
767
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
768 #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
769 case XS_SSC_PATCH:
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
770 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
771 break;
71
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
772 #endif
132
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
773 }
4162a5370b9e Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents: 127
diff changeset
774
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
775 XS_MUTEX_UNLOCK(xs_cfg);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
776 XS_MUTEX_UNLOCK(xs_status);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
777
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
778 /* 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
779 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
780 }
2b32c75729ce Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
781
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
782
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
783 /*
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
784 * Return song information
202
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
785 * This function is called by XMMS when initially loading the playlist.
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
786 * Subsequent changes to information are made by the player thread,
fe684a2ccdc7 Reworking code.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
787 * 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
788 */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
789 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
790 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
791 t_xs_tuneinfo *pInfo;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
792 gint tmpInt;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
793
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
794 /* Get tune information from emulation engine */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
795 pInfo = xs_status.sidPlayer->plrGetSIDInfo(songFilename);
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
796 if (!pInfo) return;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
797
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
798 /* Get sub-tune information, if available */
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
799 if ((pInfo->startTune >= 0) && (pInfo->startTune <= pInfo->nsubTunes))
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
800 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
801 (*songTitle) = g_strdup(pInfo->subTunes[pInfo->startTune - 1].tuneTitle);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
802
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
803 tmpInt = pInfo->subTunes[pInfo->startTune - 1].tuneLength;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
804 if (tmpInt < 0)
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
805 (*songLength) = -1;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
806 else
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
807 (*songLength) = (tmpInt * 1000);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
808 }
177
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
809
6e350784aa57 Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
810 /* Free tune information */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
811 xs_tuneinfo_free(pInfo);
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
812 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
813
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
814
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
815 /* Allocate a new tune information structure
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
816 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
817 t_xs_tuneinfo *xs_tuneinfo_new(gchar *pcFilename, gint nsubTunes, gint startTune,
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
818 gchar *sidName, gchar *sidComposer, gchar *sidCopyright,
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
819 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
820 {
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
821 t_xs_tuneinfo *pResult;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
822
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
823 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
824 if (!pResult) return NULL;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
825
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
826 pResult->sidFilename = g_strdup(pcFilename);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
827 if (!pResult->sidFilename)
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
828 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
829 g_free(pResult);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
830 return NULL;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
831 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
832
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
833 pResult->sidName = g_strdup(sidName);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
834 pResult->sidComposer = g_strdup(sidComposer);
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
835 pResult->sidCopyright = g_strdup(sidCopyright);
106
98a72c44f56b Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
836 pResult->nsubTunes = nsubTunes;
98a72c44f56b Fileinfo now working with rudimentary informations. Slightly buggy.
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
837 pResult->startTune = startTune;
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
838
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
839 pResult->loadAddr = loadAddr;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
840 pResult->initAddr = initAddr;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
841 pResult->playAddr = playAddr;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
842 pResult->dataFileLen = dataFileLen;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
843
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
844 return pResult;
73
2bc607888f53 Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
845 }
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
846
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
847
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
848 /* Free given tune information structure
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
849 */
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
850 void xs_tuneinfo_free(t_xs_tuneinfo *pTune)
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
851 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
852 gint i;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
853 if (!pTune) return;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
854
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
855 g_free(pTune->sidFilename); pTune->sidFilename = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
856 g_free(pTune->sidName); pTune->sidName = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
857 g_free(pTune->sidComposer); pTune->sidComposer = NULL;
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
858 g_free(pTune->sidCopyright); pTune->sidCopyright = NULL;
87
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
859
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
860 for (i = 0; i < pTune->nsubTunes; i++)
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
861 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
862 if (pTune->subTunes[i].tuneTitle)
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
863 {
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
864 g_free(pTune->subTunes[i].tuneTitle);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
865 pTune->subTunes[i].tuneTitle = NULL;
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
866 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
867 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
868
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
869 g_free(pTune);
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
870 }
94497283affa Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
871
230
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
872
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
873 void xs_fileinfo_ok(void)
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
874 {
608f31f6c095 Raw cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 225
diff changeset
875 }