Mercurial > audlegacy
annotate src/audacious/input.c @ 4166:983e6b3e72f3
More cleanups.
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Thu, 10 Jan 2008 06:43:58 -0600 |
parents | a2da130cdafa |
children | e8c79a8b9d9b |
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; | |
3977 | 79 static int volume_l = -1, volume_r = -1; |
2313 | 80 |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
81 InputPlayback * |
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
82 get_current_input_playback(void) |
2313 | 83 { |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
84 return ip_data.current_input_playback; |
2313 | 85 } |
86 | |
87 void | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
88 set_current_input_playback(InputPlayback * ip) |
2313 | 89 { |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
90 ip_data.current_input_playback = ip; |
2313 | 91 } |
92 | |
93 GList * | |
94 get_input_list(void) | |
95 { | |
96 return ip_data.input_list; | |
97 } | |
98 | |
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
|
99 /* |
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 * 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
|
101 * 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
|
102 * |
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 * -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
|
104 */ |
2313 | 105 gchar * |
106 input_stringify_disabled_list(void) | |
107 { | |
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
|
108 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
|
109 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
|
110 |
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 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
|
112 { |
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 Plugin *plugin = (Plugin *) node->data; |
4098
fe0f7a72facd
Fix memory leak in input_stringify_disabled_list() (Bugzilla #25)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4094
diff
changeset
|
114 gchar *filename; |
2313 | 115 |
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
|
116 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
|
117 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
|
118 |
4098
fe0f7a72facd
Fix memory leak in input_stringify_disabled_list() (Bugzilla #25)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4094
diff
changeset
|
119 filename = g_path_get_basename(plugin->filename); |
fe0f7a72facd
Fix memory leak in input_stringify_disabled_list() (Bugzilla #25)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
4094
diff
changeset
|
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 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
|
122 g_string_append(list, ":"); |
2313 | 123 |
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
|
124 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
|
125 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
|
126 } |
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
|
127 |
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
|
128 return g_string_free(list, FALSE); |
2313 | 129 } |
130 | |
131 void | |
132 free_vis_data(void) | |
133 { | |
3516
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
134 GList *iter; |
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
135 |
2313 | 136 G_LOCK(vis_mutex); |
3516
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
137 |
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
138 MOWGLI_ITER_FOREACH(iter, vis_list) |
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
139 g_slice_free(VisNode, iter->data); |
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
140 |
2313 | 141 g_list_free(vis_list); |
142 vis_list = NULL; | |
3516
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
143 |
2313 | 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 | |
3516
0970c745a497
Use GSlice for VisNode structs.
William Pitcock <nenolod@atheme.org>
parents:
3502
diff
changeset
|
274 vis_node = g_slice_new0(VisNode); |
2313 | 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 |
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
|
312 |
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 /* 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
|
314 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
|
315 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
|
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 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
|
318 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
|
319 |
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 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
|
321 |
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 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
|
323 |
3963
572258c68dfb
- for input plugins which provide probe_for_tuple only, now input_do_check_file() calls probe_for_tuple regardless of cfg.use_pl_metadata.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
324 /* some input plugins provide probe_for_tuple() only. */ |
572258c68dfb
- for input plugins which provide probe_for_tuple only, now input_do_check_file() calls probe_for_tuple regardless of cfg.use_pl_metadata.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
325 if ( (ip->probe_for_tuple && !ip->is_our_file_from_vfs && !ip->is_our_file) || |
3979
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
326 (ip->probe_for_tuple && ip->have_subtune == TRUE) || |
3963
572258c68dfb
- for input plugins which provide probe_for_tuple only, now input_do_check_file() calls probe_for_tuple regardless of cfg.use_pl_metadata.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3959
diff
changeset
|
327 (ip->probe_for_tuple && (cfg.use_pl_metadata && (!loading || (loading && cfg.get_info_on_load)))) ) { |
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
|
328 |
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 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
|
330 |
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 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
|
332 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
|
333 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
|
334 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
|
335 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
|
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 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
|
338 } |
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 |
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 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
|
342 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
|
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 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
|
345 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
|
346 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
|
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 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
|
349 } |
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 |
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 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
|
353 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
|
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 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
|
356 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
|
357 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
|
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 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
|
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 |
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
|
363 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
|
364 } |
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
|
365 |
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
|
366 |
2313 | 367 /* |
368 * input_check_file() | |
369 * | |
370 * Inputs: | |
371 * filename to check recursively against input plugins | |
372 * whether or not to show an error | |
373 * | |
374 * Outputs: | |
375 * pointer to input plugin which can handle this file | |
376 * otherwise, NULL | |
377 * | |
378 * (the previous code returned a boolean of whether or not we can | |
379 * play the file... even WORSE for performance) | |
380 * | |
381 * Side Effects: | |
382 * various input plugins open the file and probe it | |
383 * -- this can have very ugly effects performance wise on streams | |
384 * | |
385 * --nenolod, Dec 31 2005 | |
386 * | |
387 * Rewritten to use NewVFS probing, semantics are still basically the same. | |
388 * | |
389 * --nenolod, Dec 5 2006 | |
390 * | |
391 * Adapted to use the NewVFS extension probing system if enabled. | |
392 * | |
393 * --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
|
394 * |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
395 * 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
|
396 * |
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
397 * --nenolod, Jul 9 2007 |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
398 * |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
399 * Adapted to return ProbeResult structure. |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
400 * |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
401 * --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
|
402 * |
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 * 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
|
404 * |
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
|
405 * --yaz, Nov 16 2007 |
2313 | 406 */ |
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
|
407 |
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
|
408 /* 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
|
409 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
|
410 input_check_file(const gchar *filename, gboolean loading) |
2313 | 411 { |
412 VFSFile *fd; | |
413 GList *node; | |
414 InputPlugin *ip; | |
415 gchar *filename_proxy; | |
416 gint ret = 1; | |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
417 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
|
418 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
|
419 gchar *mimetype; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
420 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
|
421 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
|
422 extern GHashTable *ext_hash; |
2313 | 423 |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
424 /* 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
|
425 tmp_uri = g_strdup(filename); |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
426 tmp = strrchr(tmp_uri, '?'); |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
427 |
3979
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
428 if (tmp && g_ascii_isdigit(*(tmp + 1))) |
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
429 *tmp = '\0'; |
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
430 |
3979
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
431 filename_proxy = g_strdup(tmp_uri); |
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
432 g_free(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
|
433 |
3341
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
434 /* 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
|
435 /* cue:// cdda:// tone:// tact:// */ |
3979
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
436 if ((ip = uri_get_plugin(filename_proxy)) != NULL && ip->enabled) { |
3341
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
437 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
|
438 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
|
439 else |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
440 ret = 0; |
3979
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
441 if (ret > 0) { |
3341
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
442 g_free(filename_proxy); |
3517
b747ad540903
proberesult = use g_new0() for now still
William Pitcock <nenolod@atheme.org>
parents:
3516
diff
changeset
|
443 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
|
444 pr->ip = ip; |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
445 return pr; |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
446 } |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
447 g_free(filename_proxy); |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
448 return NULL; |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
449 } |
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
450 |
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
|
451 |
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
|
452 // open the file with vfs sub-system |
3979
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
453 fd = vfs_buffered_file_new_from_uri(filename_proxy); |
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 = |
3979
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
483 (fd && (!g_strncasecmp(filename_proxy, "/", 1) || |
67f01143e613
improve on-demand probing:
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3977
diff
changeset
|
484 !g_strncasecmp(filename_proxy, "file://", 7))) ? TRUE : FALSE; |
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
|
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 } |
4156
a2da130cdafa
If no plugins claim that they can support a file extension, try them all just to be sure. (Bugzilla #80)
Jack Kelly <weldingmaskman@hotmail.com>
parents:
4153
diff
changeset
|
519 |
a2da130cdafa
If no plugins claim that they can support a file extension, try them all just to be sure. (Bugzilla #80)
Jack Kelly <weldingmaskman@hotmail.com>
parents:
4153
diff
changeset
|
520 g_free(filename_proxy); |
a2da130cdafa
If no plugins claim that they can support a file extension, try them all just to be sure. (Bugzilla #80)
Jack Kelly <weldingmaskman@hotmail.com>
parents:
4153
diff
changeset
|
521 vfs_fclose(fd); |
a2da130cdafa
If no plugins claim that they can support a file extension, try them all just to be sure. (Bugzilla #80)
Jack Kelly <weldingmaskman@hotmail.com>
parents:
4153
diff
changeset
|
522 return NULL; // no plugin found. |
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
|
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 |
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 |
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
|
527 // 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
|
528 for (node = get_input_list(); node != NULL; node = g_list_next(node)) { |
2313 | 529 ip = INPUT_PLUGIN(node->data); |
530 | |
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
|
531 if (!ip || !ip->enabled) |
2313 | 532 continue; |
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 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
|
535 |
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
|
536 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
|
537 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
|
538 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
|
539 return pr; |
2313 | 540 } |
541 } | |
542 | |
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
|
543 |
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
|
544 // all probing failed. return NULL |
2313 | 545 g_free(filename_proxy); |
546 vfs_fclose(fd); | |
547 return NULL; | |
548 } | |
549 | |
550 | |
551 void | |
552 input_set_eq(gint on, gfloat preamp, gfloat * bands) | |
553 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
554 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
555 |
2313 | 556 if (!ip_data.playing) |
557 return; | |
558 | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
559 if ((playback = get_current_input_playback()) == NULL) |
2313 | 560 return; |
561 | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
562 if (playback->plugin->set_eq) |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
563 playback->plugin->set_eq(on, preamp, bands); |
2313 | 564 } |
565 | |
566 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
567 Tuple * |
2313 | 568 input_get_song_tuple(const gchar * filename) |
569 { | |
570 InputPlugin *ip = NULL; | |
4153 | 571 Tuple *input = NULL; |
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
|
572 gchar *ext = NULL; |
2313 | 573 gchar *filename_proxy; |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
574 ProbeResult *pr; |
2313 | 575 |
576 if (filename == NULL) | |
4089
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
577 return NULL; |
2313 | 578 |
579 filename_proxy = g_strdup(filename); | |
580 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
581 pr = input_check_file(filename_proxy, FALSE); |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
582 |
4089
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
583 if (!pr) { |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
584 g_free(filename_proxy); |
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
585 return NULL; |
4089
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
586 } |
3127
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_tuple) |
2313 | 593 input = ip->get_song_tuple(filename_proxy); |
2331 | 594 else |
595 { | |
4089
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
596 gchar *scratch; |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
597 |
4089
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
598 scratch = uri_to_display_basename(filename); |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
599 tuple_associate_string(input, FIELD_FILE_NAME, NULL, scratch); |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
600 g_free(scratch); |
2313 | 601 |
4089
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
602 scratch = uri_to_display_dirname(filename); |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
603 tuple_associate_string(input, FIELD_FILE_PATH, NULL, scratch); |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
604 g_free(scratch); |
2313 | 605 |
4089
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
606 ext = strrchr(filename, '.'); |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
607 if (ext != NULL) { |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
608 ++ext; |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
609 tuple_associate_string(input, FIELD_FILE_EXT, NULL, ext); |
9e24c8746d99
- introduce new API functions uri_to_display_basename() and uri_to_display_dirname(). each function derives utf8 encoded basename or dirname from given uri respectively.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
4029
diff
changeset
|
610 } |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
611 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3343
diff
changeset
|
612 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
|
613 |
2313 | 614 } |
615 | |
2569 | 616 g_free(filename_proxy); |
2313 | 617 return input; |
618 } | |
619 | |
620 static void | |
621 input_general_file_info_box(const gchar * filename, InputPlugin * ip) | |
622 { | |
623 GtkWidget *window, *vbox; | |
624 GtkWidget *label, *filename_hbox, *filename_entry; | |
625 GtkWidget *bbox, *cancel; | |
626 | |
627 gchar *title, *fileinfo, *basename, *iplugin; | |
628 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
|
629 gchar *realfn = NULL; |
2313 | 630 |
631 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
632 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
633 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | |
634 | |
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
635 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
|
636 basename = g_path_get_basename(realfn ? realfn : filename); |
2313 | 637 fileinfo = filename_to_utf8(basename); |
638 title = g_strdup_printf(_("audacious: %s"), fileinfo); | |
639 | |
640 gtk_window_set_title(GTK_WINDOW(window), title); | |
641 | |
642 g_free(title); | |
643 g_free(fileinfo); | |
644 g_free(basename); | |
645 | |
646 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
647 | |
648 vbox = gtk_vbox_new(FALSE, 10); | |
649 gtk_container_add(GTK_CONTAINER(window), vbox); | |
650 | |
651 filename_hbox = gtk_hbox_new(FALSE, 5); | |
652 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); | |
653 | |
654 label = gtk_label_new(_("Filename:")); | |
655 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); | |
656 | |
657 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
|
658 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
|
659 g_free(realfn); realfn = NULL; |
2313 | 660 |
661 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8); | |
662 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); | |
663 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); | |
664 | |
665 g_free(filename_utf8); | |
666 | |
667 if (ip) | |
668 if (ip->description) | |
669 iplugin = ip->description; | |
670 else | |
671 iplugin = ip->filename; | |
672 else | |
673 iplugin = _("No input plugin recognized this file"); | |
674 | |
675 title = g_strdup_printf(_("Input plugin: %s"), iplugin); | |
676 | |
677 label = gtk_label_new(title); | |
678 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
679 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
680 g_free(title); | |
681 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); | |
682 | |
683 bbox = gtk_hbutton_box_new(); | |
684 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
685 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
686 | |
687 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
688 g_signal_connect_swapped(G_OBJECT(cancel), "clicked", | |
689 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
690 GTK_OBJECT(window)); | |
691 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
692 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
693 | |
694 gtk_widget_show_all(window); | |
695 } | |
696 | |
697 void | |
698 input_file_info_box(const gchar * filename) | |
699 { | |
700 InputPlugin *ip; | |
701 gchar *filename_proxy; | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
702 ProbeResult *pr; |
2313 | 703 |
704 filename_proxy = g_strdup(filename); | |
705 | |
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
706 pr = input_check_file(filename_proxy, FALSE); |
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 if (!pr) |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
709 return; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
710 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
711 ip = pr->ip; |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
712 |
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
713 g_free(pr); |
2313 | 714 |
715 if (ip->file_info_box) | |
716 ip->file_info_box(filename_proxy); | |
717 else | |
718 input_general_file_info_box(filename, ip); | |
719 | |
720 input_general_file_info_box(filename, NULL); | |
721 g_free(filename_proxy); | |
722 } | |
723 | |
724 GList * | |
725 input_scan_dir(const gchar * path) | |
726 { | |
727 GList *node, *result = NULL; | |
728 InputPlugin *ip; | |
729 gchar *path_proxy; | |
730 | |
731 g_return_val_if_fail(path != NULL, NULL); | |
732 | |
733 if (*path == '/') | |
734 while (path[1] == '/') | |
735 path++; | |
736 | |
737 path_proxy = g_strdup(path); | |
738 | |
739 for (node = get_input_list(); node; node = g_list_next(node)) { | |
740 ip = INPUT_PLUGIN(node->data); | |
741 | |
742 if (!ip) | |
743 continue; | |
744 | |
745 if (!ip->scan_dir) | |
746 continue; | |
747 | |
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
|
748 if (!ip->enabled) |
2313 | 749 continue; |
750 | |
751 if ((result = ip->scan_dir(path_proxy))) | |
752 break; | |
753 } | |
754 | |
755 g_free(path_proxy); | |
756 | |
757 return result; | |
758 } | |
759 | |
760 void | |
761 input_get_volume(gint * l, gint * r) | |
762 { | |
3977 | 763 if (volume_l == -1 || volume_r == -1) |
764 output_get_volume(&volume_l, &volume_r); | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
765 |
3977 | 766 *l = volume_l; |
767 *r = volume_r; | |
2313 | 768 } |
769 | |
770 void | |
771 input_set_volume(gint l, gint r) | |
772 { | |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
773 InputPlayback *playback; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
774 |
2505 | 775 gint h_vol[2]; |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
776 |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
777 h_vol[0] = l; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
778 h_vol[1] = r; |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
779 hook_call("volume set", h_vol); |
2505 | 780 |
2569 | 781 if (playback_get_playing() && |
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
782 (playback = get_current_input_playback()) != NULL && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
783 playback->plugin->set_volume && |
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
784 playback->plugin->set_volume(l, r)) |
2569 | 785 return; |
786 | |
2313 | 787 output_set_volume(l, r); |
3977 | 788 |
789 volume_l = l; | |
790 volume_r = r; | |
2313 | 791 } |
792 | |
793 void | |
794 input_update_vis(gint time) | |
795 { | |
796 GList *node; | |
797 VisNode *vis = NULL, *visnext = NULL; | |
798 gboolean found = FALSE; | |
799 | |
800 G_LOCK(vis_mutex); | |
801 node = vis_list; | |
802 while (g_list_next(node) && !found) { | |
803 visnext = g_list_next(node)->data; | |
804 vis = node->data; | |
805 | |
806 if (vis->time >= time) | |
807 break; | |
808 | |
809 vis_list = g_list_delete_link(vis_list, node); | |
810 | |
811 if (visnext->time >= time) { | |
812 found = TRUE; | |
813 break; | |
814 } | |
815 g_free(vis); | |
816 node = vis_list; | |
817 } | |
818 G_UNLOCK(vis_mutex); | |
819 | |
820 if (found) { | |
821 vis_send_data(vis->data, vis->nch, vis->length); | |
822 g_free(vis); | |
823 } | |
824 else | |
825 vis_send_data(NULL, 0, 0); | |
826 } | |
827 | |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
828 /* 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
|
829 void |
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
830 input_set_info_text(gchar *text) |
2313 | 831 { |
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
832 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
|
833 event_queue("title change", title); |
2313 | 834 } |
835 | |
836 void | |
837 input_set_status_buffering(gboolean status) | |
838 { | |
839 if (!playback_get_playing()) | |
840 return; | |
841 | |
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
842 if (!get_current_input_playback()) |
2313 | 843 return; |
844 | |
845 ip_data.buffering = status; | |
846 | |
847 g_return_if_fail(mainwin_playstatus != NULL); | |
848 | |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
849 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
|
850 UI_SKINNED_PLAYSTATUS(mainwin_playstatus)->status = STATUS_PLAY; |
2313 | 851 |
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
852 ui_skinned_playstatus_set_buffering(mainwin_playstatus, ip_data.buffering); |
2313 | 853 } |