Mercurial > audlegacy
annotate audacious/input.c @ 442:10535124cc8a trunk
[svn] This commit allows for the use of alternate formats to bmp in skin
files.
author | nenolod |
---|---|
date | Mon, 16 Jan 2006 10:30:11 -0800 |
parents | 1c701dfe5098 |
children | e4e897d20791 |
rev | line source |
---|---|
0 | 1 /* BMP - Cross-platform multimedia player |
2 * Copyright (C) 2003-2004 BMP development team. | |
3 * | |
4 * Based on XMMS: | |
5 * Copyright (C) 1998-2003 XMMS development team. | |
6 * | |
7 * This program is free software; you can redistribute it and/or modify | |
8 * it under the terms of the GNU General Public License as published by | |
9 * the Free Software Foundation; either version 2 of the License, or | |
10 * (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, | |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 */ | |
21 | |
22 #ifdef HAVE_CONFIG_H | |
23 # include "config.h" | |
24 #endif | |
25 | |
26 #include <glib.h> | |
27 #include <glib/gi18n.h> | |
28 #include <gtk/gtk.h> | |
29 #include <string.h> | |
30 | |
31 #include "fft.h" | |
32 #include "input.h" | |
33 #include "main.h" | |
34 #include "mainwin.h" | |
35 #include "output.h" | |
36 #include "util.h" | |
37 #include "visualization.h" | |
284 | 38 #include "libaudcore/playback.h" |
0 | 39 #include "playstatus.h" |
40 #include "pluginenum.h" | |
41 | |
42 #include "libaudacious/titlestring.h" | |
43 #include "libaudacious/util.h" | |
44 #include "libaudacious/xentry.h" | |
45 | |
46 G_LOCK_DEFINE_STATIC(vis_mutex); | |
47 | |
48 struct _VisNode { | |
49 gint time; | |
50 gint nch; | |
51 gint length; /* number of samples per channel */ | |
52 gint16 data[2][512]; | |
53 }; | |
54 | |
55 typedef struct _VisNode VisNode; | |
56 | |
57 | |
58 InputPluginData ip_data = { | |
59 NULL, | |
60 NULL, | |
61 FALSE, | |
62 FALSE | |
63 }; | |
64 | |
65 static GList *vis_list = NULL; | |
66 | |
67 gchar *input_info_text = NULL; | |
68 | |
69 InputPlugin * | |
70 get_current_input_plugin(void) | |
71 { | |
72 return ip_data.current_input_plugin; | |
73 } | |
74 | |
75 void | |
76 set_current_input_plugin(InputPlugin * ip) | |
77 { | |
78 ip_data.current_input_plugin = ip; | |
79 } | |
80 | |
81 GList * | |
82 get_input_list(void) | |
83 { | |
84 return ip_data.input_list; | |
85 } | |
86 | |
87 | |
88 gboolean | |
89 input_is_enabled(const gchar * filename) | |
90 { | |
91 gchar *basename = g_path_get_basename(filename); | |
92 gint enabled; | |
93 | |
94 enabled = GPOINTER_TO_INT(g_hash_table_lookup(plugin_matrix, basename)); | |
95 g_free(basename); | |
96 | |
97 return enabled; | |
98 } | |
99 | |
100 static void | |
101 disabled_iplugins_foreach_func(const gchar * name, | |
102 gboolean enabled, | |
103 GString * list) | |
104 { | |
105 g_return_if_fail(list != NULL); | |
106 | |
107 if (enabled) | |
108 return; | |
109 | |
110 if (list->len > 0) | |
111 g_string_append(list, ":"); | |
112 | |
113 g_string_append(list, name); | |
114 } | |
115 | |
116 gchar * | |
117 input_stringify_disabled_list(void) | |
118 { | |
119 GString *disabled_list; | |
120 | |
121 disabled_list = g_string_new(""); | |
122 g_hash_table_foreach(plugin_matrix, | |
123 (GHFunc) disabled_iplugins_foreach_func, | |
124 disabled_list); | |
125 | |
126 return g_string_free(disabled_list, FALSE); | |
127 } | |
128 | |
129 void | |
130 free_vis_data(void) | |
131 { | |
132 G_LOCK(vis_mutex); | |
133 g_list_foreach(vis_list, (GFunc) g_free, NULL); | |
134 g_list_free(vis_list); | |
135 vis_list = NULL; | |
136 G_UNLOCK(vis_mutex); | |
137 } | |
138 | |
139 static void | |
140 convert_to_s16_ne(AFormat fmt, gpointer ptr, gint16 * left, | |
141 gint16 * right, gint nch, gint max) | |
142 { | |
143 gint16 *ptr16; | |
144 guint16 *ptru16; | |
145 guint8 *ptru8; | |
146 gint i; | |
147 | |
148 switch (fmt) { | |
149 case FMT_U8: | |
150 ptru8 = ptr; | |
151 if (nch == 1) | |
152 for (i = 0; i < max; i++) | |
153 left[i] = ((*ptru8++) ^ 128) << 8; | |
154 else | |
155 for (i = 0; i < max; i++) { | |
156 left[i] = ((*ptru8++) ^ 128) << 8; | |
157 right[i] = ((*ptru8++) ^ 128) << 8; | |
158 } | |
159 break; | |
160 case FMT_S8: | |
161 ptru8 = ptr; | |
162 if (nch == 1) | |
163 for (i = 0; i < max; i++) | |
164 left[i] = (*ptru8++) << 8; | |
165 else | |
166 for (i = 0; i < max; i++) { | |
167 left[i] = (*ptru8++) << 8; | |
168 right[i] = (*ptru8++) << 8; | |
169 } | |
170 break; | |
171 case FMT_U16_LE: | |
172 ptru16 = ptr; | |
173 if (nch == 1) | |
174 for (i = 0; i < max; i++, ptru16++) | |
175 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
176 else | |
177 for (i = 0; i < max; i++) { | |
178 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
179 ptru16++; | |
180 right[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
181 ptru16++; | |
182 } | |
183 break; | |
184 case FMT_U16_BE: | |
185 ptru16 = ptr; | |
186 if (nch == 1) | |
187 for (i = 0; i < max; i++, ptru16++) | |
188 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
189 else | |
190 for (i = 0; i < max; i++) { | |
191 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
192 ptru16++; | |
193 right[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
194 ptru16++; | |
195 } | |
196 break; | |
197 case FMT_U16_NE: | |
198 ptru16 = ptr; | |
199 if (nch == 1) | |
200 for (i = 0; i < max; i++) | |
201 left[i] = (*ptru16++) ^ 32768; | |
202 else | |
203 for (i = 0; i < max; i++) { | |
204 left[i] = (*ptru16++) ^ 32768; | |
205 right[i] = (*ptru16++) ^ 32768; | |
206 } | |
207 break; | |
208 case FMT_S16_LE: | |
209 ptr16 = ptr; | |
210 if (nch == 1) | |
211 for (i = 0; i < max; i++, ptr16++) | |
212 left[i] = GINT16_FROM_LE(*ptr16); | |
213 else | |
214 for (i = 0; i < max; i++) { | |
215 left[i] = GINT16_FROM_LE(*ptr16); | |
216 ptr16++; | |
217 right[i] = GINT16_FROM_LE(*ptr16); | |
218 ptr16++; | |
219 } | |
220 break; | |
221 case FMT_S16_BE: | |
222 ptr16 = ptr; | |
223 if (nch == 1) | |
224 for (i = 0; i < max; i++, ptr16++) | |
225 left[i] = GINT16_FROM_BE(*ptr16); | |
226 else | |
227 for (i = 0; i < max; i++) { | |
228 left[i] = GINT16_FROM_BE(*ptr16); | |
229 ptr16++; | |
230 right[i] = GINT16_FROM_BE(*ptr16); | |
231 ptr16++; | |
232 } | |
233 break; | |
234 case FMT_S16_NE: | |
235 ptr16 = ptr; | |
236 if (nch == 1) | |
237 for (i = 0; i < max; i++) | |
238 left[i] = (*ptr16++); | |
239 else | |
240 for (i = 0; i < max; i++) { | |
241 left[i] = (*ptr16++); | |
242 right[i] = (*ptr16++); | |
243 } | |
244 break; | |
245 } | |
246 } | |
247 | |
248 InputVisType | |
249 input_get_vis_type() | |
250 { | |
251 return INPUT_VIS_OFF; | |
252 } | |
253 | |
254 void | |
255 input_add_vis(gint time, guchar * s, InputVisType type) | |
256 { | |
257 g_warning("plugin uses obsoleted input_add_vis()"); | |
258 } | |
259 | |
260 void | |
261 input_add_vis_pcm(gint time, AFormat fmt, gint nch, gint length, gpointer ptr) | |
262 { | |
263 VisNode *vis_node; | |
264 gint max; | |
265 | |
266 max = length / nch; | |
267 if (fmt == FMT_U16_LE || fmt == FMT_U16_BE || fmt == FMT_U16_NE || | |
268 fmt == FMT_S16_LE || fmt == FMT_S16_BE || fmt == FMT_S16_NE) | |
269 max /= 2; | |
270 max = CLAMP(max, 0, 512); | |
271 | |
272 vis_node = g_new0(VisNode, 1); | |
273 vis_node->time = time; | |
274 vis_node->nch = nch; | |
275 vis_node->length = max; | |
276 convert_to_s16_ne(fmt, ptr, vis_node->data[0], vis_node->data[1], nch, | |
277 max); | |
278 | |
279 G_LOCK(vis_mutex); | |
280 vis_list = g_list_append(vis_list, vis_node); | |
281 G_UNLOCK(vis_mutex); | |
282 } | |
283 | |
284 void | |
285 input_dont_show_warning(GtkObject * object, gpointer user_data) | |
286 { | |
287 *((gboolean *) user_data) = | |
288 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object)); | |
289 } | |
290 | |
291 | |
292 void | |
293 input_show_unplayable_files(const gchar * filename) | |
294 { | |
295 static GtkWidget *dialog = NULL; | |
296 static GtkListStore *store = NULL; | |
297 | |
298 const gchar *markup = | |
299 N_("<b><big>Unable to play files.</big></b>\n\n" | |
300 "The following files could not be played. Please check that:\n" | |
301 "1. they are accessible.\n" | |
302 "2. you have enabled the media plugins required."); | |
303 | |
304 GtkTreeIter iter; | |
305 | |
306 gchar *filename_utf8; | |
307 | |
308 if (!dialog) { | |
309 GtkWidget *vbox, *check; | |
310 GtkWidget *expander; | |
311 GtkWidget *scrolled, *treeview; | |
312 GtkCellRenderer *renderer; | |
313 | |
314 dialog = | |
315 gtk_message_dialog_new_with_markup(GTK_WINDOW(mainwin), | |
316 GTK_DIALOG_DESTROY_WITH_PARENT, | |
317 GTK_MESSAGE_ERROR, | |
318 GTK_BUTTONS_OK, | |
319 _(markup)); | |
320 | |
321 vbox = gtk_vbox_new(FALSE, 6); | |
322 | |
323 check = gtk_check_button_new_with_label | |
324 (_("Don't show this warning anymore")); | |
325 | |
326 expander = gtk_expander_new_with_mnemonic(_("Show more _details")); | |
327 | |
328 scrolled = gtk_scrolled_window_new(NULL, NULL); | |
329 gtk_container_add(GTK_CONTAINER(expander), scrolled); | |
330 | |
331 store = gtk_list_store_new(1, G_TYPE_STRING); | |
332 | |
333 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); | |
334 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); | |
335 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), | |
336 treeview); | |
337 | |
338 renderer = gtk_cell_renderer_text_new(); | |
339 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | |
340 -1, _("Filename"), | |
341 renderer, | |
342 "text", 0, | |
343 NULL); | |
344 | |
345 vbox = GTK_DIALOG(dialog)->vbox; | |
346 gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); | |
347 gtk_box_pack_start(GTK_BOX(vbox), expander, TRUE, TRUE, 0); | |
348 | |
349 g_signal_connect(dialog, "response", | |
350 G_CALLBACK(gtk_widget_destroy), | |
351 dialog); | |
352 g_signal_connect(dialog, "destroy", | |
353 G_CALLBACK(gtk_widget_destroyed), | |
354 &dialog); | |
355 g_signal_connect(check, "clicked", | |
356 G_CALLBACK(input_dont_show_warning), | |
357 &cfg.warn_about_unplayables); | |
358 | |
359 gtk_widget_show_all(dialog); | |
360 } | |
361 | |
362 gtk_window_present(GTK_WINDOW(dialog)); | |
363 | |
364 filename_utf8 = filename_to_utf8(filename); | |
365 gtk_list_store_append(store, &iter); | |
366 gtk_list_store_set(store, &iter, 0, filename_utf8, -1); | |
367 g_free(filename_utf8); | |
368 } | |
369 | |
370 | |
371 void | |
372 input_file_not_playable(const gchar * filename) | |
373 { | |
374 if (cfg.warn_about_unplayables) | |
375 input_show_unplayable_files(filename); | |
376 } | |
377 | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
378 /* |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
379 * input_check_file() |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
380 * |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
381 * Inputs: |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
382 * filename to check recursively against input plugins |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
383 * whether or not to show an error |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
384 * |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
385 * Outputs: |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
386 * pointer to input plugin which can handle this file |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
387 * otherwise, NULL |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
388 * |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
389 * (the previous code returned a boolean of whether or not we can |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
390 * play the file... even WORSE for performance) |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
391 * |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
392 * Side Effects: |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
393 * various input plugins open the file and probe it |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
394 * -- this can have very ugly effects performance wise on streams |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
395 * |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
396 * --nenolod, Dec 31 2005 |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
397 */ |
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
398 InputPlugin * |
0 | 399 input_check_file(const gchar * filename, gboolean show_warning) |
400 { | |
401 GList *node; | |
402 InputPlugin *ip; | |
403 gchar *filename_proxy; | |
404 | |
405 filename_proxy = g_strdup(filename); | |
406 | |
407 for (node = get_input_list(); node != NULL; node = g_list_next(node)) { | |
408 ip = INPUT_PLUGIN(node->data); | |
409 if (ip && input_is_enabled(ip->filename) && | |
410 ip->is_our_file(filename_proxy)) { | |
411 g_free(filename_proxy); | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
412 return ip; |
0 | 413 } |
414 } | |
415 | |
416 g_free(filename_proxy); | |
417 | |
418 if (show_warning) { | |
419 input_file_not_playable(filename); | |
420 } | |
421 | |
355
1c701dfe5098
[svn] Cache the decoder used for each PlaylistEntry. This reduces the amount
nenolod
parents:
284
diff
changeset
|
422 return NULL; |
0 | 423 } |
424 | |
425 | |
426 void | |
427 input_set_eq(gint on, gfloat preamp, gfloat * bands) | |
428 { | |
429 if (!ip_data.playing) | |
430 return; | |
431 | |
432 if (!get_current_input_plugin()) | |
433 return; | |
434 | |
435 if (get_current_input_plugin()->set_eq) | |
436 get_current_input_plugin()->set_eq(on, preamp, bands); | |
437 } | |
438 | |
439 void | |
440 input_get_song_info(const gchar * filename, gchar ** title, gint * length) | |
441 { | |
442 InputPlugin *ip = NULL; | |
443 BmpTitleInput *input; | |
444 GList *node; | |
445 gchar *tmp = NULL, *ext; | |
446 gchar *filename_proxy; | |
447 | |
448 g_return_if_fail(filename != NULL); | |
449 g_return_if_fail(title != NULL); | |
450 g_return_if_fail(length != NULL); | |
451 | |
452 filename_proxy = g_strdup(filename); | |
453 | |
454 for (node = get_input_list(); node != NULL; node = g_list_next(node)) { | |
455 ip = INPUT_PLUGIN(node->data); | |
456 if (input_is_enabled(ip->filename) && ip->is_our_file(filename_proxy)) | |
457 break; | |
458 } | |
459 | |
460 if (ip && node && ip->get_song_info) { | |
461 ip->get_song_info(filename_proxy, &tmp, length); | |
462 *title = str_to_utf8(tmp); | |
463 g_free(tmp); | |
464 } | |
465 else { | |
466 input = bmp_title_input_new(); | |
467 | |
468 tmp = g_strdup(filename); | |
469 if ((ext = strrchr(tmp, '.'))) | |
470 *ext = '\0'; | |
471 | |
472 input->file_name = g_path_get_basename(tmp); | |
473 input->file_ext = ext ? ext + 1 : NULL; | |
474 input->file_path = tmp; | |
475 | |
476 if ((tmp = xmms_get_titlestring(xmms_get_gentitle_format(), input))) { | |
477 (*title) = str_to_utf8(tmp); | |
478 g_free(tmp); | |
479 } | |
480 else { | |
481 (*title) = filename_to_utf8(input->file_name); | |
482 } | |
483 | |
484 (*length) = -1; | |
485 | |
486 bmp_title_input_free(input); | |
487 } | |
488 | |
489 g_free(filename_proxy); | |
490 } | |
491 | |
492 static void | |
493 input_general_file_info_box(const gchar * filename, InputPlugin * ip) | |
494 { | |
495 GtkWidget *window, *vbox; | |
496 GtkWidget *label, *filename_hbox, *filename_entry; | |
497 GtkWidget *bbox, *cancel; | |
498 | |
499 gchar *title, *fileinfo, *basename, *iplugin; | |
500 gchar *filename_utf8; | |
501 | |
502 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
503 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
504 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | |
505 | |
506 basename = g_path_get_basename(filename); | |
507 fileinfo = filename_to_utf8(basename); | |
257
256b3acc87d4
[svn] Properly report Audacious instead of XMMS or BMP in all places. Patch by laci; closes bug #379.
chainsaw
parents:
0
diff
changeset
|
508 title = g_strdup_printf(_("audacious: %s"), fileinfo); |
0 | 509 |
510 gtk_window_set_title(GTK_WINDOW(window), title); | |
511 | |
512 g_free(title); | |
513 g_free(fileinfo); | |
514 g_free(basename); | |
515 | |
516 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
517 | |
518 vbox = gtk_vbox_new(FALSE, 10); | |
519 gtk_container_add(GTK_CONTAINER(window), vbox); | |
520 | |
521 filename_hbox = gtk_hbox_new(FALSE, 5); | |
522 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); | |
523 | |
524 label = gtk_label_new(_("Filename:")); | |
525 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); | |
526 | |
527 filename_entry = xmms_entry_new(); | |
528 filename_utf8 = filename_to_utf8(filename); | |
529 | |
530 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8); | |
531 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); | |
532 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); | |
533 | |
534 g_free(filename_utf8); | |
535 | |
536 if (ip) | |
537 if (ip->description) | |
538 iplugin = ip->description; | |
539 else | |
540 iplugin = ip->filename; | |
541 else | |
542 iplugin = _("No input plugin recognized this file"); | |
543 | |
544 title = g_strdup_printf(_("Input plugin: %s"), iplugin); | |
545 | |
546 label = gtk_label_new(title); | |
547 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
548 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
549 g_free(title); | |
550 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); | |
551 | |
552 bbox = gtk_hbutton_box_new(); | |
553 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
554 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
555 | |
556 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
557 g_signal_connect_swapped(G_OBJECT(cancel), "clicked", | |
558 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
559 GTK_OBJECT(window)); | |
560 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
561 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
562 | |
563 gtk_widget_show_all(window); | |
564 } | |
565 | |
566 void | |
567 input_file_info_box(const gchar * filename) | |
568 { | |
569 GList *node; | |
570 InputPlugin *ip; | |
571 gchar *filename_proxy; | |
572 | |
573 filename_proxy = g_strdup(filename); | |
574 | |
575 for (node = get_input_list(); node != NULL; node = g_list_next(node)) { | |
576 ip = INPUT_PLUGIN(node->data); | |
577 if (input_is_enabled(ip->filename) | |
578 && ip->is_our_file(filename_proxy)) { | |
579 if (ip->file_info_box) | |
580 ip->file_info_box(filename_proxy); | |
581 else | |
582 input_general_file_info_box(filename, ip); | |
583 | |
584 g_free(filename_proxy); | |
585 return; | |
586 } | |
587 } | |
588 | |
589 input_general_file_info_box(filename, NULL); | |
590 g_free(filename_proxy); | |
591 } | |
592 | |
593 GList * | |
594 input_scan_dir(const gchar * path) | |
595 { | |
596 GList *node, *result = NULL; | |
597 InputPlugin *ip; | |
598 gchar *path_proxy; | |
599 | |
600 g_return_val_if_fail(path != NULL, NULL); | |
601 | |
602 if (*path == '/') | |
603 while (path[1] == '/') | |
604 path++; | |
605 | |
606 path_proxy = g_strdup(path); | |
607 | |
608 for (node = get_input_list(); node; node = g_list_next(node)) { | |
609 ip = INPUT_PLUGIN(node->data); | |
610 | |
611 if (!ip) | |
612 continue; | |
613 | |
614 if (!ip->scan_dir) | |
615 continue; | |
616 | |
617 if (!input_is_enabled(ip->filename)) | |
618 continue; | |
619 | |
620 if ((result = ip->scan_dir(path_proxy))) | |
621 break; | |
622 } | |
623 | |
624 g_free(path_proxy); | |
625 | |
626 return result; | |
627 } | |
628 | |
629 void | |
630 input_get_volume(gint * l, gint * r) | |
631 { | |
632 *l = -1; | |
633 *r = -1; | |
634 if (bmp_playback_get_playing()) { | |
635 if (get_current_input_plugin() && | |
636 get_current_input_plugin()->get_volume) { | |
637 get_current_input_plugin()->get_volume(l, r); | |
638 return; | |
639 } | |
640 } | |
641 output_get_volume(l, r); | |
642 } | |
643 | |
644 void | |
645 input_set_volume(gint l, gint r) | |
646 { | |
647 if (bmp_playback_get_playing()) { | |
648 if (get_current_input_plugin() && | |
649 get_current_input_plugin()->set_volume) { | |
650 get_current_input_plugin()->set_volume(l, r); | |
651 return; | |
652 } | |
653 } | |
654 output_set_volume(l, r); | |
655 } | |
656 | |
657 void | |
658 input_update_vis(gint time) | |
659 { | |
660 GList *node; | |
661 VisNode *vis = NULL, *visnext = NULL; | |
662 gboolean found = FALSE; | |
663 | |
664 G_LOCK(vis_mutex); | |
665 node = vis_list; | |
666 while (g_list_next(node) && !found) { | |
667 visnext = g_list_next(node)->data; | |
668 vis = node->data; | |
669 | |
670 if (vis->time >= time) | |
671 break; | |
672 | |
673 vis_list = g_list_delete_link(vis_list, node); | |
674 | |
675 if (visnext->time >= time) { | |
676 found = TRUE; | |
677 break; | |
678 } | |
679 g_free(vis); | |
680 node = vis_list; | |
681 } | |
682 G_UNLOCK(vis_mutex); | |
683 | |
684 if (found) { | |
685 vis_send_data(vis->data, vis->nch, vis->length); | |
686 g_free(vis); | |
687 } | |
688 else | |
689 vis_send_data(NULL, 0, 0); | |
690 } | |
691 | |
692 | |
693 gchar * | |
694 input_get_info_text(void) | |
695 { | |
696 return g_strdup(input_info_text); | |
697 } | |
698 | |
699 void | |
700 input_set_info_text(const gchar * text) | |
701 { | |
702 g_free(input_info_text); | |
703 input_info_text = g_strdup(text); | |
704 mainwin_set_info_text(); | |
705 } | |
706 | |
707 void | |
708 input_about(gint index) | |
709 { | |
710 InputPlugin *ip; | |
711 | |
712 ip = g_list_nth(ip_data.input_list, index)->data; | |
713 if (ip && ip->about) | |
714 ip->about(); | |
715 } | |
716 | |
717 void | |
718 input_configure(gint index) | |
719 { | |
720 InputPlugin *ip; | |
721 | |
722 ip = g_list_nth(ip_data.input_list, index)->data; | |
723 if (ip && ip->configure) | |
724 ip->configure(); | |
725 } |