Mercurial > audlegacy-plugins
annotate src/sexypsf/plugin.c @ 2225:6b45e6441fd9
fix from Andrew O. Shadoura (chrome|debian)
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Wed, 12 Dec 2007 19:37:42 +0100 |
parents | feb0e916f8bc |
children | 4d6045c20cc5 |
rev | line source |
---|---|
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
1 /* sexyPSF - PSF1 player |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
2 * Copyright (C) 2002-2004 xodnizel |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
3 * |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
4 * This library is free software; you can redistribute it and/or |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
5 * modify it under the terms of the GNU Lesser General Public |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
6 * License as published by the Free Software Foundation; either |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
7 * version 2.1 of the License, or (at your option) any later version. |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
8 * |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
9 * This library is distributed in the hope that it will be useful, |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
12 * Lesser General Public License for more details. |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
13 * |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
14 * You should have received a copy of the GNU Lesser General Public |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
15 * License along with this library; if not, write to the Free Software |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
17 */ |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
18 |
1954
6acf1bda788b
Removed some extraneous includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1952
diff
changeset
|
19 #include <audacious/plugin.h> |
1950
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1691
diff
changeset
|
20 #include <audacious/output.h> |
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1691
diff
changeset
|
21 #include <audacious/main.h> |
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1691
diff
changeset
|
22 #include <audacious/util.h> |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
23 #include <stdio.h> |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
24 #include <stdlib.h> |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
25 #include <string.h> |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
26 #include <unistd.h> |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
27 #include "driver.h" |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
28 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
29 static volatile int seek = 0; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
30 static volatile gboolean playing = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
31 static volatile gboolean paused = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
32 static volatile gboolean stop = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
33 static volatile gboolean nextsong = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
34 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
35 extern InputPlugin sexypsf_ip; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
36 static gboolean audio_error = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
37 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
38 static PSFINFO *PSFInfo = NULL; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
39 static gchar *fnsave = NULL; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
40 static GThread *dethread = NULL; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
41 static InputPlayback *playback = NULL; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
42 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
43 static gchar *get_title_psf(gchar *fn); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
44 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
45 static int is_our_fd(gchar *filename, VFSFile *file) { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
46 gchar magic[4]; |
1978 | 47 aud_vfs_fread(magic, 1, 4, file); |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
48 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
49 // only allow PSF1 for now |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
50 if (!memcmp(magic, "PSF\x01", 4)) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
51 return 1; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
52 return 0; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
53 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
54 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
55 void sexypsf_update(unsigned char *buffer, long count) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
56 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
57 const int mask = ~((((16 / 8) * 2)) - 1); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
58 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
59 while (count > 0) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
60 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
61 int t = playback->output->buffer_free() & mask; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
62 if (t > count) |
1998
8f3188746b64
chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents:
1986
diff
changeset
|
63 playback->pass_audio(playback, |
1205 | 64 FMT_S16_NE, 2, count, buffer, NULL); |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
65 else |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
66 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
67 if (t) |
1998
8f3188746b64
chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents:
1986
diff
changeset
|
68 playback->pass_audio(playback, FMT_S16_NE, 2, t, buffer, NULL); |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
69 g_usleep((count-t)*1000*5/441/2); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
70 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
71 count -= t; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
72 buffer += t; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
73 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
74 if (seek) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
75 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
76 if(sexypsf_seek(seek)) |
1204
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
77 { |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
78 playback->output->flush(seek); |
1204
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
79 seek = 0; |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
80 } |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
81 else // negative time - must make a C time machine |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
82 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
83 sexypsf_stop(); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
84 return; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
85 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
86 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
87 if (stop) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
88 sexypsf_stop(); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
89 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
90 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
91 static gpointer sexypsf_playloop(gpointer arg) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
92 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
93 while (TRUE) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
94 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
95 sexypsf_execute(); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
96 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
97 /* we have reached the end of the song or a command was issued */ |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
98 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
99 playback->output->buffer_free(); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
100 playback->output->buffer_free(); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
101 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
102 if (stop) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
103 break; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
104 |
1204
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
105 if (seek) |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
106 { |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
107 playback->output->flush(seek); |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
108 if(!(PSFInfo = sexypsf_load(fnsave))) |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
109 break; |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
110 sexypsf_seek(seek); |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
111 seek = 0; |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
112 continue; |
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
113 } |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
114 |
1205 | 115 // timeout at the end of a file |
2128
feb0e916f8bc
adapted SexyPSF timeout to the method nenolod introduced in UPSE
mf0102 <0102@gmx.at>
parents:
2055
diff
changeset
|
116 while (playback->output->buffer_playing()) |
feb0e916f8bc
adapted SexyPSF timeout to the method nenolod introduced in UPSE
mf0102 <0102@gmx.at>
parents:
2055
diff
changeset
|
117 g_usleep(10000); |
feb0e916f8bc
adapted SexyPSF timeout to the method nenolod introduced in UPSE
mf0102 <0102@gmx.at>
parents:
2055
diff
changeset
|
118 |
1204
e9f10dac2f63
Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents:
1203
diff
changeset
|
119 break; |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
120 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
121 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
122 playback->output->close_audio(); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
123 if (!(stop)) nextsong = TRUE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
124 return NULL; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
125 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
126 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
127 static void sexypsf_xmms_play(InputPlayback *data) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
128 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
129 if (playing) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
130 return; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
131 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
132 playback = data; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
133 nextsong = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
134 paused = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
135 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
136 if (!playback->output->open_audio(FMT_S16_NE, 44100, 2)) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
137 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
138 audio_error = TRUE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
139 return; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
140 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
141 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
142 fnsave = malloc(strlen(data->filename)+1); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
143 strcpy(fnsave, data->filename); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
144 if(!(PSFInfo=sexypsf_load(data->filename))) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
145 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
146 playback->output->close_audio(); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
147 nextsong = 1; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
148 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
149 else |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
150 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
151 stop = seek = 0; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
152 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
153 gchar *name = get_title_psf(data->filename); |
1986 | 154 data->set_params(data, name, PSFInfo->length, 44100*2*2*8, 44100, 2); |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
155 g_free(name); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
156 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
157 playing = 1; |
1353
b5705eea23d9
sexypsf: new threading model
William Pitcock <nenolod@atheme-project.org>
parents:
1205
diff
changeset
|
158 dethread = g_thread_self(); |
1447
195b5657303e
updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents:
1431
diff
changeset
|
159 data->set_pb_ready(data); |
1353
b5705eea23d9
sexypsf: new threading model
William Pitcock <nenolod@atheme-project.org>
parents:
1205
diff
changeset
|
160 sexypsf_playloop(NULL); |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
161 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
162 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
163 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
164 static void sexypsf_xmms_stop(InputPlayback * playback) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
165 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
166 if (!playing) return; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
167 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
168 if (paused) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
169 playback->output->pause(0); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
170 paused = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
171 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
172 stop = TRUE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
173 g_thread_join(dethread); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
174 playing = FALSE; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
175 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
176 if (fnsave) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
177 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
178 free(fnsave); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
179 fnsave = NULL; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
180 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
181 sexypsf_freepsfinfo(PSFInfo); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
182 PSFInfo = NULL; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
183 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
184 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
185 static void sexypsf_xmms_pause(InputPlayback *playback, short p) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
186 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
187 if (!playing) return; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
188 playback->output->pause(p); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
189 paused = p; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
190 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
191 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
192 static void sexypsf_xmms_seek(InputPlayback * data, int time) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
193 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
194 if (!playing) return; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
195 seek = time * 1000; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
196 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
197 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
198 static int sexypsf_xmms_gettime(InputPlayback *playback) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
199 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
200 if (audio_error) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
201 return -2; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
202 if (nextsong) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
203 return -1; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
204 if (!playing) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
205 return 0; |
1205 | 206 |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
207 return playback->output->output_time(); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
208 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
209 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
210 static void sexypsf_xmms_getsonginfo(char *fn, char **title, int *length) |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
211 { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
212 PSFINFO *tmp; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
213 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
214 if((tmp = sexypsf_getpsfinfo(fn))) { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
215 *length = tmp->length; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
216 *title = get_title_psf(fn); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
217 sexypsf_freepsfinfo(tmp); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
218 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
219 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
220 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
221 static Tuple *get_aud_tuple_psf(gchar *fn) { |
1419
de310b4826de
sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
222 Tuple *tuple = NULL; |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
223 PSFINFO *tmp = sexypsf_getpsfinfo(fn); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
224 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
225 if (tmp->length) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
226 tuple = aud_tuple_new_from_filename(fn); |
2128
feb0e916f8bc
adapted SexyPSF timeout to the method nenolod introduced in UPSE
mf0102 <0102@gmx.at>
parents:
2055
diff
changeset
|
227 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, tmp->length); |
feb0e916f8bc
adapted SexyPSF timeout to the method nenolod introduced in UPSE
mf0102 <0102@gmx.at>
parents:
2055
diff
changeset
|
228 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, tmp->artist); |
feb0e916f8bc
adapted SexyPSF timeout to the method nenolod introduced in UPSE
mf0102 <0102@gmx.at>
parents:
2055
diff
changeset
|
229 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, tmp->game); |
feb0e916f8bc
adapted SexyPSF timeout to the method nenolod introduced in UPSE
mf0102 <0102@gmx.at>
parents:
2055
diff
changeset
|
230 aud_tuple_associate_string(tuple, -1, "game", tmp->game); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
231 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, tmp->title); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
232 aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, tmp->genre); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
233 aud_tuple_associate_string(tuple, FIELD_COPYRIGHT, NULL, tmp->copyright); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
234 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "sequenced"); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
235 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "PlayStation Audio"); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
236 aud_tuple_associate_string(tuple, -1, "console", "PlayStation"); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
237 aud_tuple_associate_string(tuple, -1, "dumper", tmp->psfby); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
238 aud_tuple_associate_string(tuple, FIELD_COMMENT, NULL, tmp->comment); |
1419
de310b4826de
sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
239 |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
240 sexypsf_freepsfinfo(tmp); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
241 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
242 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
243 return tuple; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
244 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
245 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
246 static gchar *get_title_psf(gchar *fn) { |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
247 gchar *title = NULL; |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
248 Tuple *tuple = get_aud_tuple_psf(fn); |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
249 |
1419
de310b4826de
sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
250 if (tuple != NULL) { |
2055 | 251 title = aud_tuple_formatter_make_title_string(tuple, aud_get_gentitle_format()); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
252 aud_tuple_free(tuple); |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
253 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
254 else |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
255 title = g_path_get_basename(fn); |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
256 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
257 return title; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
258 } |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
259 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
260 gchar *sexypsf_fmts[] = { "psf", "minipsf", NULL }; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
261 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
262 InputPlugin sexypsf_ip = |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
263 { |
1613
4eeeef9adab3
sexypsf: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1606
diff
changeset
|
264 .description = "PSF Audio Plugin", |
4eeeef9adab3
sexypsf: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1606
diff
changeset
|
265 .play_file = sexypsf_xmms_play, |
4eeeef9adab3
sexypsf: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1606
diff
changeset
|
266 .stop = sexypsf_xmms_stop, |
4eeeef9adab3
sexypsf: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1606
diff
changeset
|
267 .pause = sexypsf_xmms_pause, |
4eeeef9adab3
sexypsf: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1606
diff
changeset
|
268 .seek = sexypsf_xmms_seek, |
4eeeef9adab3
sexypsf: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1606
diff
changeset
|
269 .get_time = sexypsf_xmms_gettime, |
4eeeef9adab3
sexypsf: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1606
diff
changeset
|
270 .get_song_info = sexypsf_xmms_getsonginfo, |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
271 .get_song_tuple = get_aud_tuple_psf, |
1613
4eeeef9adab3
sexypsf: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents:
1606
diff
changeset
|
272 .is_our_file_from_vfs = is_our_fd, |
1979
839804c3b3a4
aud_vfs_extensions -> vfs_extensions, some vtable fixes
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
273 .vfs_extensions = sexypsf_fmts, |
1203
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
274 }; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
275 |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
276 InputPlugin *sexypsf_iplist[] = { &sexypsf_ip, NULL }; |
6eef4486e481
Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff
changeset
|
277 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1353
diff
changeset
|
278 DECLARE_PLUGIN(sexypsf, NULL, NULL, sexypsf_iplist, NULL, NULL, NULL, NULL, NULL); |