Mercurial > hg > xmms-sid
annotate src/xmms-sid.c @ 846:7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
extensions).
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 08 Nov 2012 22:43:45 +0200 |
parents | 29f3c3f29c0d |
children | 2663b1ac9ce6 |
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 |
297 | 29 #include <stdarg.h> |
184
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
30 #include <gdk/gdkkeysyms.h> |
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
31 #include <gtk/gtk.h> |
235
d04191d1ea64
Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
32 |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 #include "xs_config.h" |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 #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
|
35 #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
|
36 #include "xs_title.h" |
235
d04191d1ea64
Add xs_fileinfo.h, move appropriate function prototypes there.
Matti Hamalainen <ccr@tnsp.org>
parents:
232
diff
changeset
|
37 #include "xs_fileinfo.h" |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 #include "xs_interface.h" |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 #include "xs_glade.h" |
526
fa95d942f226
Header cleanup; Moved some types from xmms-sid.h to xs_player.h; Renamed few functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
477
diff
changeset
|
40 #include "xs_player.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
|
41 #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
|
42 |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 |
787
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
44 /* List of emulator engines |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
45 */ |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
46 #ifdef HAVE_SIDPLAY1 |
835
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
47 # include "xs_sidplay1.h" |
787
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
48 #endif |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
49 #ifdef HAVE_SIDPLAY2 |
835
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
50 # include "xs_sidplay2.h" |
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
51 #endif |
839
29f3c3f29c0d
Finalize libSIDPlay2 vs FP configuration stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
52 #ifdef HAVE_SIDPLAYFP |
29f3c3f29c0d
Finalize libSIDPlay2 vs FP configuration stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
53 # include "xs_sidplayfp.h" |
787
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
54 #endif |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
55 |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
56 static XSEngine xs_enginelist[] = |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
57 { |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
58 #ifdef HAVE_SIDPLAY1 |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
59 { |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
60 XS_ENG_SIDPLAY1, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
61 xs_sidplay1_probe, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
62 xs_sidplay1_init, xs_sidplay1_close, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
63 xs_sidplay1_initsong, xs_sidplay1_fillbuffer, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
64 xs_sidplay1_load, xs_sidplay1_delete, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
65 xs_sidplay1_getinfo, xs_sidplay1_updateinfo, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
66 NULL |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
67 }, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
68 #endif |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
69 #ifdef HAVE_SIDPLAY2 |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
70 { |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
71 XS_ENG_SIDPLAY2, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
72 xs_sidplay2_probe, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
73 xs_sidplay2_init, xs_sidplay2_close, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
74 xs_sidplay2_initsong, xs_sidplay2_fillbuffer, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
75 xs_sidplay2_load, xs_sidplay2_delete, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
76 xs_sidplay2_getinfo, xs_sidplay2_updateinfo, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
77 xs_sidplay2_flush |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
78 }, |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
79 #endif |
839
29f3c3f29c0d
Finalize libSIDPlay2 vs FP configuration stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
80 #ifdef HAVE_SIDPLAYFP |
835
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
81 { |
839
29f3c3f29c0d
Finalize libSIDPlay2 vs FP configuration stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
835
diff
changeset
|
82 XS_ENG_SIDPLAYFP, |
835
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
83 xs_sidplayfp_probe, |
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
84 xs_sidplayfp_init, xs_sidplayfp_close, |
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
85 xs_sidplayfp_initsong, xs_sidplayfp_fillbuffer, |
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
86 xs_sidplayfp_load, xs_sidplayfp_delete, |
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
87 xs_sidplayfp_getinfo, xs_sidplayfp_updateinfo, |
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
88 xs_sidplayfp_flush |
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
89 }, |
d508c7c4bc69
Add libSIDPlay2-FP backend interface module.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
90 #endif |
787
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
91 }; |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
92 |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
93 static const gint xs_nenginelist = sizeof(xs_enginelist) / sizeof(xs_enginelist[0]); |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
94 |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
95 |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
96 /* Global variables |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 */ |
751 | 98 XSEngineState xs_status; |
230 | 99 XS_MUTEX(xs_status); |
532 | 100 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
|
101 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
102 static GtkWidget *xs_subctrl = NULL; |
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
103 static GtkObject *xs_subctrl_adj = NULL; |
230 | 104 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
|
105 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
106 void xs_subctrl_close(void); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
107 void xs_subctrl_update(void); |
477
53bdac2e0dcb
Moved sldb glue functions here; Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
108 |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
109 |
787
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
110 /* Error messages |
297 | 111 */ |
392
b09d74eb71e6
Working on getting STIL and SLDB using completely dynamically allocated
Matti Hamalainen <ccr@tnsp.org>
parents:
383
diff
changeset
|
112 void xs_error(const char *fmt, ...) |
297 | 113 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
114 va_list ap; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
115 fprintf(stderr, "XMMS-SID: "); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
116 va_start(ap, fmt); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
117 vfprintf(stderr, fmt, ap); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
118 va_end(ap); |
297 | 119 } |
120 | |
299 | 121 #ifndef DEBUG_NP |
122 void XSDEBUG(const char *fmt, ...) | |
123 { | |
124 #ifdef DEBUG | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
125 va_list ap; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
126 fprintf(stderr, "XSDEBUG: "); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
127 va_start(ap, fmt); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
128 vfprintf(stderr, fmt, ap); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
129 va_end(ap); |
299 | 130 #endif |
131 } | |
132 #endif | |
133 | |
461
a1224c1f8670
STILdb handling glue moved to xmms-sid.c
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
134 |
297 | 135 /* |
230 | 136 * Initialization functions |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 */ |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
138 void xs_reinit(void) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 { |
787
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
140 gint engine; |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
141 gboolean initialized = FALSE; |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
142 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
143 /* Stop playing, if we are */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
144 XS_MUTEX_LOCK(xs_status); |
798 | 145 if (xs_status.playing) |
797 | 146 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
147 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
148 xs_stop(); |
797 | 149 } |
150 else | |
151 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
152 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
153 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
154 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
155 XS_MUTEX_LOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
156 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
|
157 |
809
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
158 // Close player stuff |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
159 xs_tuneinfo_free(xs_status.tuneInfo); |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
160 xs_status.tuneInfo = NULL; |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
161 if (xs_status.engine != NULL) |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
162 { |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
163 xs_status.engine->plrDeleteSID(&xs_status); |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
164 xs_status.engine->plrClose(&xs_status); |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
165 } |
8f155eca3612
Shut down/delete player resources at reinit.
Matti Hamalainen <ccr@tnsp.org>
parents:
799
diff
changeset
|
166 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
167 /* Initialize status and sanitize configuration */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
168 memset(&xs_status, 0, sizeof(xs_status)); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
169 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
170 if (xs_cfg.audioFrequency < 8000) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
171 xs_cfg.audioFrequency = 8000; |
273
f6daddca03c7
Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents:
264
diff
changeset
|
172 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
173 xs_status.audioFrequency = xs_cfg.audioFrequency; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
174 xs_status.audioBitsPerSample = xs_cfg.audioBitsPerSample; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
175 xs_status.audioChannels = xs_cfg.audioChannels; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
176 xs_status.audioFormat = -1; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
177 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
178 /* Try to initialize emulator engine */ |
787
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
179 XSDEBUG("initializing emulator engine #%i...\n", xs_cfg.playerEngine); |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
180 |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
181 for (engine = 0; engine < xs_nenginelist && !initialized; engine++) |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
182 { |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
183 if (xs_enginelist[engine].plrIdent == xs_cfg.playerEngine && |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
184 xs_enginelist[engine].plrInit(&xs_status)) |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
185 { |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
186 initialized = TRUE; |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
187 xs_status.engine = &xs_enginelist[engine]; |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
188 } |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
189 } |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
190 |
8f0d11865742
Move some code around, remove xs_player.c
Matti Hamalainen <ccr@tnsp.org>
parents:
767
diff
changeset
|
191 XSDEBUG("init#1: %s, %i\n", initialized ? "OK" : "FAILED", 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
|
192 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
193 /* 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
|
194 xs_cfg.audioFrequency = xs_status.audioFrequency; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
195 xs_cfg.audioBitsPerSample = xs_status.audioBitsPerSample; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
196 xs_cfg.audioChannels = xs_status.audioChannels; |
273
f6daddca03c7
Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents:
264
diff
changeset
|
197 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
198 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
199 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
|
200 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
201 /* Initialize song-length database */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
202 xs_songlen_close(); |
797 | 203 if (xs_cfg.songlenDBEnable && (xs_songlen_init() != 0)) |
204 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
205 xs_error("Error initializing song-length database!\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
206 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
207 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
208 /* Initialize STIL database */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
209 xs_stil_close(); |
797 | 210 if (xs_cfg.stilDBEnable && (xs_stil_init() != 0)) |
211 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
212 xs_error("Error initializing STIL database!\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
213 } |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
214 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
215 |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
216 |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
217 /* |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
218 * Initialize XMMS-SID |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
219 */ |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
220 void xs_init(void) |
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
221 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
222 XSDEBUG("xs_init()\n"); |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
223 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
224 /* Initialize and get configuration */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
225 xs_init_configuration(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
226 xs_read_configuration(); |
147
a7abcda7a86c
SLDB, STIL and emulation engine settings are now updated
Matti Hamalainen <ccr@tnsp.org>
parents:
140
diff
changeset
|
227 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
228 /* Initialize subsystems */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
229 xs_reinit(); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
230 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
231 XSDEBUG("OK\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
232 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
233 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
234 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 /* |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
236 * Shut down XMMS-SID |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
237 */ |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
238 void xs_close(void) |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
239 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
240 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
|
241 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
242 /* Stop playing, free structures */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
243 xs_stop(); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
244 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
245 xs_tuneinfo_free(xs_status.tuneInfo); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
246 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
|
247 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
|
248 { |
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
249 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
|
250 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
|
251 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
252 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
253 xs_songlen_close(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
254 xs_stil_close(); |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
255 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
256 XSDEBUG("shutdown finished.\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
260 /* |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
261 * 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
|
262 */ |
688 | 263 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
|
264 { |
688 | 265 gchar *ext; |
760
f6a57c0656fa
Handle engine initialization failures a bit more .. "gracefully".
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
266 if (xs_status.engine == NULL) |
f6a57c0656fa
Handle engine initialization failures a bit more .. "gracefully".
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
267 return FALSE; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
268 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
269 /* Check the filename */ |
688 | 270 if (filename == NULL) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
271 return FALSE; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
272 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
273 /* 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
|
274 if (xs_cfg.detectMagic && xs_status.engine->plrProbe != NULL) |
797 | 275 { |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
276 gboolean res = FALSE; |
751 | 277 XSFile *f; |
797 | 278 if ((f = xs_fopen(filename, "rb")) != NULL) |
279 { | |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
280 res = xs_status.engine->plrProbe(f); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
281 xs_fclose(f); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
282 } |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
283 return res; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
284 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
285 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
286 /* Detect just by checking filename extension */ |
763
61a527ac3baa
Cleanups, remove useless function.
Matti Hamalainen <ccr@tnsp.org>
parents:
760
diff
changeset
|
287 ext = strrchr(filename, '.'); |
797 | 288 if (ext) |
289 { | |
688 | 290 ext++; |
797 | 291 switch (xs_cfg.playerEngine) |
292 { | |
293 case XS_ENG_SIDPLAY1: | |
294 if (!g_strcasecmp(ext, "psid")) | |
295 return TRUE; | |
296 if (!g_strcasecmp(ext, "sid")) | |
297 return TRUE; | |
298 if (!g_strcasecmp(ext, "dat")) | |
299 return TRUE; | |
300 if (!g_strcasecmp(ext, "inf")) | |
301 return TRUE; | |
302 if (!g_strcasecmp(ext, "info")) | |
303 return TRUE; | |
304 break; | |
846
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
305 |
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
306 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
|
307 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
|
308 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
|
309 return TRUE; |
7b11ba6fc4cc
Improve and fix probing (FP backend wasn't used when checking filename
Matti Hamalainen <ccr@tnsp.org>
parents:
839
diff
changeset
|
310 break; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
311 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
312 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
313 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
314 return FALSE; |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
315 } |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
316 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
317 |
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
318 /* |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 * Main playing thread loop |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
320 */ |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
321 void *xs_playthread(void *argPointer) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
322 { |
751 | 323 XSEngineState myStatus; |
324 XSTuneInfo *myTune; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
325 gboolean audioOpen = FALSE, doPlay = FALSE, isFound = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
326 gint audioGot, songLength, i; |
748
d9d769b5dbe2
Remove oversampling support.
Matti Hamalainen <ccr@tnsp.org>
parents:
735
diff
changeset
|
327 gchar *audioBuffer = NULL, *tmpTitle; |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
328 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
329 (void) argPointer; |
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 /* Initialize */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
332 XSDEBUG("entering player thread\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
333 XS_MUTEX_LOCK(xs_status); |
751 | 334 memcpy(&myStatus, &xs_status, sizeof(XSEngineState)); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
335 myTune = xs_status.tuneInfo; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
336 for (i = 0; i <= myTune->nsubTunes; i++) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
337 myTune->subTunes[i].tunePlayed = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
338 XS_MUTEX_UNLOCK(xs_status); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
340 /* Allocate audio buffer */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
341 audioBuffer = (gchar *) g_malloc(XS_AUDIOBUF_SIZE); |
797 | 342 if (audioBuffer == NULL) |
343 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
344 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
|
345 goto xs_err_exit; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
346 } |
273
f6daddca03c7
Merging in oversampling support, audio settings sanitation.
Matti Hamalainen <ccr@tnsp.org>
parents:
264
diff
changeset
|
347 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
348 /* |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
349 * 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
|
350 */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
351 audioOpen = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
352 doPlay = TRUE; |
798 | 353 while (xs_status.playing && doPlay) |
797 | 354 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
355 /* Automatic sub-tune change logic */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
356 XS_MUTEX_LOCK(xs_cfg); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
357 XS_MUTEX_LOCK(xs_status); |
798 | 358 myStatus.playing = TRUE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
359 |
797 | 360 if (xs_status.currSong < 1 || myStatus.currSong < 1) |
361 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
362 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
363 XS_MUTEX_UNLOCK(xs_cfg); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
364 goto xs_err_exit; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
365 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
366 |
797 | 367 if (xs_cfg.subAutoEnable && (myStatus.currSong == xs_status.currSong)) |
368 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
369 /* Check if currently selected sub-tune has been played already */ |
797 | 370 if (myTune->subTunes[myStatus.currSong-1].tunePlayed) |
371 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
372 /* Find a tune that has not been played */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
373 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
|
374 isFound = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
375 i = 0; |
797 | 376 while (!isFound && (++i <= myTune->nsubTunes)) |
377 { | |
378 if (xs_cfg.subAutoMinOnly) | |
379 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
380 /* A tune with minimum length must be found */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
381 if (!myTune->subTunes[i-1].tunePlayed && |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
382 myTune->subTunes[i-1].tuneLength >= xs_cfg.subAutoMinTime) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
383 isFound = TRUE; |
797 | 384 } |
385 else | |
386 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
387 /* Any unplayed tune is okay */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
388 if (!myTune->subTunes[i-1].tunePlayed) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
389 isFound = TRUE; |
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 } |
281
d913f0f69487
Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
392 |
797 | 393 if (isFound) |
394 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
395 /* Set the new sub-tune */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
396 XSDEBUG("found #%i\n", i); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
397 xs_status.currSong = i; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
398 } else |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
399 /* This is the end */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
400 doPlay = FALSE; |
281
d913f0f69487
Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
401 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
402 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
403 XS_MUTEX_UNLOCK(xs_cfg); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
404 continue; /* This is ugly, but ... */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
405 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
406 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
407 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
408 /* 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
|
409 myStatus.currSong = xs_status.currSong; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
410 myTune->subTunes[myStatus.currSong-1].tunePlayed = TRUE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
411 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
412 XS_MUTEX_UNLOCK(xs_cfg); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
413 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
414 XSDEBUG("subtune #%i selected, initializing...\n", myStatus.currSong); |
281
d913f0f69487
Automatic sub-tune changing.
Matti Hamalainen <ccr@tnsp.org>
parents:
277
diff
changeset
|
415 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
416 GDK_THREADS_ENTER(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
417 xs_subctrl_update(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
418 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
|
419 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
420 /* Check minimum playtime */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
421 songLength = myTune->subTunes[myStatus.currSong-1].tuneLength; |
797 | 422 if (xs_cfg.playMinTimeEnable && songLength >= 0) |
423 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
424 if (songLength < xs_cfg.playMinTime) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
425 songLength = xs_cfg.playMinTime; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
426 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
427 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
428 /* Initialize song */ |
797 | 429 if (!myStatus.engine->plrInitSong(&myStatus)) |
430 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
431 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
|
432 myTune->sidFilename, myStatus.currSong); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
433 goto xs_err_exit; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
434 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
435 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
436 /* Open the audio output */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
437 XSDEBUG("open audio output (%d, %d, %d)\n", |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
438 myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels); |
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 if (!xs_plugin_ip.output-> |
797 | 441 open_audio(myStatus.audioFormat, myStatus.audioFrequency, myStatus.audioChannels)) |
442 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
443 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
|
444 myStatus.audioFormat, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
445 myStatus.audioFrequency, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
446 myStatus.audioChannels); |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
447 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
448 XS_MUTEX_LOCK(xs_status); |
798 | 449 xs_status.error = TRUE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
450 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
451 goto xs_err_exit; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
452 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
453 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
454 audioOpen = TRUE; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
455 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
456 /* Set song information for current subtune */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
457 XSDEBUG("set tune info\n"); |
753 | 458 myStatus.engine->plrUpdateSIDInfo(&myStatus); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
459 tmpTitle = xs_make_titlestring(myTune, myStatus.currSong); |
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 xs_plugin_ip.set_info( |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
462 tmpTitle, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
463 (songLength > 0) ? (songLength * 1000) : 0, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
464 -1, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
465 myStatus.audioFrequency, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
466 myStatus.audioChannels); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
467 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
468 g_free(tmpTitle); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
469 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
470 XSDEBUG("playing\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
471 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
472 /* |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
473 * Play the subtune |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
474 */ |
798 | 475 while (xs_status.playing && myStatus.playing && (xs_status.currSong == myStatus.currSong)) |
767 | 476 { |
753 | 477 audioGot = myStatus.engine->plrFillBuffer( |
748
d9d769b5dbe2
Remove oversampling support.
Matti Hamalainen <ccr@tnsp.org>
parents:
735
diff
changeset
|
478 &myStatus, audioBuffer, XS_AUDIOBUF_SIZE); |
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 /* I <3 visualice/haujobb */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
481 xs_plugin_ip.add_vis_pcm( |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
482 xs_plugin_ip.output->written_time(), |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
483 myStatus.audioFormat, myStatus.audioChannels, |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
484 audioGot, audioBuffer); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
485 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
486 /* Wait a little */ |
798 | 487 while (xs_status.playing && |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
488 (xs_status.currSong == myStatus.currSong) && |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
489 (xs_plugin_ip.output->buffer_free() < audioGot)) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
490 xmms_usleep(500); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
491 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
492 /* Output audio */ |
798 | 493 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
|
494 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
|
495 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
496 /* Check if we have played enough */ |
797 | 497 if (xs_cfg.playMaxTimeEnable) |
498 { | |
499 if (xs_cfg.playMaxTimeUnknown) | |
500 { | |
767 | 501 if (songLength < 0 && |
502 xs_plugin_ip.output->output_time() >= xs_cfg.playMaxTime * 1000) | |
798 | 503 myStatus.playing = FALSE; |
797 | 504 } |
505 else | |
506 { | |
767 | 507 if (xs_plugin_ip.output->output_time() >= xs_cfg.playMaxTime * 1000) |
798 | 508 myStatus.playing = FALSE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
509 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
510 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
511 |
797 | 512 if (songLength >= 0) |
513 { | |
767 | 514 if (xs_plugin_ip.output->output_time() >= songLength * 1000) |
798 | 515 myStatus.playing = FALSE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
516 } |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
517 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
518 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
519 XSDEBUG("subtune ended/stopped\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
520 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
521 /* Close audio output plugin */ |
797 | 522 if (audioOpen) |
523 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
524 XSDEBUG("close audio #1\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
525 xs_plugin_ip.output->close_audio(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
526 audioOpen = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
527 XSDEBUG("closed\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
528 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
529 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
530 /* Now determine if we continue by selecting other subtune or something */ |
798 | 531 if (!myStatus.playing && !xs_cfg.subAutoEnable) |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
532 doPlay = FALSE; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
533 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
534 |
402
f997b79a7251
More work on merging of improved STIL/SLDB handling code with completely
Matti Hamalainen <ccr@tnsp.org>
parents:
392
diff
changeset
|
535 xs_err_exit: |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
536 XSDEBUG("out of playing loop\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
537 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
538 /* Close audio output plugin */ |
797 | 539 if (audioOpen) |
540 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
541 XSDEBUG("close audio #2\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
542 xs_plugin_ip.output->close_audio(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
543 XSDEBUG("closed\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
544 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
545 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
546 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
|
547 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
548 /* Set playing status to false (stopped), thus when |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
549 * 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
|
550 * 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
|
551 * 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
|
552 */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
553 XS_MUTEX_LOCK(xs_status); |
798 | 554 xs_status.playing = FALSE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
555 XS_MUTEX_UNLOCK(xs_status); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
556 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
557 /* Exit the playing thread */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
558 XSDEBUG("exiting thread, bye.\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
559 XS_THREAD_EXIT(NULL); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
560 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
561 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
562 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
563 /* |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
564 * Start playing the given file |
202 | 565 * Here we load the tune and initialize the playing thread. |
566 * Usually you would also initialize the output-plugin, but | |
567 * 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
|
568 */ |
688 | 569 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
|
570 { |
760
f6a57c0656fa
Handle engine initialization failures a bit more .. "gracefully".
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
571 if (xs_status.engine == NULL) |
f6a57c0656fa
Handle engine initialization failures a bit more .. "gracefully".
Matti Hamalainen <ccr@tnsp.org>
parents:
753
diff
changeset
|
572 return; |
230 | 573 |
688 | 574 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
|
575 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
576 /* Get tune information */ |
753 | 577 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
|
578 return; |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
579 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
580 /* Initialize the tune */ |
797 | 581 if (!xs_status.engine->plrLoadSID(&xs_status, filename)) |
582 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
583 xs_tuneinfo_free(xs_status.tuneInfo); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
584 xs_status.tuneInfo = NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
585 return; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
586 } |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
587 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
588 XSDEBUG("load ok\n"); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
589 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
590 /* Set general status information */ |
798 | 591 xs_status.playing = TRUE; |
592 xs_status.error = FALSE; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
593 xs_status.currSong = xs_status.tuneInfo->startTune; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
594 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
595 /* Start the playing thread! */ |
797 | 596 if (pthread_create(&xs_decode_thread, NULL, xs_playthread, NULL) < 0) |
597 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
598 xs_error("Couldn't create playing thread!\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
599 xs_tuneinfo_free(xs_status.tuneInfo); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
600 xs_status.tuneInfo = NULL; |
753 | 601 xs_status.engine->plrDeleteSID(&xs_status); |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
602 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
603 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
604 /* 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
|
605 * 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
|
606 * and playing thread. |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
607 */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
608 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
|
609 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
610 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
611 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
612 /* |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
613 * Stop playing |
202 | 614 * Here we set the playing status to stop and wait for playing |
615 * thread to shut down. In any "correctly" done plugin, this is | |
616 * also the function where you close the output-plugin, but since | |
264 | 617 * XMMS-SID has special behaviour (audio opened/closed in the |
618 * playing thread), we don't do that here. | |
202 | 619 * |
620 * 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
|
621 */ |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
622 void xs_stop(void) |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
623 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
624 XSDEBUG("stop requested\n"); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
625 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
626 /* Close the sub-tune control window, if any */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
627 xs_subctrl_close(); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
628 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
629 /* Lock xs_status and stop playing thread */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
630 XS_MUTEX_LOCK(xs_status); |
798 | 631 if (xs_status.playing) |
797 | 632 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
633 XSDEBUG("stopping...\n"); |
798 | 634 xs_status.playing = FALSE; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
635 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
636 XS_THREAD_JOIN(xs_decode_thread); |
797 | 637 } |
638 else | |
639 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
640 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
641 } |
75
653c9b0d1320
SIDPlay2 support "works" now. Borked problems with threads.
Matti Hamalainen <ccr@tnsp.org>
parents:
74
diff
changeset
|
642 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
643 XSDEBUG("done, updating status\n"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
644 |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
645 /* Status is now stopped, update the sub-tune |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
646 * controller in fileinfo window (if open) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
647 */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
648 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
|
649 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
650 /* Free tune information */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
651 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
|
652 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
|
653 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
|
654 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
655 xs_tuneinfo_free(xs_status.tuneInfo); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
656 xs_status.tuneInfo = NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
657 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
658 XSDEBUG("ok\n"); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
659 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
660 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
661 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
662 /* |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
663 * Pause/unpause the playing |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
664 */ |
688 | 665 void xs_pause(short pause) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
666 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
667 XS_MUTEX_LOCK(xs_status); |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
668 xs_status.paused = pause; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
669 XS_MUTEX_UNLOCK(xs_status); |
264 | 670 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
671 xs_subctrl_close(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
672 xs_fileinfo_update(); |
688 | 673 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
|
674 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
675 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
676 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
677 /* |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
678 * Pop-up subtune selector |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
679 */ |
230 | 680 void xs_subctrl_setsong(void) |
681 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
682 gint n; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
683 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
684 XS_MUTEX_LOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
685 XS_MUTEX_LOCK(xs_subctrl); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
686 |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
687 if (!xs_status.paused && xs_status.tuneInfo && xs_status.playing) |
797 | 688 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
689 n = (gint) GTK_ADJUSTMENT(xs_subctrl_adj)->value; |
797 | 690 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
|
691 xs_status.currSong = n; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
692 } |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
693 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
694 XS_MUTEX_UNLOCK(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
695 XS_MUTEX_UNLOCK(xs_status); |
230 | 696 } |
697 | |
698 | |
699 void xs_subctrl_prevsong(void) | |
700 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
701 XS_MUTEX_LOCK(xs_status); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
702 |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
703 if (!xs_status.paused && xs_status.tuneInfo && xs_status.playing) |
797 | 704 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
705 if (xs_status.currSong > 1) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
706 xs_status.currSong--; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
707 } |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
708 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
709 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
|
710 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
711 xs_subctrl_update(); |
230 | 712 } |
713 | |
714 | |
715 void xs_subctrl_nextsong(void) | |
716 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
717 XS_MUTEX_LOCK(xs_status); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
718 |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
719 if (!xs_status.paused && xs_status.tuneInfo && xs_status.playing) |
797 | 720 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
721 if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
722 xs_status.currSong++; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
723 } |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
724 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
725 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
|
726 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
727 xs_subctrl_update(); |
230 | 728 } |
729 | |
177
6e350784aa57
Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
730 |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
731 void xs_subctrl_update(void) |
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 GtkAdjustment *tmpAdj; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
734 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
735 XS_MUTEX_LOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
736 XS_MUTEX_LOCK(xs_subctrl); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
737 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
738 /* Check if control window exists, we are currently playing and have a tune */ |
797 | 739 if (xs_subctrl) |
740 { | |
799
13483b855058
Fix subsong control window problems during pause state.
Matti Hamalainen <ccr@tnsp.org>
parents:
798
diff
changeset
|
741 if (!xs_status.paused && xs_status.tuneInfo && xs_status.playing) |
797 | 742 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
743 tmpAdj = GTK_ADJUSTMENT(xs_subctrl_adj); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
744 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
745 tmpAdj->value = xs_status.currSong; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
746 tmpAdj->lower = 1; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
747 tmpAdj->upper = xs_status.tuneInfo->nsubTunes; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
748 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
749 XS_MUTEX_UNLOCK(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
750 gtk_adjustment_value_changed(tmpAdj); |
797 | 751 } |
752 else | |
753 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
754 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
755 XS_MUTEX_UNLOCK(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
756 xs_subctrl_close(); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
757 } |
797 | 758 } |
759 else | |
760 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
761 XS_MUTEX_UNLOCK(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
762 XS_MUTEX_UNLOCK(xs_status); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
763 } |
177
6e350784aa57
Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
764 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
765 xs_fileinfo_update(); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
766 } |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
767 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
768 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
769 void xs_subctrl_close(void) |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
770 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
771 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
|
772 |
797 | 773 if (xs_subctrl) |
774 { | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
775 gtk_widget_destroy(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
776 xs_subctrl = NULL; |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
777 } |
232
e613873c3379
Thread locking now final. All parts, including GTK GUI, should be(?)
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
778 |
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 |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
783 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
|
784 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
785 (void) win; |
184
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
786 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
787 if (ev->keyval == GDK_Escape) |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
788 xs_subctrl_close(); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
789 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
790 return FALSE; |
184
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
791 } |
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
792 |
4406e91d2da3
Subtune control slider in fileinfo-window now works. Various fixes.
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
793 |
294
f0ece2d20094
Do correct typecasts and declare xs_subctrl_open arguments as void.
Matti Hamalainen <ccr@tnsp.org>
parents:
281
diff
changeset
|
794 void xs_subctrl_open(void) |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
795 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
796 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
|
797 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
798 XS_MUTEX_LOCK(xs_subctrl); |
797 | 799 |
798 | 800 if (!xs_status.tuneInfo || !xs_status.playing || |
797 | 801 xs_subctrl || xs_status.tuneInfo->nsubTunes <= 1) |
802 goto out; | |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
803 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
804 /* Create the pop-up window */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
805 xs_subctrl = gtk_window_new(GTK_WINDOW_DIALOG); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
806 gtk_widget_set_name(xs_subctrl, "xs_subctrl"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
807 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
|
808 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
809 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
|
810 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
|
811 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
|
812 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
|
813 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
814 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
|
815 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
|
816 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
817 gtk_widget_realize(xs_subctrl); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
818 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
|
819 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
820 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
821 /* Create the control widgets */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
822 frame25 = gtk_frame_new(NULL); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
823 gtk_container_add(GTK_CONTAINER(xs_subctrl), frame25); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
824 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
|
825 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
|
826 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
827 hbox15 = gtk_hbox_new(FALSE, 4); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
828 gtk_container_add(GTK_CONTAINER(frame25), hbox15); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
829 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
830 subctrl_prev = gtk_button_new_with_label(" < "); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
831 gtk_widget_set_name(subctrl_prev, "subctrl_prev"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
832 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
|
833 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
834 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
|
835 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
|
836 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
837 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
|
838 gtk_widget_set_name(subctrl_current, "subctrl_current"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
839 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
|
840 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
|
841 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
|
842 gtk_widget_grab_focus(subctrl_current); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
843 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
844 subctrl_next = gtk_button_new_with_label(" > "); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
845 gtk_widget_set_name(subctrl_next, "subctrl_next"); |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
846 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
|
847 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
848 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
|
849 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
|
850 XS_SIGNAL_CONNECT(xs_subctrl, "key_press_event", xs_subctrl_keypress, NULL); |
230 | 851 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
852 gtk_widget_show_all(xs_subctrl); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
853 |
797 | 854 out: |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
855 XS_MUTEX_UNLOCK(xs_subctrl); |
140
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
856 } |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
857 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
858 |
8b9c14540e53
- Added UADE-style popup subsong-selector
Matti Hamalainen <ccr@tnsp.org>
parents:
138
diff
changeset
|
859 /* |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
860 * Set the time-seek position |
202 | 861 * 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
|
862 * changing in XMMS-SID's case. time argument is time in seconds, |
202 | 863 * in contrast to milliseconds used in other occasions. |
864 * | |
865 * This function is called whenever position slider is clicked or | |
866 * 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
|
867 */ |
672
f22a708d29fd
Remove some camelcasing / hungarian notation.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
868 void xs_seek(gint time) |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
869 { |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
870 XS_MUTEX_LOCK(xs_status); |
798 | 871 if (!xs_status.tuneInfo || !xs_status.playing) |
797 | 872 goto out; |
132
4162a5370b9e
Added "seek"-subsong control option, in style of xmms-sidplay.
Matti Hamalainen <ccr@tnsp.org>
parents:
127
diff
changeset
|
873 |
797 | 874 switch (xs_cfg.subsongControl) |
875 { | |
876 case XS_SSC_SEEK: | |
877 if (time < xs_status.lastTime) | |
878 { | |
879 if (xs_status.currSong > 1) | |
880 xs_status.currSong--; | |
881 } | |
882 else | |
883 if (time > xs_status.lastTime) | |
884 { | |
885 if (xs_status.currSong < xs_status.tuneInfo->nsubTunes) | |
886 xs_status.currSong++; | |
887 } | |
888 break; | |
78
ab522ab65c85
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
889 |
797 | 890 case XS_SSC_POPUP: |
891 xs_subctrl_open(); | |
892 break; | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
893 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
894 /* 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
|
895 #ifdef HAVE_SONG_POSITION |
797 | 896 case XS_SSC_PATCH: |
897 if (time > 0 && time <= xs_status.tuneInfo->nsubTunes) | |
898 xs_status.currSong = time; | |
899 break; | |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
900 #endif |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
901 } |
103
fe83646e6baa
Changed plrFillBuffer()-functions to return actual number of samples computed.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
902 |
797 | 903 out: |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
904 XS_MUTEX_UNLOCK(xs_status); |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
905 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
906 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
907 |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
908 /* |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
909 * Return the playing "position/time" |
202 | 910 * Determine current position/time in song. Used by XMMS to update |
911 * the song clock and position slider and MOST importantly to determine | |
912 * END OF SONG! Return value of -2 means error, XMMS opens an audio | |
913 * 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
|
914 */ |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
915 gint xs_get_time(void) |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
916 { |
797 | 917 int err; |
918 | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
919 /* 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
|
920 XS_MUTEX_LOCK(xs_status); |
798 | 921 if (xs_status.error) |
797 | 922 { |
923 err = -2; | |
924 goto error; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
925 } |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
926 |
797 | 927 /* If there is no tune or tune has ended, return -1 */ |
798 | 928 if (!xs_status.tuneInfo || !xs_status.playing) |
797 | 929 { |
930 err = -1; | |
931 goto error; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
932 } |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
933 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
934 /* Let's see what we do */ |
797 | 935 switch (xs_cfg.subsongControl) |
936 { | |
937 case XS_SSC_SEEK: | |
938 xs_status.lastTime = (xs_plugin_ip.output->output_time() / 1000); | |
939 break; | |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
940 |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
941 #ifdef HAVE_SONG_POSITION |
797 | 942 case XS_SSC_PATCH: |
943 set_song_position(xs_status.currSong, 1, xs_status.tuneInfo->nsubTunes); | |
944 break; | |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
945 #endif |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
946 } |
230 | 947 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
948 XS_MUTEX_UNLOCK(xs_status); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
949 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
950 /* Return output time reported by audio output plugin */ |
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
951 return xs_plugin_ip.output->output_time(); |
797 | 952 |
953 error: | |
954 XS_MUTEX_UNLOCK(xs_status); | |
955 return err; | |
71
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
956 } |
2b32c75729ce
Started modularizing, separated sidplay1 things into a "wrapper" module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
957 |
73
2bc607888f53
Added libsidplay2 module, lots of reworking of internals, sidplay1 support
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
958 |
477
53bdac2e0dcb
Moved sldb glue functions here; Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
472
diff
changeset
|
959 /* Return song information: called by XMMS when initially loading the playlist. |
202 | 960 * Subsequent changes to information are made by the player thread, |
961 * 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
|
962 */ |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
963 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
|
964 { |
751 | 965 XSTuneInfo *info; |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
966 |
797 | 967 XS_MUTEX_LOCK(xs_status); |
968 | |
794
3012740d014c
Add some NULL pointer checks in case the emulator engine backend didn't
Matti Hamalainen <ccr@tnsp.org>
parents:
787
diff
changeset
|
969 if (xs_status.engine == NULL) |
797 | 970 goto out; |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
971 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
972 /* Get tune information from emulation engine */ |
753 | 973 info = xs_status.engine->plrGetSIDInfo(songFilename); |
797 | 974 if (!info) |
975 goto out; | |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
976 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
977 /* Get sub-tune information, if available */ |
797 | 978 if (info->startTune > 0 && info->startTune <= info->nsubTunes) |
979 { | |
980 gint length; | |
981 | |
672
f22a708d29fd
Remove some camelcasing / hungarian notation.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
982 (*songTitle) = xs_make_titlestring(info, info->startTune); |
359
b1a858b8cb1a
Re-indentation all (non-generated) code.
Matti Hamalainen <ccr@tnsp.org>
parents:
354
diff
changeset
|
983 |
797 | 984 length = info->subTunes[info->startTune-1].tuneLength; |
985 (*songLength) = length < 0 ? -1 : length * 1000; | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
986 } |
177
6e350784aa57
Various cleanups. Min-playtime option now works. Configuration has more
Matti Hamalainen <ccr@tnsp.org>
parents:
172
diff
changeset
|
987 |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
988 /* Free tune information */ |
672
f22a708d29fd
Remove some camelcasing / hungarian notation.
Matti Hamalainen <ccr@tnsp.org>
parents:
660
diff
changeset
|
989 xs_tuneinfo_free(info); |
797 | 990 |
991 out: | |
660
b0743dc9165d
Change tabs to 4 spaces, everywhere.
Matti Hamalainen <ccr@tnsp.org>
parents:
659
diff
changeset
|
992 XS_MUTEX_UNLOCK(xs_status); |
87
94497283affa
Various fixes and improvements
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
993 } |