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