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