annotate src/sexypsf/plugin.c @ 1447:195b5657303e

updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
author Giacomo Lozito <james@develia.org>
date Fri, 10 Aug 2007 22:00:07 +0200
parents 6b1f888a4c52
children db616ccdd40c
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"
1419
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
21 #include "audacious/main.h"
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
22 #include "audacious/tuple.h"
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
23 #include "audacious/tuple_formatter.h"
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
24 #include "audacious/util.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
25 #include "audacious/vfs.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
26 #include <stdio.h>
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
27 #include <stdlib.h>
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
28 #include <string.h>
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
29 #include <unistd.h>
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
30 #include "driver.h"
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
31
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
32 static volatile int seek = 0;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
33 static volatile gboolean playing = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
34 static volatile gboolean paused = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
35 static volatile gboolean stop = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
36 static volatile gboolean nextsong = 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 extern InputPlugin sexypsf_ip;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
39 static gboolean audio_error = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
40
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
41 static PSFINFO *PSFInfo = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
42 static gchar *fnsave = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
43 static GThread *dethread = NULL;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
44 static InputPlayback *playback = NULL;
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 gchar *get_title_psf(gchar *fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
47
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
48 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
49 gchar magic[4];
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
50 vfs_fread(magic, 1, 4, file);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
51
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
52 // only allow PSF1 for now
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
53 if (!memcmp(magic, "PSF\x01", 4))
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
54 return 1;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
55 return 0;
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
58 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
59 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
60 const int mask = ~((((16 / 8) * 2)) - 1);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
61
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
62 while (count > 0)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
63 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
64 int t = playback->output->buffer_free() & mask;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
65 if (t > count)
1205
c39a61e6a276 Fine-tune fadeout
mf0102 <0102@gmx.at>
parents: 1204
diff changeset
66 produce_audio(playback->output->written_time(),
c39a61e6a276 Fine-tune fadeout
mf0102 <0102@gmx.at>
parents: 1204
diff changeset
67 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
68 else
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
69 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
70 if (t)
1205
c39a61e6a276 Fine-tune fadeout
mf0102 <0102@gmx.at>
parents: 1204
diff changeset
71 produce_audio(playback->output->written_time(),
c39a61e6a276 Fine-tune fadeout
mf0102 <0102@gmx.at>
parents: 1204
diff changeset
72 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
73 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
74 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
75 count -= t;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
76 buffer += t;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
77 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
78 if (seek)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
79 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
80 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
81 {
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
82 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
83 seek = 0;
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
84 }
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
85 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
86 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
87 sexypsf_stop();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
88 return;
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 if (stop)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
92 sexypsf_stop();
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
95 static gpointer sexypsf_playloop(gpointer arg)
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 while (TRUE)
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 sexypsf_execute();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
100
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
101 /* 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
102
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
103 playback->output->buffer_free();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
104 playback->output->buffer_free();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
105
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
106 if (stop)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
107 break;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
108
1204
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
109 if (seek)
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
110 {
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
111 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
112 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
113 break;
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
114 sexypsf_seek(seek);
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
115 seek = 0;
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
116 continue;
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
117 }
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
118
1205
c39a61e6a276 Fine-tune fadeout
mf0102 <0102@gmx.at>
parents: 1204
diff changeset
119 // timeout at the end of a file
c39a61e6a276 Fine-tune fadeout
mf0102 <0102@gmx.at>
parents: 1204
diff changeset
120 sleep(4);
1204
e9f10dac2f63 Fixed bug (no fadeout was applied at the end of a file)
mf0102 <0102@gmx.at>
parents: 1203
diff changeset
121 break;
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
122 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
123
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
124 playback->output->close_audio();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
125 if (!(stop)) nextsong = TRUE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
126 g_thread_exit(NULL);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
127 return NULL;
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
130 static void sexypsf_xmms_play(InputPlayback *data)
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 if (playing)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
133 return;
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 playback = data;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
136 nextsong = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
137 paused = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
138
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
139 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
140 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
141 audio_error = TRUE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
142 return;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
143 }
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 fnsave = malloc(strlen(data->filename)+1);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
146 strcpy(fnsave, data->filename);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
147 if(!(PSFInfo=sexypsf_load(data->filename)))
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 playback->output->close_audio();
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
150 nextsong = 1;
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 else
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
153 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
154 stop = seek = 0;
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 gchar *name = get_title_psf(data->filename);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
157 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
158 g_free(name);
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 playing = 1;
1353
b5705eea23d9 sexypsf: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1205
diff changeset
161 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
162 data->set_pb_ready(data);
1353
b5705eea23d9 sexypsf: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1205
diff changeset
163 sexypsf_playloop(NULL);
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
164 }
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
167 static void sexypsf_xmms_stop(InputPlayback * playback)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
168 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
169 if (!playing) return;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
170
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
171 if (paused)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
172 playback->output->pause(0);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
173 paused = FALSE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
174
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
175 stop = TRUE;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
176 g_thread_join(dethread);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
177 playing = FALSE;
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 if (fnsave)
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 free(fnsave);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
182 fnsave = 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 sexypsf_freepsfinfo(PSFInfo);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
185 PSFInfo = NULL;
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
188 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
189 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
190 if (!playing) return;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
191 playback->output->pause(p);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
192 paused = p;
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
195 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
196 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
197 if (!playing) return;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
198 seek = time * 1000;
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
201 static int sexypsf_xmms_gettime(InputPlayback *playback)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
202 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
203 if (audio_error)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
204 return -2;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
205 if (nextsong)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
206 return -1;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
207 if (!playing)
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
208 return 0;
1205
c39a61e6a276 Fine-tune fadeout
mf0102 <0102@gmx.at>
parents: 1204
diff changeset
209
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
210 return playback->output->output_time();
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
213 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
214 {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
215 PSFINFO *tmp;
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 if((tmp = sexypsf_getpsfinfo(fn))) {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
218 *length = tmp->length;
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
219 *title = get_title_psf(fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
220 sexypsf_freepsfinfo(tmp);
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 }
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
223
1419
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
224 static Tuple *get_tuple_psf(gchar *fn) {
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
225 Tuple *tuple = NULL;
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
226 PSFINFO *tmp = sexypsf_getpsfinfo(fn);
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
227
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
228 if (tmp->length) {
1431
6b1f888a4c52 Use tuple_new_from_filename in more plugins.
Tony Vroon <chainsaw@gentoo.org>
parents: 1419
diff changeset
229 tuple = tuple_new_from_filename(fn);
1419
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
230 tuple_associate_int(tuple, "length", tmp->length);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
231 tuple_associate_string(tuple, "artist", tmp->artist);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
232 tuple_associate_string(tuple, "album", tmp->game);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
233 tuple_associate_string(tuple, "game", tmp->game);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
234 tuple_associate_string(tuple, "title", tmp->title);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
235 tuple_associate_string(tuple, "genre", tmp->genre);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
236 tuple_associate_string(tuple, "copyright", tmp->copyright);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
237 tuple_associate_string(tuple, "quality", "sequenced");
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
238 tuple_associate_string(tuple, "codec", "PlayStation Audio");
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
239 tuple_associate_string(tuple, "console", "PlayStation");
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
240 tuple_associate_string(tuple, "dumper", tmp->psfby);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
241 tuple_associate_string(tuple, "comment", tmp->comment);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
242
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
243 sexypsf_freepsfinfo(tmp);
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 return tuple;
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
249 static gchar *get_title_psf(gchar *fn) {
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
250 gchar *title = NULL;
1419
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
251 Tuple *tuple = get_tuple_psf(fn);
1203
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
252
1419
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
253 if (tuple != NULL) {
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
254 title = tuple_formatter_process_string(tuple, cfg.gentitle_format);
de310b4826de sexypsf: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
255 mowgli_object_unref(tuple);
1203
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 else
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
258 title = g_path_get_basename(fn);
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 return title;
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
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
263 gchar *sexypsf_fmts[] = { "psf", "minipsf", NULL };
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
264
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
265 InputPlugin sexypsf_ip =
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
266 {
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 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
269 "PSF Audio Plugin",
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 sexypsf_xmms_play,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
276 sexypsf_xmms_stop,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
277 sexypsf_xmms_pause,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
278 sexypsf_xmms_seek,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
279 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
280 sexypsf_xmms_gettime,
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 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
283 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
284 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
285 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
286 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
287 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
288 sexypsf_xmms_getsonginfo,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
289 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
290 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
291 get_tuple_psf,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
292 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
293 NULL,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
294 is_our_fd,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
295 sexypsf_fmts,
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
296 };
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
297
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
298 InputPlugin *sexypsf_iplist[] = { &sexypsf_ip, NULL };
6eef4486e481 Fixed hangs when outputting to FileWriter and improved readability in
michi@tux.homenetwork
parents:
diff changeset
299
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1353
diff changeset
300 DECLARE_PLUGIN(sexypsf, NULL, NULL, sexypsf_iplist, NULL, NULL, NULL, NULL, NULL);