Mercurial > audlegacy
annotate audacious/input.c @ 1238:dc6f7048a9fa trunk
[svn] - remove metatag entirely
author | nenolod |
---|---|
date | Wed, 14 Jun 2006 22:41:05 -0700 |
parents | 7918849bad3e |
children | 3b990c26fc46 |
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 | |
1231 | 494 TitleInput * |
495 input_get_song_tuple(const gchar * filename) | |
496 { | |
497 InputPlugin *ip = NULL; | |
498 TitleInput *input; | |
499 GList *node; | |
500 gchar *tmp = NULL, *ext; | |
501 gchar *filename_proxy; | |
502 | |
503 if (filename == NULL) | |
504 return NULL; | |
505 | |
506 filename_proxy = g_strdup(filename); | |
507 | |
508 for (node = get_input_list(); node != NULL; node = g_list_next(node)) { | |
509 ip = INPUT_PLUGIN(node->data); | |
510 if (input_is_enabled(ip->filename) && ip->is_our_file(filename_proxy)) | |
511 break; | |
512 } | |
513 | |
514 if (ip && node && ip->get_song_tuple) | |
515 input = ip->get_song_tuple(filename_proxy); | |
516 else { | |
517 input = bmp_title_input_new(); | |
518 | |
519 tmp = g_strdup(filename); | |
520 if ((ext = strrchr(tmp, '.'))) | |
521 *ext = '\0'; | |
522 | |
1235 | 523 input->track_name = NULL; |
524 input->length = -1; | |
525 input_get_song_info(filename, &input->track_name, &input->length); | |
1231 | 526 input->file_name = g_path_get_basename(tmp); |
527 input->file_ext = ext ? ext + 1 : NULL; | |
528 input->file_path = tmp; | |
529 } | |
530 | |
531 return input; | |
532 } | |
533 | |
0 | 534 static void |
535 input_general_file_info_box(const gchar * filename, InputPlugin * ip) | |
536 { | |
537 GtkWidget *window, *vbox; | |
538 GtkWidget *label, *filename_hbox, *filename_entry; | |
539 GtkWidget *bbox, *cancel; | |
540 | |
541 gchar *title, *fileinfo, *basename, *iplugin; | |
542 gchar *filename_utf8; | |
543 | |
544 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
545 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
546 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | |
547 | |
548 basename = g_path_get_basename(filename); | |
549 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
|
550 title = g_strdup_printf(_("audacious: %s"), fileinfo); |
0 | 551 |
552 gtk_window_set_title(GTK_WINDOW(window), title); | |
553 | |
554 g_free(title); | |
555 g_free(fileinfo); | |
556 g_free(basename); | |
557 | |
558 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
559 | |
560 vbox = gtk_vbox_new(FALSE, 10); | |
561 gtk_container_add(GTK_CONTAINER(window), vbox); | |
562 | |
563 filename_hbox = gtk_hbox_new(FALSE, 5); | |
564 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); | |
565 | |
566 label = gtk_label_new(_("Filename:")); | |
567 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); | |
568 | |
569 filename_entry = xmms_entry_new(); | |
570 filename_utf8 = filename_to_utf8(filename); | |
571 | |
572 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8); | |
573 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); | |
574 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); | |
575 | |
576 g_free(filename_utf8); | |
577 | |
578 if (ip) | |
579 if (ip->description) | |
580 iplugin = ip->description; | |
581 else | |
582 iplugin = ip->filename; | |
583 else | |
584 iplugin = _("No input plugin recognized this file"); | |
585 | |
586 title = g_strdup_printf(_("Input plugin: %s"), iplugin); | |
587 | |
588 label = gtk_label_new(title); | |
589 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
590 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
591 g_free(title); | |
592 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); | |
593 | |
594 bbox = gtk_hbutton_box_new(); | |
595 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
596 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
597 | |
598 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
599 g_signal_connect_swapped(G_OBJECT(cancel), "clicked", | |
600 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
601 GTK_OBJECT(window)); | |
602 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
603 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
604 | |
605 gtk_widget_show_all(window); | |
606 } | |
607 | |
608 void | |
609 input_file_info_box(const gchar * filename) | |
610 { | |
611 GList *node; | |
612 InputPlugin *ip; | |
613 gchar *filename_proxy; | |
614 | |
615 filename_proxy = g_strdup(filename); | |
616 | |
617 for (node = get_input_list(); node != NULL; node = g_list_next(node)) { | |
618 ip = INPUT_PLUGIN(node->data); | |
619 if (input_is_enabled(ip->filename) | |
620 && ip->is_our_file(filename_proxy)) { | |
621 if (ip->file_info_box) | |
622 ip->file_info_box(filename_proxy); | |
623 else | |
624 input_general_file_info_box(filename, ip); | |
625 | |
626 g_free(filename_proxy); | |
627 return; | |
628 } | |
629 } | |
630 | |
631 input_general_file_info_box(filename, NULL); | |
632 g_free(filename_proxy); | |
633 } | |
634 | |
635 GList * | |
636 input_scan_dir(const gchar * path) | |
637 { | |
638 GList *node, *result = NULL; | |
639 InputPlugin *ip; | |
640 gchar *path_proxy; | |
641 | |
642 g_return_val_if_fail(path != NULL, NULL); | |
643 | |
644 if (*path == '/') | |
645 while (path[1] == '/') | |
646 path++; | |
647 | |
648 path_proxy = g_strdup(path); | |
649 | |
650 for (node = get_input_list(); node; node = g_list_next(node)) { | |
651 ip = INPUT_PLUGIN(node->data); | |
652 | |
653 if (!ip) | |
654 continue; | |
655 | |
656 if (!ip->scan_dir) | |
657 continue; | |
658 | |
659 if (!input_is_enabled(ip->filename)) | |
660 continue; | |
661 | |
662 if ((result = ip->scan_dir(path_proxy))) | |
663 break; | |
664 } | |
665 | |
666 g_free(path_proxy); | |
667 | |
668 return result; | |
669 } | |
670 | |
671 void | |
672 input_get_volume(gint * l, gint * r) | |
673 { | |
674 *l = -1; | |
675 *r = -1; | |
676 if (bmp_playback_get_playing()) { | |
677 if (get_current_input_plugin() && | |
678 get_current_input_plugin()->get_volume) { | |
679 get_current_input_plugin()->get_volume(l, r); | |
680 return; | |
681 } | |
682 } | |
683 output_get_volume(l, r); | |
684 } | |
685 | |
686 void | |
687 input_set_volume(gint l, gint r) | |
688 { | |
689 if (bmp_playback_get_playing()) { | |
690 if (get_current_input_plugin() && | |
691 get_current_input_plugin()->set_volume) { | |
692 get_current_input_plugin()->set_volume(l, r); | |
693 return; | |
694 } | |
695 } | |
696 output_set_volume(l, r); | |
697 } | |
698 | |
699 void | |
700 input_update_vis(gint time) | |
701 { | |
702 GList *node; | |
703 VisNode *vis = NULL, *visnext = NULL; | |
704 gboolean found = FALSE; | |
705 | |
706 G_LOCK(vis_mutex); | |
707 node = vis_list; | |
708 while (g_list_next(node) && !found) { | |
709 visnext = g_list_next(node)->data; | |
710 vis = node->data; | |
711 | |
712 if (vis->time >= time) | |
713 break; | |
714 | |
715 vis_list = g_list_delete_link(vis_list, node); | |
716 | |
717 if (visnext->time >= time) { | |
718 found = TRUE; | |
719 break; | |
720 } | |
721 g_free(vis); | |
722 node = vis_list; | |
723 } | |
724 G_UNLOCK(vis_mutex); | |
725 | |
726 if (found) { | |
727 vis_send_data(vis->data, vis->nch, vis->length); | |
728 g_free(vis); | |
729 } | |
730 else | |
731 vis_send_data(NULL, 0, 0); | |
732 } | |
733 | |
734 | |
735 gchar * | |
736 input_get_info_text(void) | |
737 { | |
738 return g_strdup(input_info_text); | |
739 } | |
740 | |
741 void | |
742 input_set_info_text(const gchar * text) | |
743 { | |
744 g_free(input_info_text); | |
745 input_info_text = g_strdup(text); | |
746 mainwin_set_info_text(); | |
747 } | |
748 | |
749 void | |
750 input_about(gint index) | |
751 { | |
752 InputPlugin *ip; | |
753 | |
754 ip = g_list_nth(ip_data.input_list, index)->data; | |
755 if (ip && ip->about) | |
756 ip->about(); | |
757 } | |
758 | |
759 void | |
760 input_configure(gint index) | |
761 { | |
762 InputPlugin *ip; | |
763 | |
764 ip = g_list_nth(ip_data.input_list, index)->data; | |
765 if (ip && ip->configure) | |
766 ip->configure(); | |
767 } |