Mercurial > audlegacy
annotate src/audacious/input.c @ 3251:f02623377013
goodbye widgets directory
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Sun, 05 Aug 2007 16:43:53 +0200 |
parents | 95cfda3878da |
children | f985357757e0 |
rev | line source |
---|---|
2313 | 1 /* Audacious - Cross-platform multimedia player |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
2 * Copyright (C) 2005-2007 Audacious development team |
2313 | 3 * |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3110
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
2313 | 13 * |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3110
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
2313 | 24 */ |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 # include "config.h" | |
28 #endif | |
29 | |
30 #include <glib.h> | |
31 #include <glib/gi18n.h> | |
32 #include <gtk/gtk.h> | |
33 #include <string.h> | |
34 | |
35 #include "fft.h" | |
36 #include "input.h" | |
37 #include "main.h" | |
38 #include "output.h" | |
39 #include "playback.h" | |
40 #include "pluginenum.h" | |
2420 | 41 #include "strings.h" |
2313 | 42 #include "titlestring.h" |
2420 | 43 #include "ui_main.h" |
44 #include "util.h" | |
45 #include "visualization.h" | |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
46 #include "ui_skinned_playstatus.h" |
2505 | 47 #include "hook.h" |
2313 | 48 |
2347
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
49 #include "vfs.h" |
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
50 #include "vfs_buffer.h" |
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
51 #include "vfs_buffered_file.h" |
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
52 |
2313 | 53 G_LOCK_DEFINE_STATIC(vis_mutex); |
54 | |
55 struct _VisNode { | |
56 gint time; | |
57 gint nch; | |
58 gint length; /* number of samples per channel */ | |
59 gint16 data[2][512]; | |
60 }; | |
61 | |
62 typedef struct _VisNode VisNode; | |
63 | |
64 | |
65 InputPluginData ip_data = { | |
66 NULL, | |
67 NULL, | |
68 FALSE, | |
69 FALSE, | |
70 FALSE, | |
71 FALSE, | |
72 NULL | |
73 }; | |
74 | |
75 static GList *vis_list = NULL; | |
76 | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
77 InputPlayback * |
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
78 get_current_input_playback(void) |
2313 | 79 { |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
80 return ip_data.current_input_playback; |
2313 | 81 } |
82 | |
83 void | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
84 set_current_input_playback(InputPlayback * ip) |
2313 | 85 { |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
86 ip_data.current_input_playback = ip; |
2313 | 87 } |
88 | |
89 GList * | |
90 get_input_list(void) | |
91 { | |
92 return ip_data.input_list; | |
93 } | |
94 | |
95 | |
96 gboolean | |
97 input_is_enabled(const gchar * filename) | |
98 { | |
99 gchar *basename = g_path_get_basename(filename); | |
100 gint enabled; | |
101 | |
102 enabled = GPOINTER_TO_INT(g_hash_table_lookup(plugin_matrix, basename)); | |
103 g_free(basename); | |
104 | |
105 return enabled; | |
106 } | |
107 | |
108 static void | |
109 disabled_iplugins_foreach_func(const gchar * name, | |
110 gboolean enabled, | |
111 GString * list) | |
112 { | |
113 g_return_if_fail(list != NULL); | |
114 | |
115 if (enabled) | |
116 return; | |
117 | |
118 if (list->len > 0) | |
119 g_string_append(list, ":"); | |
120 | |
121 g_string_append(list, name); | |
122 } | |
123 | |
124 gchar * | |
125 input_stringify_disabled_list(void) | |
126 { | |
127 GString *disabled_list; | |
128 | |
129 disabled_list = g_string_new(""); | |
130 g_hash_table_foreach(plugin_matrix, | |
131 (GHFunc) disabled_iplugins_foreach_func, | |
132 disabled_list); | |
133 | |
134 return g_string_free(disabled_list, FALSE); | |
135 } | |
136 | |
137 void | |
138 free_vis_data(void) | |
139 { | |
140 G_LOCK(vis_mutex); | |
141 g_list_foreach(vis_list, (GFunc) g_free, NULL); | |
142 g_list_free(vis_list); | |
143 vis_list = NULL; | |
144 G_UNLOCK(vis_mutex); | |
145 } | |
146 | |
147 static void | |
148 convert_to_s16_ne(AFormat fmt, gpointer ptr, gint16 * left, | |
149 gint16 * right, gint nch, gint max) | |
150 { | |
151 gint16 *ptr16; | |
152 guint16 *ptru16; | |
153 guint8 *ptru8; | |
154 gint i; | |
155 | |
156 switch (fmt) { | |
157 case FMT_U8: | |
158 ptru8 = ptr; | |
159 if (nch == 1) | |
160 for (i = 0; i < max; i++) | |
161 left[i] = ((*ptru8++) ^ 128) << 8; | |
162 else | |
163 for (i = 0; i < max; i++) { | |
164 left[i] = ((*ptru8++) ^ 128) << 8; | |
165 right[i] = ((*ptru8++) ^ 128) << 8; | |
166 } | |
167 break; | |
168 case FMT_S8: | |
169 ptru8 = ptr; | |
170 if (nch == 1) | |
171 for (i = 0; i < max; i++) | |
172 left[i] = (*ptru8++) << 8; | |
173 else | |
174 for (i = 0; i < max; i++) { | |
175 left[i] = (*ptru8++) << 8; | |
176 right[i] = (*ptru8++) << 8; | |
177 } | |
178 break; | |
179 case FMT_U16_LE: | |
180 ptru16 = ptr; | |
181 if (nch == 1) | |
182 for (i = 0; i < max; i++, ptru16++) | |
183 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
184 else | |
185 for (i = 0; i < max; i++) { | |
186 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
187 ptru16++; | |
188 right[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
189 ptru16++; | |
190 } | |
191 break; | |
192 case FMT_U16_BE: | |
193 ptru16 = ptr; | |
194 if (nch == 1) | |
195 for (i = 0; i < max; i++, ptru16++) | |
196 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
197 else | |
198 for (i = 0; i < max; i++) { | |
199 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
200 ptru16++; | |
201 right[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
202 ptru16++; | |
203 } | |
204 break; | |
205 case FMT_U16_NE: | |
206 ptru16 = ptr; | |
207 if (nch == 1) | |
208 for (i = 0; i < max; i++) | |
209 left[i] = (*ptru16++) ^ 32768; | |
210 else | |
211 for (i = 0; i < max; i++) { | |
212 left[i] = (*ptru16++) ^ 32768; | |
213 right[i] = (*ptru16++) ^ 32768; | |
214 } | |
215 break; | |
216 case FMT_S16_LE: | |
217 ptr16 = ptr; | |
218 if (nch == 1) | |
219 for (i = 0; i < max; i++, ptr16++) | |
220 left[i] = GINT16_FROM_LE(*ptr16); | |
221 else | |
222 for (i = 0; i < max; i++) { | |
223 left[i] = GINT16_FROM_LE(*ptr16); | |
224 ptr16++; | |
225 right[i] = GINT16_FROM_LE(*ptr16); | |
226 ptr16++; | |
227 } | |
228 break; | |
229 case FMT_S16_BE: | |
230 ptr16 = ptr; | |
231 if (nch == 1) | |
232 for (i = 0; i < max; i++, ptr16++) | |
233 left[i] = GINT16_FROM_BE(*ptr16); | |
234 else | |
235 for (i = 0; i < max; i++) { | |
236 left[i] = GINT16_FROM_BE(*ptr16); | |
237 ptr16++; | |
238 right[i] = GINT16_FROM_BE(*ptr16); | |
239 ptr16++; | |
240 } | |
241 break; | |
242 case FMT_S16_NE: | |
243 ptr16 = ptr; | |
244 if (nch == 1) | |
245 for (i = 0; i < max; i++) | |
246 left[i] = (*ptr16++); | |
247 else | |
248 for (i = 0; i < max; i++) { | |
249 left[i] = (*ptr16++); | |
250 right[i] = (*ptr16++); | |
251 } | |
252 break; | |
253 } | |
254 } | |
255 | |
256 InputVisType | |
257 input_get_vis_type() | |
258 { | |
259 return INPUT_VIS_OFF; | |
260 } | |
261 | |
262 void | |
263 input_add_vis_pcm(gint time, AFormat fmt, gint nch, gint length, gpointer ptr) | |
264 { | |
265 VisNode *vis_node; | |
266 gint max; | |
267 | |
268 max = length / nch; | |
269 if (fmt == FMT_U16_LE || fmt == FMT_U16_BE || fmt == FMT_U16_NE || | |
270 fmt == FMT_S16_LE || fmt == FMT_S16_BE || fmt == FMT_S16_NE) | |
271 max /= 2; | |
272 max = CLAMP(max, 0, 512); | |
273 | |
274 vis_node = g_new0(VisNode, 1); | |
275 vis_node->time = time; | |
276 vis_node->nch = nch; | |
277 vis_node->length = max; | |
278 convert_to_s16_ne(fmt, ptr, vis_node->data[0], vis_node->data[1], nch, | |
279 max); | |
280 | |
281 G_LOCK(vis_mutex); | |
282 vis_list = g_list_append(vis_list, vis_node); | |
283 G_UNLOCK(vis_mutex); | |
284 } | |
285 | |
286 void | |
287 input_dont_show_warning(GtkObject * object, gpointer user_data) | |
288 { | |
289 *((gboolean *) user_data) = | |
290 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object)); | |
291 } | |
292 | |
3133
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
293 static time_t |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
294 input_get_mtime(const gchar *filename) |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
295 { |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
296 struct stat buf; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
297 gint rv; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
298 gchar *realfn = NULL; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
299 |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
300 /* stat() does not accept file:// --yaz */ |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
301 realfn = g_filename_from_uri(filename, NULL, NULL); |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
302 rv = stat(realfn ? realfn : filename, &buf); |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
303 g_free(realfn); realfn = NULL; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
304 |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
305 if (rv == 0) { |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
306 return buf.st_mtime; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
307 } else { |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
308 return 0; //error |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
309 } |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
310 } |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
311 |
2313 | 312 /* |
313 * input_check_file() | |
314 * | |
315 * Inputs: | |
316 * filename to check recursively against input plugins | |
317 * whether or not to show an error | |
318 * | |
319 * Outputs: | |
320 * pointer to input plugin which can handle this file | |
321 * otherwise, NULL | |
322 * | |
323 * (the previous code returned a boolean of whether or not we can | |
324 * play the file... even WORSE for performance) | |
325 * | |
326 * Side Effects: | |
327 * various input plugins open the file and probe it | |
328 * -- this can have very ugly effects performance wise on streams | |
329 * | |
330 * --nenolod, Dec 31 2005 | |
331 * | |
332 * Rewritten to use NewVFS probing, semantics are still basically the same. | |
333 * | |
334 * --nenolod, Dec 5 2006 | |
335 * | |
336 * Adapted to use the NewVFS extension probing system if enabled. | |
337 * | |
338 * --nenolod, Dec 12 2006 | |
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
339 * |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
340 * Adapted to use the mimetype system. |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
341 * |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
342 * --nenolod, Jul 9 2007 |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
343 * |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
344 * Adapted to return ProbeResult structure. |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
345 * |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
346 * --nenolod, Jul 20 2007 |
2313 | 347 */ |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
348 ProbeResult * |
2313 | 349 input_check_file(const gchar * filename, gboolean show_warning) |
350 { | |
351 VFSFile *fd; | |
352 GList *node; | |
353 InputPlugin *ip; | |
354 gchar *filename_proxy; | |
355 gint ret = 1; | |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
356 gchar *ext, *tmp, *tmp_uri; |
2313 | 357 gboolean use_ext_filter; |
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
358 gchar *mimetype; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
359 ProbeResult *pr = NULL; |
2313 | 360 |
361 filename_proxy = g_strdup(filename); | |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
362 |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
363 /* Some URIs will end in ?<subsong> to determine the subsong requested. */ |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
364 tmp_uri = g_strdup(filename); |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
365 |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
366 tmp = strrchr(tmp_uri, '?'); |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
367 |
3144
2812140dba3f
Backed out changeset 4673533d7cc3
Cristi Magherusan <majeru@atheme-project.org>
parents:
3143
diff
changeset
|
368 if (tmp != NULL && g_ascii_isdigit(*(tmp + 1))) |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
369 *tmp = '\0'; |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
370 |
3145
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
371 /* CD-Audio uses cdda:// dummy paths, no filedescriptor handling for it */ |
3162
5161ced1bce2
exclude cue:// from regular scheme check. it is temporal too.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3145
diff
changeset
|
372 /* also cuesheet uses cue:// */ |
5161ced1bce2
exclude cue:// from regular scheme check. it is temporal too.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3145
diff
changeset
|
373 if (!g_strncasecmp(filename, "cdda://", 7) || |
5161ced1bce2
exclude cue:// from regular scheme check. it is temporal too.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3145
diff
changeset
|
374 !g_strncasecmp(filename, "cue://", 6)) { |
3145
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
375 for (node = get_input_list(); node != NULL; node = g_list_next(node)) |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
376 { |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
377 ip = INPUT_PLUGIN(node->data); |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
378 if (!ip || !input_is_enabled(ip->filename)) |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
379 continue; |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
380 if (ip->is_our_file != NULL) |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
381 ret = ip->is_our_file(filename_proxy); |
3169
b1964057a1a0
Hardcoded a dummy path to use with cdaudio-ng plugin
Calin Crisan ccrisan@gmail.com
parents:
3166
diff
changeset
|
382 else |
b1964057a1a0
Hardcoded a dummy path to use with cdaudio-ng plugin
Calin Crisan ccrisan@gmail.com
parents:
3166
diff
changeset
|
383 ret = 0; |
3145
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
384 if (ret > 0) |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
385 { |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
386 g_free(filename_proxy); |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
387 pr = g_new0(ProbeResult, 1); |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
388 pr->ip = ip; |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
389 return pr; |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
390 } |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
391 } |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
392 g_free(filename_proxy); |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
393 return NULL; |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
394 } |
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
395 |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
396 fd = vfs_buffered_file_new_from_uri(tmp_uri); |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
397 g_free(tmp_uri); |
2313 | 398 |
3110
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
399 if (!fd) { |
3125 | 400 printf("Unable to read from %s, giving up.\n", filename_proxy); |
3110
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
401 g_free(filename_proxy); |
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
402 return NULL; |
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
403 } |
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
404 |
2313 | 405 ext = strrchr(filename_proxy, '.') + 1; |
406 | |
2569 | 407 use_ext_filter = |
408 (fd != NULL && (!g_strncasecmp(filename, "/", 1) || | |
409 !g_strncasecmp(filename, "file://", 7))) ? TRUE : FALSE; | |
2313 | 410 |
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
411 mimetype = vfs_get_metadata(fd, "content-type"); |
3200
95cfda3878da
oops, using a C0X extension (break-from-if) probably isn't cool here.
William Pitcock <nenolod@atheme-project.org>
parents:
3198
diff
changeset
|
412 if ((ip = mime_get_plugin(mimetype)) != NULL && |
95cfda3878da
oops, using a C0X extension (break-from-if) probably isn't cool here.
William Pitcock <nenolod@atheme-project.org>
parents:
3198
diff
changeset
|
413 input_is_enabled(ip->filename) == TRUE) |
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
414 { |
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
415 if (ip->probe_for_tuple != NULL) |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
416 { |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
417 TitleInput *tuple = ip->probe_for_tuple(filename_proxy, fd); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
418 |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
419 if (tuple != NULL) |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
420 { |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
421 g_free(filename_proxy); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
422 vfs_fclose(fd); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
423 |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
424 pr = g_new0(ProbeResult, 1); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
425 pr->ip = ip; |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
426 pr->tuple = tuple; |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
427 pr->tuple->mtime = input_get_mtime(filename_proxy); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
428 |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
429 return pr; |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
430 } |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
431 } |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
432 else if (fd && ip->is_our_file_from_vfs != NULL) |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
433 { |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
434 ret = ip->is_our_file_from_vfs(filename_proxy, fd); |
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
435 |
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
436 if (ret > 0) |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
437 { |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
438 g_free(filename_proxy); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
439 vfs_fclose(fd); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
440 |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
441 pr = g_new0(ProbeResult, 1); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
442 pr->ip = ip; |
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
443 |
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
444 return pr; |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
445 } |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
446 } |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
447 else if (ip->is_our_file != NULL) |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
448 { |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
449 ret = ip->is_our_file(filename_proxy); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
450 |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
451 if (ret > 0) |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
452 { |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
453 g_free(filename_proxy); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
454 vfs_fclose(fd); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
455 |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
456 pr = g_new0(ProbeResult, 1); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
457 pr->ip = ip; |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
458 |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
459 return pr; |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
460 } |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
461 } |
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
462 } |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
463 |
2313 | 464 for (node = get_input_list(); node != NULL; node = g_list_next(node)) |
465 { | |
466 ip = INPUT_PLUGIN(node->data); | |
467 | |
468 if (!ip || !input_is_enabled(ip->filename)) | |
469 continue; | |
470 | |
2342
f140d0a27093
[svn] - use vfs_rewind() instead of vfs_fseek(fd, 0, seek_set) which was wrong
nenolod
parents:
2331
diff
changeset
|
471 vfs_rewind(fd); |
2313 | 472 |
2569 | 473 if (cfg.use_extension_probing == TRUE && ip->vfs_extensions != NULL && |
474 ext != NULL && ext != (gpointer) 0x1 && use_ext_filter == TRUE) | |
2313 | 475 { |
476 gint i; | |
477 gboolean is_our_ext = FALSE; | |
478 | |
479 for (i = 0; ip->vfs_extensions[i] != NULL; i++) | |
480 { | |
481 if (str_has_prefix_nocase(ext, ip->vfs_extensions[i])) | |
2331 | 482 { |
483 is_our_ext = TRUE; | |
484 break; | |
485 } | |
2313 | 486 } |
487 | |
488 /* not a plugin that supports this extension */ | |
489 if (is_our_ext == FALSE) | |
490 continue; | |
491 } | |
492 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
493 if (fd && ip->probe_for_tuple != NULL) |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
494 { |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
495 TitleInput *tuple = ip->probe_for_tuple(filename_proxy, fd); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
496 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
497 if (tuple != NULL) |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
498 { |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
499 g_free(filename_proxy); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
500 vfs_fclose(fd); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
501 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
502 pr = g_new0(ProbeResult, 1); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
503 pr->ip = ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
504 pr->tuple = tuple; |
3133
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
505 pr->tuple->mtime = input_get_mtime(filename_proxy); |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
506 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
507 return pr; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
508 } |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
509 } |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
510 else if (fd && ip->is_our_file_from_vfs != NULL) |
2313 | 511 { |
512 ret = ip->is_our_file_from_vfs(filename_proxy, fd); | |
513 | |
514 if (ret > 0) | |
515 { | |
516 g_free(filename_proxy); | |
517 vfs_fclose(fd); | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
518 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
519 pr = g_new0(ProbeResult, 1); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
520 pr->ip = ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
521 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
522 return pr; |
2313 | 523 } |
524 } | |
525 else if (ip->is_our_file != NULL) | |
526 { | |
527 ret = ip->is_our_file(filename_proxy); | |
528 | |
529 if (ret > 0) | |
530 { | |
531 g_free(filename_proxy); | |
532 vfs_fclose(fd); | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
533 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
534 pr = g_new0(ProbeResult, 1); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
535 pr->ip = ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
536 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
537 return pr; |
2313 | 538 } |
539 } | |
540 | |
2331 | 541 if (ret <= -1) |
542 break; | |
2313 | 543 } |
544 | |
545 g_free(filename_proxy); | |
546 | |
547 vfs_fclose(fd); | |
548 | |
549 return NULL; | |
550 } | |
551 | |
552 | |
553 void | |
554 input_set_eq(gint on, gfloat preamp, gfloat * bands) | |
555 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
556 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
557 |
2313 | 558 if (!ip_data.playing) |
559 return; | |
560 | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
561 if ((playback = get_current_input_playback()) == NULL) |
2313 | 562 return; |
563 | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
564 if (playback->plugin->set_eq) |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
565 playback->plugin->set_eq(on, preamp, bands); |
2313 | 566 } |
567 | |
568 void | |
569 input_get_song_info(const gchar * filename, gchar ** title, gint * length) | |
570 { | |
571 InputPlugin *ip = NULL; | |
572 BmpTitleInput *input; | |
573 gchar *tmp = NULL, *ext; | |
574 gchar *filename_proxy; | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
575 ProbeResult *pr; |
2313 | 576 |
577 g_return_if_fail(filename != NULL); | |
578 g_return_if_fail(title != NULL); | |
579 g_return_if_fail(length != NULL); | |
580 | |
581 filename_proxy = g_strdup(filename); | |
582 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
583 pr = input_check_file(filename_proxy, FALSE); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
584 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
585 if (!pr) |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
586 return; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
587 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
588 ip = pr->ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
589 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
590 g_free(pr); |
2313 | 591 |
2331 | 592 if (ip && ip->get_song_info) { |
2313 | 593 ip->get_song_info(filename_proxy, &tmp, length); |
594 *title = str_to_utf8(tmp); | |
595 g_free(tmp); | |
596 } | |
597 else { | |
598 input = bmp_title_input_new(); | |
599 | |
600 tmp = g_strdup(filename); | |
601 if ((ext = strrchr(tmp, '.'))) | |
602 *ext = '\0'; | |
603 | |
604 input->file_name = g_path_get_basename(tmp); | |
605 input->file_ext = ext ? ext + 1 : NULL; | |
606 input->file_path = g_path_get_dirname(tmp); | |
607 | |
608 if ((tmp = xmms_get_titlestring(xmms_get_gentitle_format(), input))) { | |
609 (*title) = str_to_utf8(tmp); | |
610 g_free(tmp); | |
611 } | |
612 else { | |
613 (*title) = filename_to_utf8(input->file_name); | |
614 } | |
615 | |
616 (*length) = -1; | |
617 | |
618 bmp_title_input_free(input); | |
619 input = NULL; | |
620 } | |
621 | |
622 g_free(filename_proxy); | |
623 } | |
624 | |
625 TitleInput * | |
626 input_get_song_tuple(const gchar * filename) | |
627 { | |
628 InputPlugin *ip = NULL; | |
629 TitleInput *input; | |
2394
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
630 gchar *ext = NULL; |
2313 | 631 gchar *filename_proxy; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
632 ProbeResult *pr; |
2313 | 633 |
634 if (filename == NULL) | |
2331 | 635 return NULL; |
2313 | 636 |
637 filename_proxy = g_strdup(filename); | |
638 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
639 pr = input_check_file(filename_proxy, FALSE); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
640 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
641 if (!pr) |
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
642 return NULL; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
643 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
644 ip = pr->ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
645 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
646 g_free(pr); |
2313 | 647 |
2331 | 648 if (ip && ip->get_song_tuple) |
2313 | 649 input = ip->get_song_tuple(filename_proxy); |
2331 | 650 else |
651 { | |
2313 | 652 input = bmp_title_input_new(); |
653 | |
2394
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
654 ext = strrchr(filename, '.'); |
2313 | 655 |
2331 | 656 input->track_name = NULL; |
657 input->length = -1; | |
658 input_get_song_info(filename, &input->track_name, &input->length); | |
2394
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
659 input->file_name = g_path_get_basename(filename); |
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
660 input->file_ext = ( ( ext != NULL ) ? g_strdup(ext + 1) : NULL ); |
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
661 input->file_path = g_path_get_dirname(filename); |
2313 | 662 } |
663 | |
2569 | 664 g_free(filename_proxy); |
2313 | 665 return input; |
666 } | |
667 | |
668 static void | |
669 input_general_file_info_box(const gchar * filename, InputPlugin * ip) | |
670 { | |
671 GtkWidget *window, *vbox; | |
672 GtkWidget *label, *filename_hbox, *filename_entry; | |
673 GtkWidget *bbox, *cancel; | |
674 | |
675 gchar *title, *fileinfo, *basename, *iplugin; | |
676 gchar *filename_utf8; | |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
677 gchar *realfn = NULL; |
2313 | 678 |
679 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
680 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
681 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | |
682 | |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
683 realfn = g_filename_from_uri(filename, NULL, NULL); |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
684 basename = g_path_get_basename(realfn ? realfn : filename); |
2313 | 685 fileinfo = filename_to_utf8(basename); |
686 title = g_strdup_printf(_("audacious: %s"), fileinfo); | |
687 | |
688 gtk_window_set_title(GTK_WINDOW(window), title); | |
689 | |
690 g_free(title); | |
691 g_free(fileinfo); | |
692 g_free(basename); | |
693 | |
694 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
695 | |
696 vbox = gtk_vbox_new(FALSE, 10); | |
697 gtk_container_add(GTK_CONTAINER(window), vbox); | |
698 | |
699 filename_hbox = gtk_hbox_new(FALSE, 5); | |
700 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); | |
701 | |
702 label = gtk_label_new(_("Filename:")); | |
703 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); | |
704 | |
705 filename_entry = gtk_entry_new(); | |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
706 filename_utf8 = filename_to_utf8(realfn ? realfn : filename); |
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
707 g_free(realfn); realfn = NULL; |
2313 | 708 |
709 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8); | |
710 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); | |
711 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); | |
712 | |
713 g_free(filename_utf8); | |
714 | |
715 if (ip) | |
716 if (ip->description) | |
717 iplugin = ip->description; | |
718 else | |
719 iplugin = ip->filename; | |
720 else | |
721 iplugin = _("No input plugin recognized this file"); | |
722 | |
723 title = g_strdup_printf(_("Input plugin: %s"), iplugin); | |
724 | |
725 label = gtk_label_new(title); | |
726 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
727 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
728 g_free(title); | |
729 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); | |
730 | |
731 bbox = gtk_hbutton_box_new(); | |
732 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
733 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
734 | |
735 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
736 g_signal_connect_swapped(G_OBJECT(cancel), "clicked", | |
737 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
738 GTK_OBJECT(window)); | |
739 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
740 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
741 | |
742 gtk_widget_show_all(window); | |
743 } | |
744 | |
745 void | |
746 input_file_info_box(const gchar * filename) | |
747 { | |
748 InputPlugin *ip; | |
749 gchar *filename_proxy; | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
750 ProbeResult *pr; |
2313 | 751 |
752 filename_proxy = g_strdup(filename); | |
753 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
754 pr = input_check_file(filename_proxy, FALSE); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
755 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
756 if (!pr) |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
757 return; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
758 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
759 ip = pr->ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
760 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
761 g_free(pr); |
2313 | 762 |
763 if (ip->file_info_box) | |
764 ip->file_info_box(filename_proxy); | |
765 else | |
766 input_general_file_info_box(filename, ip); | |
767 | |
768 input_general_file_info_box(filename, NULL); | |
769 g_free(filename_proxy); | |
770 } | |
771 | |
772 GList * | |
773 input_scan_dir(const gchar * path) | |
774 { | |
775 GList *node, *result = NULL; | |
776 InputPlugin *ip; | |
777 gchar *path_proxy; | |
778 | |
779 g_return_val_if_fail(path != NULL, NULL); | |
780 | |
781 if (*path == '/') | |
782 while (path[1] == '/') | |
783 path++; | |
784 | |
785 path_proxy = g_strdup(path); | |
786 | |
787 for (node = get_input_list(); node; node = g_list_next(node)) { | |
788 ip = INPUT_PLUGIN(node->data); | |
789 | |
790 if (!ip) | |
791 continue; | |
792 | |
793 if (!ip->scan_dir) | |
794 continue; | |
795 | |
796 if (!input_is_enabled(ip->filename)) | |
797 continue; | |
798 | |
799 if ((result = ip->scan_dir(path_proxy))) | |
800 break; | |
801 } | |
802 | |
803 g_free(path_proxy); | |
804 | |
805 return result; | |
806 } | |
807 | |
808 void | |
809 input_get_volume(gint * l, gint * r) | |
810 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
811 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
812 |
2313 | 813 *l = -1; |
814 *r = -1; | |
815 if (playback_get_playing()) { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
816 if ((playback = get_current_input_playback()) != NULL && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
817 playback->plugin->get_volume && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
818 playback->plugin->get_volume(l, r)) |
2313 | 819 return; |
820 } | |
821 output_get_volume(l, r); | |
822 } | |
823 | |
824 void | |
825 input_set_volume(gint l, gint r) | |
826 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
827 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
828 |
2505 | 829 gint h_vol[2]; |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
830 |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
831 h_vol[0] = l; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
832 h_vol[1] = r; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
833 hook_call("volume set", h_vol); |
2505 | 834 |
2569 | 835 if (playback_get_playing() && |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
836 (playback = get_current_input_playback()) != NULL && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
837 playback->plugin->set_volume && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
838 playback->plugin->set_volume(l, r)) |
2569 | 839 return; |
840 | |
2313 | 841 output_set_volume(l, r); |
842 } | |
843 | |
844 void | |
845 input_update_vis(gint time) | |
846 { | |
847 GList *node; | |
848 VisNode *vis = NULL, *visnext = NULL; | |
849 gboolean found = FALSE; | |
850 | |
851 G_LOCK(vis_mutex); | |
852 node = vis_list; | |
853 while (g_list_next(node) && !found) { | |
854 visnext = g_list_next(node)->data; | |
855 vis = node->data; | |
856 | |
857 if (vis->time >= time) | |
858 break; | |
859 | |
860 vis_list = g_list_delete_link(vis_list, node); | |
861 | |
862 if (visnext->time >= time) { | |
863 found = TRUE; | |
864 break; | |
865 } | |
866 g_free(vis); | |
867 node = vis_list; | |
868 } | |
869 G_UNLOCK(vis_mutex); | |
870 | |
871 if (found) { | |
872 vis_send_data(vis->data, vis->nch, vis->length); | |
873 g_free(vis); | |
874 } | |
875 else | |
876 vis_send_data(NULL, 0, 0); | |
877 } | |
878 | |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
879 /* FIXME: move this somewhere else */ |
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
880 void |
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
881 input_set_info_text(gchar *text) |
2313 | 882 { |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
883 gchar *title = g_strdup(text); |
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
884 event_queue("title change", title); |
2313 | 885 } |
886 | |
887 void | |
888 input_set_status_buffering(gboolean status) | |
889 { | |
890 if (!playback_get_playing()) | |
891 return; | |
892 | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
893 if (!get_current_input_playback()) |
2313 | 894 return; |
895 | |
896 ip_data.buffering = status; | |
897 | |
898 g_return_if_fail(mainwin_playstatus != NULL); | |
899 | |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
900 if (ip_data.buffering == TRUE && mainwin_playstatus != NULL && UI_SKINNED_PLAYSTATUS(mainwin_playstatus)->status == STATUS_STOP) |
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
901 UI_SKINNED_PLAYSTATUS(mainwin_playstatus)->status = STATUS_PLAY; |
2313 | 902 |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
903 ui_skinned_playstatus_set_buffering(mainwin_playstatus, ip_data.buffering); |
2313 | 904 } |
905 | |
906 void | |
907 input_about(gint index) | |
908 { | |
909 InputPlugin *ip; | |
910 | |
911 ip = g_list_nth(ip_data.input_list, index)->data; | |
912 if (ip && ip->about) | |
913 ip->about(); | |
914 } | |
915 | |
916 void | |
917 input_configure(gint index) | |
918 { | |
919 InputPlugin *ip; | |
920 | |
921 ip = g_list_nth(ip_data.input_list, index)->data; | |
922 if (ip && ip->configure) | |
923 ip->configure(); | |
924 } |