Mercurial > audlegacy
annotate src/audacious/input.c @ 3959:a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
- revise ext_hash to have lists of input plugins which associated with each extension.
- now input_check_file() makes use of ext_hash for file format probing to avoid full scan in the input list.
- make "detect file formats on demand" default.
- change tooltip text for on demand {detect|metadata}.
- move update request for playlist from idle function to event queue.
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Sat, 17 Nov 2007 17:07:46 +0900 |
parents | b747ad540903 |
children | 572258c68dfb |
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 | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
35 #include <mowgli.h> |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
36 |
2313 | 37 #include "fft.h" |
38 #include "input.h" | |
39 #include "main.h" | |
40 #include "output.h" | |
41 #include "playback.h" | |
42 #include "pluginenum.h" | |
2420 | 43 #include "strings.h" |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
44 #include "tuple.h" |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
45 #include "tuple_formatter.h" |
2420 | 46 #include "ui_main.h" |
47 #include "util.h" | |
48 #include "visualization.h" | |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
49 #include "ui_skinned_playstatus.h" |
2505 | 50 #include "hook.h" |
2313 | 51 |
2347
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
52 #include "vfs.h" |
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
53 #include "vfs_buffer.h" |
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
54 #include "vfs_buffered_file.h" |
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
55 |
2313 | 56 G_LOCK_DEFINE_STATIC(vis_mutex); |
57 | |
58 struct _VisNode { | |
59 gint time; | |
60 gint nch; | |
61 gint length; /* number of samples per channel */ | |
62 gint16 data[2][512]; | |
63 }; | |
64 | |
65 typedef struct _VisNode VisNode; | |
66 | |
67 | |
68 InputPluginData ip_data = { | |
69 NULL, | |
70 NULL, | |
71 FALSE, | |
72 FALSE, | |
73 FALSE, | |
74 FALSE, | |
75 NULL | |
76 }; | |
77 | |
78 static GList *vis_list = NULL; | |
79 | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
80 InputPlayback * |
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
81 get_current_input_playback(void) |
2313 | 82 { |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
83 return ip_data.current_input_playback; |
2313 | 84 } |
85 | |
86 void | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
87 set_current_input_playback(InputPlayback * ip) |
2313 | 88 { |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
89 ip_data.current_input_playback = ip; |
2313 | 90 } |
91 | |
92 GList * | |
93 get_input_list(void) | |
94 { | |
95 return ip_data.input_list; | |
96 } | |
97 | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
98 /* |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
99 * TODO: move this to utility as something like |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
100 * plugin_generate_list(GList *plugin_list, gboolean enabled_state) |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
101 * |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
102 * -nenolod |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
103 */ |
2313 | 104 gchar * |
105 input_stringify_disabled_list(void) | |
106 { | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
107 GList *node; |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
108 GString *list = g_string_new(""); |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
109 |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
110 MOWGLI_ITER_FOREACH(node, ip_data.input_list) |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
111 { |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
112 Plugin *plugin = (Plugin *) node->data; |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
113 gchar *filename = g_path_get_basename(plugin->filename); |
2313 | 114 |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
115 if (plugin->enabled) |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
116 continue; |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
117 |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
118 if (list->len > 0) |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
119 g_string_append(list, ":"); |
2313 | 120 |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
121 g_string_append(list, filename); |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
122 g_free(filename); |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
123 } |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
124 |
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
125 return g_string_free(list, FALSE); |
2313 | 126 } |
127 | |
128 void | |
129 free_vis_data(void) | |
130 { | |
3516
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
131 GList *iter; |
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
132 |
2313 | 133 G_LOCK(vis_mutex); |
3516
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
134 |
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
135 MOWGLI_ITER_FOREACH(iter, vis_list) |
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
136 g_slice_free(VisNode, iter->data); |
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
137 |
2313 | 138 g_list_free(vis_list); |
139 vis_list = NULL; | |
3516
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
140 |
2313 | 141 G_UNLOCK(vis_mutex); |
142 } | |
143 | |
144 static void | |
145 convert_to_s16_ne(AFormat fmt, gpointer ptr, gint16 * left, | |
146 gint16 * right, gint nch, gint max) | |
147 { | |
148 gint16 *ptr16; | |
149 guint16 *ptru16; | |
150 guint8 *ptru8; | |
151 gint i; | |
152 | |
153 switch (fmt) { | |
154 case FMT_U8: | |
155 ptru8 = ptr; | |
156 if (nch == 1) | |
157 for (i = 0; i < max; i++) | |
158 left[i] = ((*ptru8++) ^ 128) << 8; | |
159 else | |
160 for (i = 0; i < max; i++) { | |
161 left[i] = ((*ptru8++) ^ 128) << 8; | |
162 right[i] = ((*ptru8++) ^ 128) << 8; | |
163 } | |
164 break; | |
165 case FMT_S8: | |
166 ptru8 = ptr; | |
167 if (nch == 1) | |
168 for (i = 0; i < max; i++) | |
169 left[i] = (*ptru8++) << 8; | |
170 else | |
171 for (i = 0; i < max; i++) { | |
172 left[i] = (*ptru8++) << 8; | |
173 right[i] = (*ptru8++) << 8; | |
174 } | |
175 break; | |
176 case FMT_U16_LE: | |
177 ptru16 = ptr; | |
178 if (nch == 1) | |
179 for (i = 0; i < max; i++, ptru16++) | |
180 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
181 else | |
182 for (i = 0; i < max; i++) { | |
183 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
184 ptru16++; | |
185 right[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
186 ptru16++; | |
187 } | |
188 break; | |
189 case FMT_U16_BE: | |
190 ptru16 = ptr; | |
191 if (nch == 1) | |
192 for (i = 0; i < max; i++, ptru16++) | |
193 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
194 else | |
195 for (i = 0; i < max; i++) { | |
196 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
197 ptru16++; | |
198 right[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
199 ptru16++; | |
200 } | |
201 break; | |
202 case FMT_U16_NE: | |
203 ptru16 = ptr; | |
204 if (nch == 1) | |
205 for (i = 0; i < max; i++) | |
206 left[i] = (*ptru16++) ^ 32768; | |
207 else | |
208 for (i = 0; i < max; i++) { | |
209 left[i] = (*ptru16++) ^ 32768; | |
210 right[i] = (*ptru16++) ^ 32768; | |
211 } | |
212 break; | |
213 case FMT_S16_LE: | |
214 ptr16 = ptr; | |
215 if (nch == 1) | |
216 for (i = 0; i < max; i++, ptr16++) | |
217 left[i] = GINT16_FROM_LE(*ptr16); | |
218 else | |
219 for (i = 0; i < max; i++) { | |
220 left[i] = GINT16_FROM_LE(*ptr16); | |
221 ptr16++; | |
222 right[i] = GINT16_FROM_LE(*ptr16); | |
223 ptr16++; | |
224 } | |
225 break; | |
226 case FMT_S16_BE: | |
227 ptr16 = ptr; | |
228 if (nch == 1) | |
229 for (i = 0; i < max; i++, ptr16++) | |
230 left[i] = GINT16_FROM_BE(*ptr16); | |
231 else | |
232 for (i = 0; i < max; i++) { | |
233 left[i] = GINT16_FROM_BE(*ptr16); | |
234 ptr16++; | |
235 right[i] = GINT16_FROM_BE(*ptr16); | |
236 ptr16++; | |
237 } | |
238 break; | |
239 case FMT_S16_NE: | |
240 ptr16 = ptr; | |
241 if (nch == 1) | |
242 for (i = 0; i < max; i++) | |
243 left[i] = (*ptr16++); | |
244 else | |
245 for (i = 0; i < max; i++) { | |
246 left[i] = (*ptr16++); | |
247 right[i] = (*ptr16++); | |
248 } | |
249 break; | |
250 } | |
251 } | |
252 | |
253 InputVisType | |
254 input_get_vis_type() | |
255 { | |
256 return INPUT_VIS_OFF; | |
257 } | |
258 | |
259 void | |
260 input_add_vis_pcm(gint time, AFormat fmt, gint nch, gint length, gpointer ptr) | |
261 { | |
262 VisNode *vis_node; | |
263 gint max; | |
264 | |
265 max = length / nch; | |
266 if (fmt == FMT_U16_LE || fmt == FMT_U16_BE || fmt == FMT_U16_NE || | |
267 fmt == FMT_S16_LE || fmt == FMT_S16_BE || fmt == FMT_S16_NE) | |
268 max /= 2; | |
269 max = CLAMP(max, 0, 512); | |
270 | |
3516
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
271 vis_node = g_slice_new0(VisNode); |
2313 | 272 vis_node->time = time; |
273 vis_node->nch = nch; | |
274 vis_node->length = max; | |
275 convert_to_s16_ne(fmt, ptr, vis_node->data[0], vis_node->data[1], nch, | |
276 max); | |
277 | |
278 G_LOCK(vis_mutex); | |
279 vis_list = g_list_append(vis_list, vis_node); | |
280 G_UNLOCK(vis_mutex); | |
281 } | |
282 | |
283 void | |
284 input_dont_show_warning(GtkObject * object, gpointer user_data) | |
285 { | |
286 *((gboolean *) user_data) = | |
287 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object)); | |
288 } | |
289 | |
3133
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
290 static time_t |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
291 input_get_mtime(const gchar *filename) |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
292 { |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
293 struct stat buf; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
294 gint rv; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
295 gchar *realfn = NULL; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
296 |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
297 /* stat() does not accept file:// --yaz */ |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
298 realfn = g_filename_from_uri(filename, NULL, NULL); |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
299 rv = stat(realfn ? realfn : filename, &buf); |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
300 g_free(realfn); realfn = NULL; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
301 |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
302 if (rv == 0) { |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
303 return buf.st_mtime; |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
304 } else { |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
305 return 0; //error |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
306 } |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
307 } |
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
308 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
309 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
310 /* do actual probing. this function is called from input_check_file() */ |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
311 static ProbeResult * |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
312 input_do_check_file(InputPlugin *ip, VFSFile *fd, gchar *filename_proxy, gboolean loading) |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
313 { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
314 ProbeResult *pr = NULL; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
315 gint result = 0; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
316 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
317 g_return_val_if_fail(fd != NULL, NULL); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
318 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
319 vfs_rewind(fd); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
320 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
321 if (ip->probe_for_tuple && |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
322 cfg.use_pl_metadata && |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
323 (!loading || (loading && cfg.get_info_on_load)) ) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
324 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
325 Tuple *tuple = ip->probe_for_tuple(filename_proxy, fd); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
326 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
327 if (tuple != NULL) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
328 pr = g_new0(ProbeResult, 1); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
329 pr->ip = ip; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
330 pr->tuple = tuple; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
331 tuple_associate_int(pr->tuple, FIELD_MTIME, NULL, input_get_mtime(filename_proxy)); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
332 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
333 return pr; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
334 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
335 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
336 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
337 else if (ip->is_our_file_from_vfs != NULL) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
338 result = ip->is_our_file_from_vfs(filename_proxy, fd); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
339 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
340 if (result > 0) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
341 pr = g_new0(ProbeResult, 1); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
342 pr->ip = ip; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
343 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
344 return pr; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
345 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
346 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
347 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
348 else if (ip->is_our_file != NULL) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
349 result = ip->is_our_file(filename_proxy); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
350 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
351 if (result > 0) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
352 pr = g_new0(ProbeResult, 1); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
353 pr->ip = ip; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
354 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
355 return pr; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
356 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
357 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
358 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
359 return NULL; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
360 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
361 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
362 |
2313 | 363 /* |
364 * input_check_file() | |
365 * | |
366 * Inputs: | |
367 * filename to check recursively against input plugins | |
368 * whether or not to show an error | |
369 * | |
370 * Outputs: | |
371 * pointer to input plugin which can handle this file | |
372 * otherwise, NULL | |
373 * | |
374 * (the previous code returned a boolean of whether or not we can | |
375 * play the file... even WORSE for performance) | |
376 * | |
377 * Side Effects: | |
378 * various input plugins open the file and probe it | |
379 * -- this can have very ugly effects performance wise on streams | |
380 * | |
381 * --nenolod, Dec 31 2005 | |
382 * | |
383 * Rewritten to use NewVFS probing, semantics are still basically the same. | |
384 * | |
385 * --nenolod, Dec 5 2006 | |
386 * | |
387 * Adapted to use the NewVFS extension probing system if enabled. | |
388 * | |
389 * --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
|
390 * |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
391 * 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
|
392 * |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
393 * --nenolod, Jul 9 2007 |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
394 * |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
395 * Adapted to return ProbeResult structure. |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
396 * |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
397 * --nenolod, Jul 20 2007 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
398 * |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
399 * Make use of ext_hash to avoid full scan in input list. |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
400 * |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
401 * --yaz, Nov 16 2007 |
2313 | 402 */ |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
403 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
404 /* if loading is TRUE, tuple probing can be skipped as regards configuration. */ |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
405 ProbeResult * |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
406 input_check_file(const gchar *filename, gboolean loading) |
2313 | 407 { |
408 VFSFile *fd; | |
409 GList *node; | |
410 InputPlugin *ip; | |
411 gchar *filename_proxy; | |
412 gint ret = 1; | |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
413 gchar *ext, *tmp, *tmp_uri; |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
414 gboolean use_ext_filter = FALSE; |
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
415 gchar *mimetype; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
416 ProbeResult *pr = NULL; |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
417 GList **list_hdr = NULL; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
418 extern GHashTable *ext_hash; |
2313 | 419 |
420 filename_proxy = g_strdup(filename); | |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
421 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
422 |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
423 /* 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
|
424 tmp_uri = g_strdup(filename); |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
425 tmp = strrchr(tmp_uri, '?'); |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
426 |
3144
2812140dba3f
Backed out changeset 4673533d7cc3
Cristi Magherusan <majeru@atheme-project.org>
parents:
3143
diff
changeset
|
427 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
|
428 *tmp = '\0'; |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
429 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
430 |
3341
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
431 /* Check for plugins with custom URI:// strings */ |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
432 /* cue:// cdda:// tone:// tact:// */ |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
433 if ((ip = uri_get_plugin(filename)) != NULL && ip->enabled) |
3341
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
434 { |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
435 if (ip->is_our_file != NULL) |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
436 ret = ip->is_our_file(filename_proxy); |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
437 else |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
438 ret = 0; |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
439 if (ret > 0) |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
440 { |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
441 g_free(filename_proxy); |
3517
b747ad540903
proberesult = use g_new0() for now still
William Pitcock <nenolod@atheme.org>
parents:
3516
diff
changeset
|
442 pr = g_new0(ProbeResult, 1); |
3341
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
443 pr->ip = ip; |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
444 return pr; |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
445 } |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
446 g_free(filename_proxy); |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
447 return NULL; |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
448 } |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
449 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
450 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
451 // open the file with vfs sub-system |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
452 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
|
453 g_free(tmp_uri); |
2313 | 454 |
3110
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
455 if (!fd) { |
3125 | 456 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
|
457 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
|
458 return NULL; |
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
459 } |
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
460 |
2313 | 461 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
462 // apply mimetype check. note that stdio does not support mimetype check. |
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
463 mimetype = vfs_get_metadata(fd, "content-type"); |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
464 if ((ip = mime_get_plugin(mimetype)) != NULL && ip->enabled) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
465 while(1) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
466 if (!ip || !ip->enabled) |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
467 continue; |
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
468 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
469 pr = input_do_check_file(ip, fd, filename_proxy, loading); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
470 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
471 if(pr) { |
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
472 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
|
473 vfs_fclose(fd); |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
474 return pr; |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
475 } |
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
476 } |
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
477 } |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
478 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
479 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
480 // apply ext_hash check |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
481 if(cfg.use_extension_probing) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
482 use_ext_filter = |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
483 (fd != NULL && (!g_strncasecmp(filename, "/", 1) || |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
484 !g_strncasecmp(filename, "file://", 7))) ? TRUE : FALSE; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
485 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
486 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
487 if(use_ext_filter) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
488 gchar *base, *lext; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
489 gchar *tmp2 = g_filename_from_uri(filename_proxy, NULL, NULL); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
490 gchar *realfn = g_strdup(tmp2 ? tmp2 : filename_proxy); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
491 g_free(tmp2); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
492 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
493 base = g_path_get_basename(realfn); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
494 g_free(realfn); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
495 ext = strrchr(base, '.'); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
496 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
497 if(ext) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
498 lext = g_ascii_strdown(ext+1, -1); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
499 list_hdr = g_hash_table_lookup(ext_hash, lext); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
500 g_free(lext); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
501 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
502 g_free(base); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
503 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
504 if(list_hdr) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
505 for(node = *list_hdr; node != NULL; node = g_list_next(node)) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
506 ip = INPUT_PLUGIN(node->data); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
507 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
508 if (!ip || !ip->enabled) |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
509 continue; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
510 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
511 pr = input_do_check_file(ip, fd, filename_proxy, loading); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
512 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
513 if(pr) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
514 g_free(filename_proxy); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
515 vfs_fclose(fd); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
516 return pr; |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
517 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
518 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
519 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
520 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
521 return NULL; // no plugin found. |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
522 } |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
523 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
524 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
525 // do full scan when extension match isn't specified. |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
526 for (node = get_input_list(); node != NULL; node = g_list_next(node)) { |
2313 | 527 ip = INPUT_PLUGIN(node->data); |
528 | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
529 if (!ip || !ip->enabled) |
2313 | 530 continue; |
531 | |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
532 pr = input_do_check_file(ip, fd, filename_proxy, loading); |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
533 |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
534 if(pr) { |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
535 g_free(filename_proxy); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
536 vfs_fclose(fd); |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
537 return pr; |
2313 | 538 } |
539 } | |
540 | |
3959
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
541 |
a575c29cee05
- revive on-demand metadata retrieving. in the combination with "Detect file formats on demand", now audacious can load large directory in a few seconds.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3517
diff
changeset
|
542 // all probing failed. return NULL |
2313 | 543 g_free(filename_proxy); |
544 vfs_fclose(fd); | |
545 return NULL; | |
546 } | |
547 | |
548 | |
549 void | |
550 input_set_eq(gint on, gfloat preamp, gfloat * bands) | |
551 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
552 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
553 |
2313 | 554 if (!ip_data.playing) |
555 return; | |
556 | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
557 if ((playback = get_current_input_playback()) == NULL) |
2313 | 558 return; |
559 | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
560 if (playback->plugin->set_eq) |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
561 playback->plugin->set_eq(on, preamp, bands); |
2313 | 562 } |
563 | |
564 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
565 Tuple * |
2313 | 566 input_get_song_tuple(const gchar * filename) |
567 { | |
568 InputPlugin *ip = NULL; | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
569 Tuple *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
|
570 gchar *ext = NULL; |
2313 | 571 gchar *filename_proxy; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
572 ProbeResult *pr; |
2313 | 573 |
574 if (filename == NULL) | |
2331 | 575 return NULL; |
2313 | 576 |
577 filename_proxy = g_strdup(filename); | |
578 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
579 pr = input_check_file(filename_proxy, FALSE); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
580 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
581 if (!pr) |
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
582 return NULL; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
583 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
584 ip = pr->ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
585 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
586 g_free(pr); |
2313 | 587 |
2331 | 588 if (ip && ip->get_song_tuple) |
2313 | 589 input = ip->get_song_tuple(filename_proxy); |
2331 | 590 else |
591 { | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
592 gchar *tmp; |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
593 |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
594 input = tuple_new(); |
2313 | 595 |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
596 tmp = g_strdup(filename); |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
597 if ((ext = strrchr(tmp, '.'))) |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
598 *ext = '\0'; |
2313 | 599 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3343
diff
changeset
|
600 tuple_associate_string(input, FIELD_FILE_NAME, NULL, g_path_get_basename(tmp)); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
601 |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
602 if (ext) |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3343
diff
changeset
|
603 tuple_associate_string(input, FIELD_FILE_EXT, NULL, ext + 1); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
604 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3343
diff
changeset
|
605 tuple_associate_string(input, FIELD_FILE_PATH, NULL, g_path_get_dirname(tmp)); |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3343
diff
changeset
|
606 tuple_associate_int(input, FIELD_LENGTH, NULL, -1); |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
607 |
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
608 g_free(tmp); |
2313 | 609 } |
610 | |
2569 | 611 g_free(filename_proxy); |
2313 | 612 return input; |
613 } | |
614 | |
615 static void | |
616 input_general_file_info_box(const gchar * filename, InputPlugin * ip) | |
617 { | |
618 GtkWidget *window, *vbox; | |
619 GtkWidget *label, *filename_hbox, *filename_entry; | |
620 GtkWidget *bbox, *cancel; | |
621 | |
622 gchar *title, *fileinfo, *basename, *iplugin; | |
623 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
|
624 gchar *realfn = NULL; |
2313 | 625 |
626 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
627 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
628 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | |
629 | |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
630 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
|
631 basename = g_path_get_basename(realfn ? realfn : filename); |
2313 | 632 fileinfo = filename_to_utf8(basename); |
633 title = g_strdup_printf(_("audacious: %s"), fileinfo); | |
634 | |
635 gtk_window_set_title(GTK_WINDOW(window), title); | |
636 | |
637 g_free(title); | |
638 g_free(fileinfo); | |
639 g_free(basename); | |
640 | |
641 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
642 | |
643 vbox = gtk_vbox_new(FALSE, 10); | |
644 gtk_container_add(GTK_CONTAINER(window), vbox); | |
645 | |
646 filename_hbox = gtk_hbox_new(FALSE, 5); | |
647 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); | |
648 | |
649 label = gtk_label_new(_("Filename:")); | |
650 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); | |
651 | |
652 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
|
653 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
|
654 g_free(realfn); realfn = NULL; |
2313 | 655 |
656 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8); | |
657 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); | |
658 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); | |
659 | |
660 g_free(filename_utf8); | |
661 | |
662 if (ip) | |
663 if (ip->description) | |
664 iplugin = ip->description; | |
665 else | |
666 iplugin = ip->filename; | |
667 else | |
668 iplugin = _("No input plugin recognized this file"); | |
669 | |
670 title = g_strdup_printf(_("Input plugin: %s"), iplugin); | |
671 | |
672 label = gtk_label_new(title); | |
673 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
674 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
675 g_free(title); | |
676 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); | |
677 | |
678 bbox = gtk_hbutton_box_new(); | |
679 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
680 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
681 | |
682 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
683 g_signal_connect_swapped(G_OBJECT(cancel), "clicked", | |
684 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
685 GTK_OBJECT(window)); | |
686 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
687 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
688 | |
689 gtk_widget_show_all(window); | |
690 } | |
691 | |
692 void | |
693 input_file_info_box(const gchar * filename) | |
694 { | |
695 InputPlugin *ip; | |
696 gchar *filename_proxy; | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
697 ProbeResult *pr; |
2313 | 698 |
699 filename_proxy = g_strdup(filename); | |
700 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
701 pr = input_check_file(filename_proxy, FALSE); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
702 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
703 if (!pr) |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
704 return; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
705 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
706 ip = pr->ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
707 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
708 g_free(pr); |
2313 | 709 |
710 if (ip->file_info_box) | |
711 ip->file_info_box(filename_proxy); | |
712 else | |
713 input_general_file_info_box(filename, ip); | |
714 | |
715 input_general_file_info_box(filename, NULL); | |
716 g_free(filename_proxy); | |
717 } | |
718 | |
719 GList * | |
720 input_scan_dir(const gchar * path) | |
721 { | |
722 GList *node, *result = NULL; | |
723 InputPlugin *ip; | |
724 gchar *path_proxy; | |
725 | |
726 g_return_val_if_fail(path != NULL, NULL); | |
727 | |
728 if (*path == '/') | |
729 while (path[1] == '/') | |
730 path++; | |
731 | |
732 path_proxy = g_strdup(path); | |
733 | |
734 for (node = get_input_list(); node; node = g_list_next(node)) { | |
735 ip = INPUT_PLUGIN(node->data); | |
736 | |
737 if (!ip) | |
738 continue; | |
739 | |
740 if (!ip->scan_dir) | |
741 continue; | |
742 | |
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
743 if (!ip->enabled) |
2313 | 744 continue; |
745 | |
746 if ((result = ip->scan_dir(path_proxy))) | |
747 break; | |
748 } | |
749 | |
750 g_free(path_proxy); | |
751 | |
752 return result; | |
753 } | |
754 | |
755 void | |
756 input_get_volume(gint * l, gint * r) | |
757 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
758 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
759 |
2313 | 760 *l = -1; |
761 *r = -1; | |
762 if (playback_get_playing()) { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
763 if ((playback = get_current_input_playback()) != NULL && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
764 playback->plugin->get_volume && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
765 playback->plugin->get_volume(l, r)) |
2313 | 766 return; |
767 } | |
768 output_get_volume(l, r); | |
769 } | |
770 | |
771 void | |
772 input_set_volume(gint l, gint r) | |
773 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
774 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
775 |
2505 | 776 gint h_vol[2]; |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
777 |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
778 h_vol[0] = l; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
779 h_vol[1] = r; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
780 hook_call("volume set", h_vol); |
2505 | 781 |
2569 | 782 if (playback_get_playing() && |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
783 (playback = get_current_input_playback()) != NULL && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
784 playback->plugin->set_volume && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
785 playback->plugin->set_volume(l, r)) |
2569 | 786 return; |
787 | |
2313 | 788 output_set_volume(l, r); |
789 } | |
790 | |
791 void | |
792 input_update_vis(gint time) | |
793 { | |
794 GList *node; | |
795 VisNode *vis = NULL, *visnext = NULL; | |
796 gboolean found = FALSE; | |
797 | |
798 G_LOCK(vis_mutex); | |
799 node = vis_list; | |
800 while (g_list_next(node) && !found) { | |
801 visnext = g_list_next(node)->data; | |
802 vis = node->data; | |
803 | |
804 if (vis->time >= time) | |
805 break; | |
806 | |
807 vis_list = g_list_delete_link(vis_list, node); | |
808 | |
809 if (visnext->time >= time) { | |
810 found = TRUE; | |
811 break; | |
812 } | |
813 g_free(vis); | |
814 node = vis_list; | |
815 } | |
816 G_UNLOCK(vis_mutex); | |
817 | |
818 if (found) { | |
819 vis_send_data(vis->data, vis->nch, vis->length); | |
820 g_free(vis); | |
821 } | |
822 else | |
823 vis_send_data(NULL, 0, 0); | |
824 } | |
825 | |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
826 /* 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
|
827 void |
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
828 input_set_info_text(gchar *text) |
2313 | 829 { |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
830 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
|
831 event_queue("title change", title); |
2313 | 832 } |
833 | |
834 void | |
835 input_set_status_buffering(gboolean status) | |
836 { | |
837 if (!playback_get_playing()) | |
838 return; | |
839 | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
840 if (!get_current_input_playback()) |
2313 | 841 return; |
842 | |
843 ip_data.buffering = status; | |
844 | |
845 g_return_if_fail(mainwin_playstatus != NULL); | |
846 | |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
847 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
|
848 UI_SKINNED_PLAYSTATUS(mainwin_playstatus)->status = STATUS_PLAY; |
2313 | 849 |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
850 ui_skinned_playstatus_set_buffering(mainwin_playstatus, ip_data.buffering); |
2313 | 851 } |