Mercurial > hg > xmms-sid
annotate src/xmms-sid.c @ 970:d90bca05521e
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 21 Nov 2012 00:16:03 +0200 |
parents | 04dc44e87e03 |
children | ede5374e9294 |
rev | line source |
---|---|
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 XMMS-SID - SIDPlay input plugin for X MultiMedia System (XMMS) |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 Main source file |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 |
324 | 6 Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org> |
723 | 7 (C) Copyright 1999-2009 Tecnic Software productions (TNSP) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 This program is free software; you can redistribute it and/or modify |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 it under the terms of the GNU General Public License as published by |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 the Free Software Foundation; either version 2 of the License, or |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 (at your option) any later version. |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 This program is distributed in the hope that it will be useful, |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 but WITHOUT ANY WARRANTY; without even the implied warranty of |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 GNU General Public License for more details. |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 |
412
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
19 You should have received a copy of the GNU General Public License along along |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
20 with this program; if not, write to the Free Software Foundation, Inc., |
7f694e5a1493
Updated GNU GPL (new FSF address) and some cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
403
diff
changeset
|
21 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 */ |
235
d04191d1ea64
Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
23 #include "xmms-sid.h" |
223
16e3b2446a73
On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents:
213
diff
changeset
|
24 |
16e3b2446a73
On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents:
213
diff
changeset
|
25 #ifdef HAVE_STDLIB_H |
16e3b2446a73
On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents:
213
diff
changeset
|
26 #include <stdlib.h> |
16e3b2446a73
On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents:
213
diff
changeset
|
27 #endif |
16e3b2446a73
On some systems stdlib.h has prerequisite of stdio.h, corrected order of
Matti Hamalainen <ccr@tnsp.org>
parents:
213
diff
changeset
|
28 |
184
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
29 #include <gdk/gdkkeysyms.h> |
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
30 #include <gtk/gtk.h> |
235
d04191d1ea64
Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
31 |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 #include "xs_config.h" |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 #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
|
34 #include "xs_stil.h" |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
392
diff
changeset
|
35 #include "xs_title.h" |
235
d04191d1ea64
Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
36 #include "xs_fileinfo.h" |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 #include "xs_interface.h" |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 #include "xs_glade.h" |
872
b02f934d8224
Move some code to xs_backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
865
diff
changeset
|
39 #include "xs_backend.h" |
622
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
40 #include "xs_slsup.h" |
d7389ea52113
Move SLDB and STIL utility functions to xs_slsup.[ch] and amend some changes between XMMS-SID and Aud-SID via a macro mess.
Matti Hamalainen <ccr@tnsp.org>
parents:
606
diff
changeset
|
41 |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
787
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
43 /* Global variables |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 */ |
751 | 45 XSEngineState xs_status; |
230 | 46 XS_MUTEX(xs_status); |
532 | 47 static XS_THREAD_T xs_decode_thread; |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
49 static GtkWidget *xs_subctrl = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
50 static GtkObject *xs_subctrl_adj = NULL; |
230 | 51 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
|
52 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
53 void xs_subctrl_close(void); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
54 void xs_subctrl_update(void); |
477
53bdac2e0dcb
Moved sldb glue functions here; Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
55 |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
56 |
297 | 57 /* |
230 | 58 * Initialization functions |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 */ |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
60 void xs_reinit(void) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
62 /* Stop playing, if we are */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
63 XS_MUTEX_LOCK(xs_status); |
798 | 64 if (xs_status.playing) |
797 | 65 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
66 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
67 xs_stop(); |
797 | 68 } |
69 else | |
70 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
71 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
72 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
73 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
74 XS_MUTEX_LOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
75 XS_MUTEX_LOCK(xs_cfg); |
606
59046d70c0ef
Fixed a thread race conds in xs_reinit() and xs_get_song_info()
Matti Hamalainen <ccr@tnsp.org>
parents:
543
diff
changeset
|
76 |
809
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
77 // Close player stuff |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
78 xs_tuneinfo_free(xs_status.tuneInfo); |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
79 xs_status.tuneInfo = NULL; |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
80 if (xs_status.engine != NULL) |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
81 { |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
82 xs_status.engine->plrDeleteSID(&xs_status); |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
83 xs_status.engine->plrClose(&xs_status); |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
84 } |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
85 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
86 /* Initialize status and sanitize configuration */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
87 memset(&xs_status, 0, sizeof(xs_status)); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
88 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
89 if (xs_cfg.audioFrequency < 8000) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
90 xs_cfg.audioFrequency = 8000; |
273
f6daddca03c7
Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents:
264
diff
changeset
|
91 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
92 xs_status.audioFrequency = xs_cfg.audioFrequency; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
93 xs_status.audioBitsPerSample = xs_cfg.audioBitsPerSample; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
94 xs_status.audioChannels = xs_cfg.audioChannels; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
95 xs_status.audioFormat = -1; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
96 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
97 /* Try to initialize emulator engine */ |
875
0fdb001e456c
Oops, one argument was missing from xs_init_emu_backend() call.
Matti Hamalainen <ccr@tnsp.org>
parents:
872
diff
changeset
|
98 xs_init_emu_backend(&xs_status, &xs_cfg.playerEngine); |
606
59046d70c0ef
Fixed a thread race conds in xs_reinit() and xs_get_song_info()
Matti Hamalainen <ccr@tnsp.org>
parents:
543
diff
changeset
|
99 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
100 /* Get settings back, in case the chosen emulator backend changed them */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
101 xs_cfg.audioFrequency = xs_status.audioFrequency; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
102 xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
103 xs_cfg.audioChannels = xs_status.audioChannels; |
273
f6daddca03c7
Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents:
264
diff
changeset
|
104 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
105 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
106 XS_MUTEX_UNLOCK(xs_cfg); |
606
59046d70c0ef
Fixed a thread race conds in xs_reinit() and xs_get_song_info()
Matti Hamalainen <ccr@tnsp.org>
parents:
543
diff
changeset
|
107 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
108 /* Initialize song-length database */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
109 xs_songlen_close(); |
797 | 110 if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) |
111 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
112 xs_error("Error initializing song-length database!\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
113 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
114 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
115 /* Initialize STIL database */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
116 xs_stil_close(); |
797 | 117 if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) |
118 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
119 xs_error("Error initializing STIL database!\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
120 } |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
121 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
123 |
943
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
124 gboolean xs_configure_pester(gpointer data) |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
125 { |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
126 xs_configure(); |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
127 |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
128 xs_messagebox(_("Attention!"), |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
129 _("It seems you haven't yet configured XMMS-SID plugin, " |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
130 "or the configuration is from another version. " |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
131 "Opening the configuration dialog for it now.")); |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
132 return FALSE; |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
133 } |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
134 |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
135 |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
136 /* |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
137 * Initialize XMMS-SID |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
138 */ |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
139 void xs_init(void) |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
140 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
141 XSDEBUG("xs_init()\n"); |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
142 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
143 /* Initialize and get configuration */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
144 xs_init_configuration(); |
943
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
145 |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
146 if (!xs_read_configuration()) |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
147 { |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
148 g_timeout_add(1500, xs_configure_pester, NULL); |
04dc44e87e03
Add a automatic pestering dialog if the user has not configured XMMS-SID or
Matti Hamalainen <ccr@tnsp.org>
parents:
879
diff
changeset
|
149 } |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
150 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
151 /* Initialize subsystems */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
152 xs_reinit(); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
153 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
154 XSDEBUG("OK\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 /* |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 * Shut down XMMS-SID |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 */ |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 void xs_close(void) |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
163 XSDEBUG("xs_close(): shutting down...\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
165 /* Stop playing, free structures */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
166 xs_stop(); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
168 xs_tuneinfo_free(xs_status.tuneInfo); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
169 xs_status.tuneInfo = NULL; |
794
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
170 if (xs_status.engine != NULL) |
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
171 { |
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
172 xs_status.engine->plrDeleteSID(&xs_status); |
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
173 xs_status.engine->plrClose(&xs_status); |
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
174 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
175 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
176 xs_songlen_close(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
177 xs_stil_close(); |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
178 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
179 XSDEBUG("shutdown finished.\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
182 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 /* |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
184 * 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
|
185 */ |
688 | 186 gint xs_is_our_file(gchar *filename) |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
187 { |
688 | 188 gchar *ext; |
760
f6a57c0656fa
Handle engine initialization failures a bit more .. "gracefully".
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
189 if (xs_status.engine == NULL) |
f6a57c0656fa
Handle engine initialization failures a bit more .. "gracefully".
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
190 return FALSE; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
191 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
192 /* Check the filename */ |
688 | 193 if (filename == NULL) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
194 return FALSE; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
195 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
196 /* Try to detect via detection routine, if required */ |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
197 if (xs_cfg.detectMagic && xs_status.engine->plrProbe != NULL) |
797 | 198 { |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
199 gboolean res = FALSE; |
751 | 200 XSFile *f; |
797 | 201 if ((f = xs_fopen(filename, "rb")) != NULL) |
202 { | |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
203 res = xs_status.engine->plrProbe(f); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
204 xs_fclose(f); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
205 } |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
206 return res; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
207 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
208 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
209 /* Detect just by checking filename extension */ |
763
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
760
diff
changeset
|
210 ext = strrchr(filename, '.'); |
797 | 211 if (ext) |
212 { | |
688 | 213 ext++; |
797 | 214 switch (xs_cfg.playerEngine) |
215 { | |
216 case XS_ENG_SIDPLAY1: | |
217 if (!g_strcasecmp(ext, "psid")) | |
218 return TRUE; | |
219 if (!g_strcasecmp(ext, "sid")) | |
220 return TRUE; | |
221 if (!g_strcasecmp(ext, "dat")) | |
222 return TRUE; | |
223 if (!g_strcasecmp(ext, "inf")) | |
224 return TRUE; | |
225 if (!g_strcasecmp(ext, "info")) | |
226 return TRUE; | |
227 break; | |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
228 |
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
229 case XS_ENG_SIDPLAY2: |
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
230 case XS_ENG_SIDPLAYFP: |
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
231 if (!g_strcasecmp(ext, "sid")) |
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
232 return TRUE; |
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
233 break; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
234 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
235 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
236 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
237 return FALSE; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
238 } |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
239 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
240 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
241 /* |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
242 * Main playing thread loop |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
243 */ |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
244 void *xs_playthread(void *argPointer) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
245 { |
751 | 246 XSEngineState myStatus; |
247 XSTuneInfo *myTune; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
248 gboolean audioOpen = FALSE, doPlay = FALSE, isFound = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
249 gint audioGot, songLength, i; |
748
d9d769b5dbe2
Remove oversampling support.
Matti Hamalainen <ccr@tnsp.org>
parents:
735
diff
changeset
|
250 gchar *audioBuffer = NULL, *tmpTitle; |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
251 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
252 (void) argPointer; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
253 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
254 /* Initialize */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
255 XSDEBUG("entering player thread\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
256 XS_MUTEX_LOCK(xs_status); |
751 | 257 memcpy(&myStatus, &xs_status, sizeof(XSEngineState)); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
258 myTune = xs_status.tuneInfo; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
259 for (i = 0; i <= myTune->nsubTunes; i++) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
260 myTune->subTunes[i].tunePlayed = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
261 XS_MUTEX_UNLOCK(xs_status); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
262 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
263 /* Allocate audio buffer */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
264 audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE); |
797 | 265 if (audioBuffer == NULL) |
266 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
267 xs_error("Couldn't allocate memory for audio data buffer!\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
268 goto xs_err_exit; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
269 } |
273
f6daddca03c7
Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents:
264
diff
changeset
|
270 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
271 /* |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
272 * Main player loop: while not stopped, loop here - play subtunes |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
273 */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
274 audioOpen = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
275 doPlay = TRUE; |
798 | 276 while (xs_status.playing && doPlay) |
797 | 277 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
278 /* Automatic sub-tune change logic */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
279 XS_MUTEX_LOCK(xs_cfg); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
280 XS_MUTEX_LOCK(xs_status); |
798 | 281 myStatus.playing = TRUE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
282 |
797 | 283 if (xs_status.currSong < 1 || myStatus.currSong < 1) |
284 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
285 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
286 XS_MUTEX_UNLOCK(xs_cfg); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
287 goto xs_err_exit; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
288 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
289 |
797 | 290 if (xs_cfg.subAutoEnable && (myStatus.currSong == xs_status.currSong)) |
291 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
292 /* Check if currently selected sub-tune has been played already */ |
797 | 293 if (myTune->subTunes[myStatus.currSong-1].tunePlayed) |
294 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
295 /* Find a tune that has not been played */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
296 XSDEBUG("tune #%i already played, finding next match ...\n", myStatus.currSong); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
297 isFound = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
298 i = 0; |
797 | 299 while (!isFound && (++i <= myTune->nsubTunes)) |
300 { | |
301 if (xs_cfg.subAutoMinOnly) | |
302 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
303 /* A tune with minimum length must be found */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
304 if (!myTune->subTunes[i-1].tunePlayed && |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
305 myTune->subTunes[i-1].tuneLength >= xs_cfg.subAutoMinTime) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
306 isFound = TRUE; |
797 | 307 } |
308 else | |
309 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
310 /* Any unplayed tune is okay */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
311 if (!myTune->subTunes[i-1].tunePlayed) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
312 isFound = TRUE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
313 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
314 } |
281
d913f0f69487
Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
315 |
797 | 316 if (isFound) |
317 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
318 /* Set the new sub-tune */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
319 XSDEBUG("found #%i\n", i); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
320 xs_status.currSong = i; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
321 } else |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
322 /* This is the end */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
323 doPlay = FALSE; |
281
d913f0f69487
Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
324 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
325 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
326 XS_MUTEX_UNLOCK(xs_cfg); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
327 continue; /* This is ugly, but ... */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
328 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
329 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
330 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
331 /* Tell that we are initializing, update sub-tune controls */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
332 myStatus.currSong = xs_status.currSong; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
333 myTune->subTunes[myStatus.currSong-1].tunePlayed = TRUE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
334 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
335 XS_MUTEX_UNLOCK(xs_cfg); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
336 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
337 XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); |
281
d913f0f69487
Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
338 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
339 GDK_THREADS_ENTER(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
340 xs_subctrl_update(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
341 GDK_THREADS_LEAVE(); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
342 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
343 /* Check minimum playtime */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
344 songLength = myTune->subTunes[myStatus.currSong-1].tuneLength; |
797 | 345 if (xs_cfg.playMinTimeEnable && songLength >= 0) |
346 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
347 if (songLength < xs_cfg.playMinTime) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
348 songLength = xs_cfg.playMinTime; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
349 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
350 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
351 /* Initialize song */ |
797 | 352 if (!myStatus.engine->plrInitSong(&myStatus)) |
353 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
354 xs_error("Couldn't initialize SID-tune '%s' (sub-tune #%i)!\n", |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
355 myTune->sidFilename, myStatus.currSong); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
356 goto xs_err_exit; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
357 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
358 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
359 /* Open the audio output */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
360 XSDEBUG("open audio output (%d, %d, %d)\n", |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
361 myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
362 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
363 if (!xs_plugin_ip.output-> |
797 | 364 open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels)) |
365 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
366 xs_error("Couldn't open XMMS audio output (fmt=%x, freq=%i, nchan=%i)!\n", |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
367 myStatus.audioFormat, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
368 myStatus.audioFrequency, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
369 myStatus.audioChannels); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
370 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
371 XS_MUTEX_LOCK(xs_status); |
798 | 372 xs_status.error = TRUE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
373 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
374 goto xs_err_exit; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
375 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
376 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
377 audioOpen = TRUE; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
378 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
379 /* Set song information for current subtune */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
380 XSDEBUG("set tune info\n"); |
753 | 381 myStatus.engine->plrUpdateSIDInfo(&myStatus); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
382 tmpTitle = xs_make_titlestring(myTune, myStatus.currSong); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
383 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
384 xs_plugin_ip.set_info( |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
385 tmpTitle, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
386 (songLength > 0) ? (songLength * 1000) : 0, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
387 -1, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
388 myStatus.audioFrequency, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
389 myStatus.audioChannels); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
390 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
391 g_free(tmpTitle); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
392 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
393 XSDEBUG("playing\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
394 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
395 /* |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
396 * Play the subtune |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
397 */ |
798 | 398 while (xs_status.playing && myStatus.playing && (xs_status.currSong == myStatus.currSong)) |
767 | 399 { |
753 | 400 audioGot = myStatus.engine->plrFillBuffer( |
748
d9d769b5dbe2
Remove oversampling support.
Matti Hamalainen <ccr@tnsp.org>
parents:
735
diff
changeset
|
401 &myStatus, audioBuffer, XS_AUDIOBUF_SIZE); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
402 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
403 /* I <3 visualice/haujobb */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
404 xs_plugin_ip.add_vis_pcm( |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
405 xs_plugin_ip.output->written_time(), |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
406 myStatus.audioFormat, myStatus.audioChannels, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
407 audioGot, audioBuffer); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
408 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
409 /* Wait a little */ |
798 | 410 while (xs_status.playing && |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
411 (xs_status.currSong == myStatus.currSong) && |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
412 (xs_plugin_ip.output->buffer_free() < audioGot)) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
413 xmms_usleep(500); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
414 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
415 /* Output audio */ |
798 | 416 if (xs_status.playing && xs_status.currSong == myStatus.currSong) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
417 xs_plugin_ip.output->write_audio(audioBuffer, audioGot); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
418 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
419 /* Check if we have played enough */ |
797 | 420 if (xs_cfg.playMaxTimeEnable) |
421 { | |
422 if (xs_cfg.playMaxTimeUnknown) | |
423 { | |
767 | 424 if (songLength < 0 && |
425 xs_plugin_ip.output->output_time() >= xs_cfg.playMaxTime * 1000) | |
798 | 426 myStatus.playing = FALSE; |
797 | 427 } |
428 else | |
429 { | |
767 | 430 if (xs_plugin_ip.output->output_time() >= xs_cfg.playMaxTime * 1000) |
798 | 431 myStatus.playing = FALSE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
432 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
433 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
434 |
797 | 435 if (songLength >= 0) |
436 { | |
767 | 437 if (xs_plugin_ip.output->output_time() >= songLength * 1000) |
798 | 438 myStatus.playing = FALSE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
439 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
440 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
441 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
442 XSDEBUG("subtune ended/stopped\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
443 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
444 /* Close audio output plugin */ |
797 | 445 if (audioOpen) |
446 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
447 XSDEBUG("close audio #1\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
448 xs_plugin_ip.output->close_audio(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
449 audioOpen = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
450 XSDEBUG("closed\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
451 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
452 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
453 /* Now determine if we continue by selecting other subtune or something */ |
798 | 454 if (!myStatus.playing && !xs_cfg.subAutoEnable) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
455 doPlay = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
456 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
457 |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
392
diff
changeset
|
458 xs_err_exit: |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
459 XSDEBUG("out of playing loop\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
460 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
461 /* Close audio output plugin */ |
797 | 462 if (audioOpen) |
463 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
464 XSDEBUG("close audio #2\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
465 xs_plugin_ip.output->close_audio(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
466 XSDEBUG("closed\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
467 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
468 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
469 g_free(audioBuffer); |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
470 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
471 /* Set playing status to false (stopped), thus when |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
472 * XMMS next calls xs_get_time(), it can return appropriate |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
473 * value "not playing" status and XMMS knows to move to |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
474 * next entry in the playlist .. or whatever it wishes. |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
475 */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
476 XS_MUTEX_LOCK(xs_status); |
798 | 477 xs_status.playing = FALSE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
478 XS_MUTEX_UNLOCK(xs_status); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
479 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
480 /* Exit the playing thread */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
481 XSDEBUG("exiting thread, bye.\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
482 XS_THREAD_EXIT(NULL); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
483 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
484 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
485 |
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 * Start playing the given file |
202 | 488 * Here we load the tune and initialize the playing thread. |
489 * Usually you would also initialize the output-plugin, but | |
490 * 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
|
491 */ |
688 | 492 void xs_play_file(gchar *filename) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
493 { |
865
9052d9096c59
Check for NULL filename here.
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
494 if (xs_status.engine == NULL || filename == NULL) |
760
f6a57c0656fa
Handle engine initialization failures a bit more .. "gracefully".
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
495 return; |
230 | 496 |
688 | 497 XSDEBUG("play '%s'\n", filename); |
72
e3b205a6bc7e
Lots re-arranging and new code for upcoming modularization.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
498 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
499 /* Get tune information */ |
753 | 500 if ((xs_status.tuneInfo = xs_status.engine->plrGetSIDInfo(filename)) == NULL) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
501 return; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
502 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
503 /* Initialize the tune */ |
797 | 504 if (!xs_status.engine->plrLoadSID(&xs_status, filename)) |
505 { | |
849 | 506 XSDEBUG("backend could not load '%s'\n", filename); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
507 xs_tuneinfo_free(xs_status.tuneInfo); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
508 xs_status.tuneInfo = NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
509 return; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
510 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
511 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
512 XSDEBUG("load ok\n"); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
513 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
514 /* Set general status information */ |
798 | 515 xs_status.playing = TRUE; |
516 xs_status.error = FALSE; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
517 xs_status.currSong = xs_status.tuneInfo->startTune; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
518 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
519 /* Start the playing thread! */ |
797 | 520 if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) |
521 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
522 xs_error("Couldn't create playing thread!\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
523 xs_tuneinfo_free(xs_status.tuneInfo); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
524 xs_status.tuneInfo = NULL; |
753 | 525 xs_status.engine->plrDeleteSID(&xs_status); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
526 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
527 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
528 /* Okay, here the playing thread has started up and we |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
529 * return from here to XMMS. Rest is up to XMMS's GUI |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
530 * and playing thread. |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
531 */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
532 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
|
533 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
534 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
535 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
536 /* |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
537 * Stop playing |
202 | 538 * Here we set the playing status to stop and wait for playing |
539 * thread to shut down. In any "correctly" done plugin, this is | |
540 * also the function where you close the output-plugin, but since | |
264 | 541 * XMMS-SID has special behaviour (audio opened/closed in the |
542 * playing thread), we don't do that here. | |
202 | 543 * |
544 * 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
|
545 */ |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
546 void xs_stop(void) |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
547 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
548 XSDEBUG("stop requested\n"); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
549 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
550 /* Close the sub-tune control window, if any */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
551 xs_subctrl_close(); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
552 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
553 /* Lock xs_status and stop playing thread */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
554 XS_MUTEX_LOCK(xs_status); |
798 | 555 if (xs_status.playing) |
797 | 556 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
557 XSDEBUG("stopping...\n"); |
798 | 558 xs_status.playing = FALSE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
559 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
560 XS_THREAD_JOIN(xs_decode_thread); |
797 | 561 } |
562 else | |
563 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
564 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
565 } |
75
653c9b0d1320
SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
566 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
567 XSDEBUG("done, updating status\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
568 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
569 /* Status is now stopped, update the sub-tune |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
570 * controller in fileinfo window (if open) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
571 */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
572 xs_fileinfo_update(); |
241
291715a519e2
Compile-time setting to enable/disable use of dynamically allocated buffers.
Matti Hamalainen <ccr@tnsp.org>
parents:
235
diff
changeset
|
573 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
574 /* Free tune information */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
575 XS_MUTEX_LOCK(xs_status); |
794
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
576 if (xs_status.engine != NULL) |
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
577 xs_status.engine->plrDeleteSID(&xs_status); |
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
578 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
579 xs_tuneinfo_free(xs_status.tuneInfo); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
580 xs_status.tuneInfo = NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
581 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
582 XSDEBUG("ok\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
583 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
584 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
585 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
586 /* |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
587 * Pause/unpause the playing |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
588 */ |
688 | 589 void xs_pause(short pause) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
590 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
591 XS_MUTEX_LOCK(xs_status); |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
592 xs_status.paused = pause; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
593 XS_MUTEX_UNLOCK(xs_status); |
264 | 594 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
595 xs_subctrl_close(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
596 xs_fileinfo_update(); |
688 | 597 xs_plugin_ip.output->pause(pause); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
598 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
599 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
600 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
601 /* |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
602 * Pop-up subtune selector |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
603 */ |
230 | 604 void xs_subctrl_setsong(void) |
605 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
606 gint n; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
607 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
608 XS_MUTEX_LOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
609 XS_MUTEX_LOCK(xs_subctrl); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
610 |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
611 if (!xs_status.paused && xs_status.tuneInfo && xs_status.playing) |
797 | 612 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
613 n = (gint) GTK_ADJUSTMENT(xs_subctrl_adj)->value; |
797 | 614 if (n >= 1 && n <= xs_status.tuneInfo->nsubTunes) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
615 xs_status.currSong = n; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
616 } |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
617 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
618 XS_MUTEX_UNLOCK(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
619 XS_MUTEX_UNLOCK(xs_status); |
230 | 620 } |
621 | |
622 | |
623 void xs_subctrl_prevsong(void) | |
624 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
625 XS_MUTEX_LOCK(xs_status); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
626 |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
627 if (!xs_status.paused && xs_status.tuneInfo && xs_status.playing) |
797 | 628 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
629 if (xs_status.currSong > 1) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
630 xs_status.currSong--; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
631 } |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
632 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
633 XS_MUTEX_UNLOCK(xs_status); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
634 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
635 xs_subctrl_update(); |
230 | 636 } |
637 | |
638 | |
639 void xs_subctrl_nextsong(void) | |
640 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
641 XS_MUTEX_LOCK(xs_status); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
642 |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
643 if (!xs_status.paused && xs_status.tuneInfo && xs_status.playing) |
797 | 644 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
645 if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
646 xs_status.currSong++; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
647 } |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
648 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
649 XS_MUTEX_UNLOCK(xs_status); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
650 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
651 xs_subctrl_update(); |
230 | 652 } |
653 | |
177
6e350784aa57
Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
654 |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
655 void xs_subctrl_update(void) |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
656 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
657 GtkAdjustment *tmpAdj; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
658 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
659 XS_MUTEX_LOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
660 XS_MUTEX_LOCK(xs_subctrl); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
661 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
662 /* Check if control window exists, we are currently playing and have a tune */ |
797 | 663 if (xs_subctrl) |
664 { | |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
665 if (!xs_status.paused && xs_status.tuneInfo && xs_status.playing) |
797 | 666 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
667 tmpAdj = GTK_ADJUSTMENT(xs_subctrl_adj); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
668 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
669 tmpAdj->value = xs_status.currSong; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
670 tmpAdj->lower = 1; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
671 tmpAdj->upper = xs_status.tuneInfo->nsubTunes; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
672 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
673 XS_MUTEX_UNLOCK(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
674 gtk_adjustment_value_changed(tmpAdj); |
797 | 675 } |
676 else | |
677 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
678 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
679 XS_MUTEX_UNLOCK(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
680 xs_subctrl_close(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
681 } |
797 | 682 } |
683 else | |
684 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
685 XS_MUTEX_UNLOCK(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
686 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
687 } |
177
6e350784aa57
Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
688 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
689 xs_fileinfo_update(); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
690 } |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
691 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
692 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
693 void xs_subctrl_close(void) |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
694 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
695 XS_MUTEX_LOCK(xs_subctrl); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
696 |
797 | 697 if (xs_subctrl) |
698 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
699 gtk_widget_destroy(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
700 xs_subctrl = NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
701 } |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
702 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
703 XS_MUTEX_UNLOCK(xs_subctrl); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
704 } |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
705 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
706 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
707 gboolean xs_subctrl_keypress(GtkWidget * win, GdkEventKey * ev) |
184
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
708 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
709 (void) win; |
184
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
710 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
711 if (ev->keyval == GDK_Escape) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
712 xs_subctrl_close(); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
713 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
714 return FALSE; |
184
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
715 } |
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
716 |
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
717 |
294
f0ece2d20094
Do correct typecasts and declare xs_subctrl_open arguments as void.
Matti Hamalainen <ccr@tnsp.org>
parents:
281
diff
changeset
|
718 void xs_subctrl_open(void) |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
719 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
720 GtkWidget *frame25, *hbox15, *subctrl_prev, *subctrl_current, *subctrl_next; |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
721 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
722 XS_MUTEX_LOCK(xs_subctrl); |
797 | 723 |
860
852fe7009876
Prevent subsong control from opening when paused.
Matti Hamalainen <ccr@tnsp.org>
parents:
849
diff
changeset
|
724 if (xs_status.paused || !xs_status.tuneInfo || !xs_status.playing || |
797 | 725 xs_subctrl || xs_status.tuneInfo->nsubTunes <= 1) |
726 goto out; | |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
727 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
728 /* Create the pop-up window */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
729 xs_subctrl = gtk_window_new(GTK_WINDOW_DIALOG); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
730 gtk_widget_set_name(xs_subctrl, "xs_subctrl"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
731 gtk_object_set_data(GTK_OBJECT(xs_subctrl), "xs_subctrl", xs_subctrl); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
732 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
733 gtk_window_set_title(GTK_WINDOW(xs_subctrl), _("Subtune Control")); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
734 gtk_window_set_position(GTK_WINDOW(xs_subctrl), GTK_WIN_POS_MOUSE); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
735 gtk_container_set_border_width(GTK_CONTAINER(xs_subctrl), 0); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
736 gtk_window_set_policy(GTK_WINDOW(xs_subctrl), FALSE, FALSE, FALSE); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
737 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
738 XS_SIGNAL_CONNECT(xs_subctrl, "destroy", gtk_widget_destroyed, &xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
739 XS_SIGNAL_CONNECT(xs_subctrl, "focus_out_event", xs_subctrl_close, NULL); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
740 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
741 gtk_widget_realize(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
742 gdk_window_set_decorations(xs_subctrl->window, (GdkWMDecoration) 0); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
743 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
744 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
745 /* Create the control widgets */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
746 frame25 = gtk_frame_new(NULL); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
747 gtk_container_add(GTK_CONTAINER(xs_subctrl), frame25); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
748 gtk_container_set_border_width(GTK_CONTAINER(frame25), 2); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
749 gtk_frame_set_shadow_type(GTK_FRAME(frame25), GTK_SHADOW_OUT); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
750 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
751 hbox15 = gtk_hbox_new(FALSE, 4); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
752 gtk_container_add(GTK_CONTAINER(frame25), hbox15); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
753 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
754 subctrl_prev = gtk_button_new_with_label(" < "); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
755 gtk_widget_set_name(subctrl_prev, "subctrl_prev"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
756 gtk_box_pack_start(GTK_BOX(hbox15), subctrl_prev, FALSE, FALSE, 0); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
757 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
758 xs_subctrl_adj = gtk_adjustment_new(xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes, 1, 1, 0); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
759 XS_SIGNAL_CONNECT(xs_subctrl_adj, "value_changed", xs_subctrl_setsong, NULL); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
760 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
761 subctrl_current = gtk_hscale_new(GTK_ADJUSTMENT(xs_subctrl_adj)); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
762 gtk_widget_set_name(subctrl_current, "subctrl_current"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
763 gtk_box_pack_start(GTK_BOX(hbox15), subctrl_current, FALSE, TRUE, 0); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
764 gtk_scale_set_digits(GTK_SCALE(subctrl_current), 0); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
765 gtk_range_set_update_policy(GTK_RANGE(subctrl_current), GTK_UPDATE_DELAYED); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
766 gtk_widget_grab_focus(subctrl_current); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
767 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
768 subctrl_next = gtk_button_new_with_label(" > "); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
769 gtk_widget_set_name(subctrl_next, "subctrl_next"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
770 gtk_box_pack_start(GTK_BOX(hbox15), subctrl_next, FALSE, FALSE, 0); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
771 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
772 XS_SIGNAL_CONNECT(subctrl_prev, "clicked", xs_subctrl_prevsong, NULL); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
773 XS_SIGNAL_CONNECT(subctrl_next, "clicked", xs_subctrl_nextsong, NULL); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
774 XS_SIGNAL_CONNECT(xs_subctrl, "key_press_event", xs_subctrl_keypress, NULL); |
230 | 775 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
776 gtk_widget_show_all(xs_subctrl); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
777 |
797 | 778 out: |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
779 XS_MUTEX_UNLOCK(xs_subctrl); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
780 } |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
781 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
782 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
783 /* |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
784 * Set the time-seek position |
202 | 785 * The playing thread will do the "seeking", which means sub-tune |
672
f22a708d29fd
Remove some camelcasing / hungarian notation.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
786 * changing in XMMS-SID's case. time argument is time in seconds, |
202 | 787 * in contrast to milliseconds used in other occasions. |
788 * | |
789 * This function is called whenever position slider is clicked or | |
790 * 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
|
791 */ |
672
f22a708d29fd
Remove some camelcasing / hungarian notation.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
792 void xs_seek(gint time) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
793 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
794 XS_MUTEX_LOCK(xs_status); |
798 | 795 if (!xs_status.tuneInfo || !xs_status.playing) |
797 | 796 goto out; |
132
4162a5370b9e
Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
797 |
797 | 798 switch (xs_cfg.subsongControl) |
799 { | |
800 case XS_SSC_SEEK: | |
801 if (time < xs_status.lastTime) | |
802 { | |
803 if (xs_status.currSong > 1) | |
804 xs_status.currSong--; | |
805 } | |
806 else | |
807 if (time > xs_status.lastTime) | |
808 { | |
809 if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) | |
810 xs_status.currSong++; | |
811 } | |
812 break; | |
78
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
813 |
797 | 814 case XS_SSC_POPUP: |
815 xs_subctrl_open(); | |
816 break; | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
817 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
818 /* If we have song-position patch, check settings */ |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
819 #ifdef HAVE_SONG_POSITION |
797 | 820 case XS_SSC_PATCH: |
821 if (time > 0 && time <= xs_status.tuneInfo->nsubTunes) | |
822 xs_status.currSong = time; | |
823 break; | |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
824 #endif |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
825 } |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
826 |
797 | 827 out: |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
828 XS_MUTEX_UNLOCK(xs_status); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
829 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
830 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
831 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
832 /* |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
833 * Return the playing "position/time" |
202 | 834 * Determine current position/time in song. Used by XMMS to update |
835 * the song clock and position slider and MOST importantly to determine | |
836 * END OF SONG! Return value of -2 means error, XMMS opens an audio | |
837 * 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
|
838 */ |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
839 gint xs_get_time(void) |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
840 { |
797 | 841 int err; |
842 | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
843 /* If errorflag is set, return -2 to signal it to XMMS's idle callback */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
844 XS_MUTEX_LOCK(xs_status); |
798 | 845 if (xs_status.error) |
797 | 846 { |
847 err = -2; | |
848 goto error; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
849 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
850 |
797 | 851 /* If there is no tune or tune has ended, return -1 */ |
798 | 852 if (!xs_status.tuneInfo || !xs_status.playing) |
797 | 853 { |
854 err = -1; | |
855 goto error; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
856 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
857 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
858 /* Let's see what we do */ |
797 | 859 switch (xs_cfg.subsongControl) |
860 { | |
861 case XS_SSC_SEEK: | |
862 xs_status.lastTime = (xs_plugin_ip.output->output_time() / 1000); | |
863 break; | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
864 |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
865 #ifdef HAVE_SONG_POSITION |
797 | 866 case XS_SSC_PATCH: |
867 set_song_position(xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes); | |
868 break; | |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
869 #endif |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
870 } |
230 | 871 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
872 XS_MUTEX_UNLOCK(xs_status); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
873 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
874 /* Return output time reported by audio output plugin */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
875 return xs_plugin_ip.output->output_time(); |
797 | 876 |
877 error: | |
878 XS_MUTEX_UNLOCK(xs_status); | |
879 return err; | |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
880 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
881 |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
882 |
477
53bdac2e0dcb
Moved sldb glue functions here; Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
883 /* Return song information: called by XMMS when initially loading the playlist. |
202 | 884 * Subsequent changes to information are made by the player thread, |
885 * 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
|
886 */ |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
887 void xs_get_song_info(gchar * songFilename, gchar ** songTitle, gint * songLength) |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
888 { |
751 | 889 XSTuneInfo *info; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
890 |
797 | 891 XS_MUTEX_LOCK(xs_status); |
892 | |
794
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
893 if (xs_status.engine == NULL) |
797 | 894 goto out; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
895 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
896 /* Get tune information from emulation engine */ |
753 | 897 info = xs_status.engine->plrGetSIDInfo(songFilename); |
797 | 898 if (!info) |
899 goto out; | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
900 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
901 /* Get sub-tune information, if available */ |
797 | 902 if (info->startTune > 0 && info->startTune <= info->nsubTunes) |
903 { | |
904 gint length; | |
905 | |
672
f22a708d29fd
Remove some camelcasing / hungarian notation.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
906 (*songTitle) = xs_make_titlestring(info, info->startTune); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
907 |
797 | 908 length = info->subTunes[info->startTune-1].tuneLength; |
909 (*songLength) = length < 0 ? -1 : length * 1000; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
910 } |
177
6e350784aa57
Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
911 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
912 /* Free tune information */ |
672
f22a708d29fd
Remove some camelcasing / hungarian notation.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
913 xs_tuneinfo_free(info); |
797 | 914 |
915 out: | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
916 XS_MUTEX_UNLOCK(xs_status); |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
917 } |