annotate src/sexypsf/plugin.c @ 1204:e9f10dac2f63

Fixed bug (no fadeout was applied at the end of a file)
author mf0102 <0102@gmx.at>
date Tue, 03 Jul 2007 12:15:45 +0200
parents 6eef4486e481
children c39a61e6a276
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
19 #include "audacious/output.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
20 #include "audacious/plugin.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
21 #include "audacious/titlestring.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
22 #include "audacious/util.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
23 #include "audacious/vfs.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
24 #include <stdio.h>
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
25 #include <stdlib.h>
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
26 #include <string.h>
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
27 #include <unistd.h>
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
28 #include "driver.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
29
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
30 static volatile int seek = 0;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
31 static volatile gboolean playing = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
32 static volatile gboolean paused = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
33 static volatile gboolean stop = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
34 static volatile gboolean nextsong = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
35
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
36 extern InputPlugin sexypsf_ip;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
37 static gboolean audio_error = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
38
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
39 static PSFINFO *PSFInfo = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
40 static gchar *fnsave = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
41 static GThread *dethread = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
42 static InputPlayback *playback = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
43
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
44 static gchar *get_title_psf(gchar *fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
45
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
46 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
47 gchar magic[4];
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
48 vfs_fread(magic, 1, 4, file);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
49
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
50 // only allow PSF1 for now
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
51 if (!memcmp(magic, "PSF\x01", 4))
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
52 return 1;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
53 return 0;
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
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 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
58 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
59 const int mask = ~((((16 / 8) * 2)) - 1);
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 while (count > 0)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
62 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
63 int t = playback->output->buffer_free() & mask;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
64 if (t > count)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
65 produce_audio(playback->output->written_time(), FMT_S16_NE, 2, count, buffer, NULL);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
66 else
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
67 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
68 if (t)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
69 produce_audio(playback->output->written_time(), FMT_S16_NE, 2, t, buffer, NULL);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
70 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
71 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
72 count -= t;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
73 buffer += t;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
74 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
75 if (seek)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
76 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
77 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
78 {
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
79 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
80 seek = 0;
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
81 }
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
82 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
83 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
84 sexypsf_stop();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
85 return;
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 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
88 if (stop)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
89 sexypsf_stop();
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
92 static gpointer sexypsf_playloop(gpointer arg)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
93 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
94 while (TRUE)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
95 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
96 sexypsf_execute();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
97
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
98 /* 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
99
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 playback->output->buffer_free();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
102
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
103 if (stop)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
104 break;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
105
1204
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
106 if (seek)
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
107 {
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
108 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
109 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
110 break;
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
111 sexypsf_seek(seek);
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
112 seek = 0;
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
113 continue;
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
114 }
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
115
1204
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
116 sleep(2);
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
117 break;
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
118 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
119
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
120 playback->output->close_audio();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
121 if (!(stop)) nextsong = TRUE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
122 g_thread_exit(NULL);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
123 return NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
124 }
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 static void sexypsf_xmms_play(InputPlayback *data)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
127 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
128 if (playing)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
129 return;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
130
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
131 playback = data;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
132 nextsong = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
133 paused = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
134
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
135 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
136 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
137 audio_error = TRUE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
138 return;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
139 }
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 fnsave = malloc(strlen(data->filename)+1);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
142 strcpy(fnsave, data->filename);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
143 if(!(PSFInfo=sexypsf_load(data->filename)))
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
144 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
145 playback->output->close_audio();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
146 nextsong = 1;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
147 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
148 else
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
149 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
150 stop = seek = 0;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
151
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
152 gchar *name = get_title_psf(data->filename);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
153 sexypsf_ip.set_info(name, PSFInfo->length, 44100*2*2*8, 44100, 2);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
154 g_free(name);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
155
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
156 playing = 1;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
157 dethread = g_thread_create((GThreadFunc)sexypsf_playloop,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
158 NULL, TRUE, NULL);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
159 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
160 }
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 static void sexypsf_xmms_stop(InputPlayback * playback)
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 if (!playing) return;
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 (paused)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
167 playback->output->pause(0);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
168 paused = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
169
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
170 stop = TRUE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
171 g_thread_join(dethread);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
172 playing = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
173
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
174 if (fnsave)
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 free(fnsave);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
177 fnsave = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
178 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
179 sexypsf_freepsfinfo(PSFInfo);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
180 PSFInfo = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
181 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
182
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
183 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
184 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
185 if (!playing) return;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
186 playback->output->pause(p);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
187 paused = p;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
188 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
189
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
190 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
191 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
192 if (!playing) return;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
193 seek = time * 1000;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
194 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
195
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
196 static int sexypsf_xmms_gettime(InputPlayback *playback)
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 if (audio_error)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
199 return -2;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
200 if (nextsong)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
201 return -1;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
202 if (!playing)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
203 return 0;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
204 return playback->output->output_time();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
205 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
206
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
207 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
208 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
209 PSFINFO *tmp;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
210
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
211 if((tmp = sexypsf_getpsfinfo(fn))) {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
212 *length = tmp->length;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
213 *title = get_title_psf(fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
214 sexypsf_freepsfinfo(tmp);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
215 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
216 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
217
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
218 static TitleInput *get_tuple_psf(gchar *fn) {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
219 TitleInput *tuple = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
220 PSFINFO *tmp = sexypsf_getpsfinfo(fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
221
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
222 if (tmp->length) {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
223 tuple = bmp_title_input_new();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
224 tuple->length = tmp->length;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
225 tuple->performer = g_strdup(tmp->artist);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
226 tuple->album_name = g_strdup(tmp->game);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
227 tuple->track_name = g_strdup(tmp->title);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
228 tuple->file_name = g_path_get_basename(fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
229 tuple->file_path = g_path_get_dirname(fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
230 sexypsf_freepsfinfo(tmp);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
231 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
232
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
233 return tuple;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
234 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
235
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
236 static gchar *get_title_psf(gchar *fn) {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
237 gchar *title = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
238 TitleInput *tinput = get_tuple_psf(fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
239
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
240 if (tinput != NULL) {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
241 title = xmms_get_titlestring(xmms_get_gentitle_format(),
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
242 tinput);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
243 bmp_title_input_free(tinput);
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 else
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
246 title = g_path_get_basename(fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
247
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
248 return title;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
249 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
250
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
251 gchar *sexypsf_fmts[] = { "psf", "minipsf", NULL };
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
252
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
253 InputPlugin sexypsf_ip =
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
254 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
255 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
256 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
257 "PSF Audio Plugin",
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
258 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
259 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
260 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
261 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
262 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
263 sexypsf_xmms_play,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
264 sexypsf_xmms_stop,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
265 sexypsf_xmms_pause,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
266 sexypsf_xmms_seek,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
267 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
268 sexypsf_xmms_gettime,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
269 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
270 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
271 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
272 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
273 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
274 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
275 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
276 sexypsf_xmms_getsonginfo,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
277 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
278 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
279 get_tuple_psf,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
280 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
281 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
282 is_our_fd,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
283 sexypsf_fmts,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
284 };
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
285
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
286 InputPlugin *sexypsf_iplist[] = { &sexypsf_ip, NULL };
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
287
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
288 DECLARE_PLUGIN(sexypsf, NULL, NULL, sexypsf_iplist, NULL, NULL, NULL, NULL);