annotate src/sexypsf/xmms.c @ 1201:2ae8155baef1

First cleanups
author michi@tux.homenetwork
date Mon, 02 Jul 2007 15:53:49 +0200
parents 3bcb772fa1b5
children 82ef51e8934a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /* sexyPSF - PSF1 player
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * Copyright (C) 2002-2004 xodnizel
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 * This library is free software; you can redistribute it and/or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 * modify it under the terms of the GNU Lesser General Public
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 * version 2.1 of the License, or (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 * This library is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 * Lesser General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 * You should have received a copy of the GNU Lesser General Public
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 * License along with this library; if not, write to the Free Software
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
17 */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 #include "audacious/output.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20 #include "audacious/plugin.h"
3
088092a52fea [svn] - move from (internal) libaudacious/ include path to audacious/ include path
nenolod
parents: 0
diff changeset
21 #include "audacious/titlestring.h"
088092a52fea [svn] - move from (internal) libaudacious/ include path to audacious/ include path
nenolod
parents: 0
diff changeset
22 #include "audacious/util.h"
088092a52fea [svn] - move from (internal) libaudacious/ include path to audacious/ include path
nenolod
parents: 0
diff changeset
23 #include "audacious/vfs.h"
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
24 #include <stdio.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
25 #include <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27 #include <unistd.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
28 #include "driver.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
29
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
30 #define CMD_SEEK 0x80000000
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
31 #define CMD_STOP 0x40000000
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
33 static volatile int seek_time = 0;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
34 static volatile int stop = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35 static volatile int playing=0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36 static volatile int nextsong=0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
37
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
38 extern InputPlugin sexypsf_ip;
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
39 static char *fnsave = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
40
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
41 static gchar *get_title_psf(gchar *fn);
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
42 static short paused;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
43 static GThread *dethread;
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
44 static PSFINFO *PSFInfo = NULL;
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
45 static InputPlayback *playback;
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
46
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
47 static int is_our_fd(gchar *filename, VFSFile *file) {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
48 gchar magic[4];
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
49 vfs_fread(magic, 1, 4, file);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
50
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
51 // only allow PSF1 for now
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
52 if (!memcmp(magic, "PSF\x01", 4))
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
53 return 1;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
54 return 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
55 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
56
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
57
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
58 void sexypsf_update(unsigned char *buffer, long count)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
59 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
60 const int mask = ~((((16 / 8) * 2)) - 1);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
61
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
62 while (count > 0)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
63 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
64 int t = playback->output->buffer_free() & mask;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
65 if (t > count)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
66 produce_audio(playback->output->written_time(), FMT_S16_NE, 2, count, buffer, NULL);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
67 else
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
68 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
69 if (t)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
70 produce_audio(playback->output->written_time(), FMT_S16_NE, 2, t, buffer, NULL);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
71 g_usleep((count-t)*1000*5/441/2);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
72 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
73 count -= t;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
74 buffer += t;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
75 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
76 if (seek_time)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
77 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
78 if(sexypsf_seek(seek_time))
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
79 playback->output->flush(seek_time);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
80 // negative time - must make a C time machine
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
81 else
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
82 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
83 sexypsf_stop();
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
84 return;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
85 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
86 seek_time = 0;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
87 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
88 if (stop)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
89 sexypsf_stop();
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
90 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
91
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
92 static gpointer sexypsf_playloop(gpointer arg)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
94 dofunky:
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
95
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
96 sexypsf_execute();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
97
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
98 /* we have reached the end of the song */
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
99
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
100 playback->output->buffer_free();
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
101 playback->output->buffer_free();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
102
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
103 while (!(stop))
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
104 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
105 if (seek_time)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
106 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
107 playback->output->flush(seek_time);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
108 if(!(PSFInfo=sexypsf_load(fnsave)))
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
109 break;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
110 sexypsf_seek(seek_time);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
111 seek_time = 0;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
112 goto dofunky;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
113 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
114 if (!playback->output->buffer_playing()) break;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
115 usleep(2000);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
116 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
117 playback->output->close_audio();
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
118 if(!(stop)) nextsong=1;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
119 g_thread_exit(NULL);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
120 return NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
121 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
122
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 372
diff changeset
123 static void sexypsf_xmms_play(InputPlayback *data)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
124 {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
125 char *fn = data->filename;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
126 if(playing)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
127 return;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
128 playback = data;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
129 nextsong=0;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
130 paused = 0;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
131 if(!playback->output->open_audio(FMT_S16_NE, 44100, 2))
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
132 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
133 puts("Error opening audio.");
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
134 return;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
135 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
136 fnsave=malloc(strlen(fn)+1);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
137 strcpy(fnsave,fn);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
138 if(!(PSFInfo=sexypsf_load(fn)))
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
139 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
140 playback->output->close_audio();
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
141 nextsong=1;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
142 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
143 else
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
144 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
145 stop = seek_time = 0;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
146
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
147 gchar *name = get_title_psf(fn);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
148 sexypsf_ip.set_info(name,PSFInfo->length,44100*2*2*8,44100,2);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
149 g_free(name);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
150
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
151 playing=1;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
152 dethread = g_thread_create((GThreadFunc)sexypsf_playloop,NULL,TRUE,NULL);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
153 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
154 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
155
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
156 static void sexypsf_xmms_stop(InputPlayback * playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
157 {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
158 if(!playing) return;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
159
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
160 if(paused)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
161 playback->output->pause(0);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
162 paused = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
163
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
164 stop = TRUE;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
165 g_thread_join(dethread);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
166 playing = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
167
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
168 if(fnsave)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
169 {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
170 free(fnsave);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
171 fnsave=NULL;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
172 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
173 sexypsf_freepsfinfo(PSFInfo);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
174 PSFInfo=NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
175 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
176
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
177 static void sexypsf_xmms_pause(InputPlayback * playback, short p)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
178 {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
179 if(!playing) return;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
180 playback->output->pause(p);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
181 paused = p;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
182 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
183
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 372
diff changeset
184 static void sexypsf_xmms_seek(InputPlayback * data, int time)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
185 {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
186 if(!playing) return;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
187 seek_time = time * 1000;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
188 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
189
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
190 static int sexypsf_xmms_gettime(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
191 {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
192 if(nextsong)
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
193 return(-1);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
194 if(!playing) return(0);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
195 return playback->output->output_time();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
196 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
197
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
198 static void sexypsf_xmms_getsonginfo(char *fn, char **title, int *length)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
199 {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
200 PSFINFO *tmp;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
201
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
202 if((tmp=sexypsf_getpsfinfo(fn))) {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
203 *length = tmp->length;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
204 *title = get_title_psf(fn);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
205 sexypsf_freepsfinfo(tmp);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
206 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
207 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
208
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
209 static TitleInput *get_tuple_psf(gchar *fn) {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
210 TitleInput *tuple = NULL;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
211 PSFINFO *tmp = sexypsf_getpsfinfo(fn);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
212
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
213 if (tmp->length) {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
214 tuple = bmp_title_input_new();
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
215 tuple->length = tmp->length;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
216 tuple->performer = g_strdup(tmp->artist);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
217 tuple->album_name = g_strdup(tmp->game);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
218 tuple->track_name = g_strdup(tmp->title);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
219 tuple->file_name = g_path_get_basename(fn);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
220 tuple->file_path = g_path_get_dirname(fn);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
221 sexypsf_freepsfinfo(tmp);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
222 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
223
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
224 return tuple;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
225 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
226
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
227 static gchar *get_title_psf(gchar *fn) {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
228 gchar *title;
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
229 TitleInput *tinput = get_tuple_psf(fn);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
230
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
231 if (tinput != NULL) {
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
232 title = xmms_get_titlestring(xmms_get_gentitle_format(),
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
233 tinput);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
234 bmp_title_input_free(tinput);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
235 }
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
236 else
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
237 title = g_path_get_basename(fn);
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
238
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
239 return title;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
240 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
241
372
a157306caf03 [svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents: 368
diff changeset
242 gchar *sexypsf_fmts[] = { "psf", "minipsf", NULL };
a157306caf03 [svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents: 368
diff changeset
243
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
244 InputPlugin sexypsf_ip =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
245 {
1201
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
246 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
247 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
248 "PSF Audio Plugin",
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
249 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
250 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
251 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
252 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
253 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
254 sexypsf_xmms_play,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
255 sexypsf_xmms_stop,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
256 sexypsf_xmms_pause,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
257 sexypsf_xmms_seek,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
258 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
259 sexypsf_xmms_gettime,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
260 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
261 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
262 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
263 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
264 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
265 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
266 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
267 sexypsf_xmms_getsonginfo,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
268 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
269 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
270 get_tuple_psf,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
271 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
272 NULL,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
273 is_our_fd,
2ae8155baef1 First cleanups
michi@tux.homenetwork
parents: 1090
diff changeset
274 sexypsf_fmts,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
275 };
1090
3bcb772fa1b5 [svn] - sexypsf: convert to plugin API v2
nenolod
parents: 561
diff changeset
276
3bcb772fa1b5 [svn] - sexypsf: convert to plugin API v2
nenolod
parents: 561
diff changeset
277 InputPlugin *sexypsf_iplist[] = { &sexypsf_ip, NULL };
3bcb772fa1b5 [svn] - sexypsf: convert to plugin API v2
nenolod
parents: 561
diff changeset
278
3bcb772fa1b5 [svn] - sexypsf: convert to plugin API v2
nenolod
parents: 561
diff changeset
279 DECLARE_PLUGIN(sexypsf, NULL, NULL, sexypsf_iplist, NULL, NULL, NULL, NULL);