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"
|
|
38 #include "playback.h"
|
|
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
|
|
378
|
|
379 gboolean
|
|
380 input_check_file(const gchar * filename, gboolean show_warning)
|
|
381 {
|
|
382 GList *node;
|
|
383 InputPlugin *ip;
|
|
384 gchar *filename_proxy;
|
|
385
|
|
386 filename_proxy = g_strdup(filename);
|
|
387
|
|
388 for (node = get_input_list(); node != NULL; node = g_list_next(node)) {
|
|
389 ip = INPUT_PLUGIN(node->data);
|
|
390 if (ip && input_is_enabled(ip->filename) &&
|
|
391 ip->is_our_file(filename_proxy)) {
|
|
392 g_free(filename_proxy);
|
|
393 return TRUE;
|
|
394 }
|
|
395 }
|
|
396
|
|
397 g_free(filename_proxy);
|
|
398
|
|
399 if (show_warning) {
|
|
400 input_file_not_playable(filename);
|
|
401 }
|
|
402
|
|
403 return FALSE;
|
|
404 }
|
|
405
|
|
406
|
|
407 void
|
|
408 input_set_eq(gint on, gfloat preamp, gfloat * bands)
|
|
409 {
|
|
410 if (!ip_data.playing)
|
|
411 return;
|
|
412
|
|
413 if (!get_current_input_plugin())
|
|
414 return;
|
|
415
|
|
416 if (get_current_input_plugin()->set_eq)
|
|
417 get_current_input_plugin()->set_eq(on, preamp, bands);
|
|
418 }
|
|
419
|
|
420 void
|
|
421 input_get_song_info(const gchar * filename, gchar ** title, gint * length)
|
|
422 {
|
|
423 InputPlugin *ip = NULL;
|
|
424 BmpTitleInput *input;
|
|
425 GList *node;
|
|
426 gchar *tmp = NULL, *ext;
|
|
427 gchar *filename_proxy;
|
|
428
|
|
429 g_return_if_fail(filename != NULL);
|
|
430 g_return_if_fail(title != NULL);
|
|
431 g_return_if_fail(length != NULL);
|
|
432
|
|
433 filename_proxy = g_strdup(filename);
|
|
434
|
|
435 for (node = get_input_list(); node != NULL; node = g_list_next(node)) {
|
|
436 ip = INPUT_PLUGIN(node->data);
|
|
437 if (input_is_enabled(ip->filename) && ip->is_our_file(filename_proxy))
|
|
438 break;
|
|
439 }
|
|
440
|
|
441 if (ip && node && ip->get_song_info) {
|
|
442 ip->get_song_info(filename_proxy, &tmp, length);
|
|
443 *title = str_to_utf8(tmp);
|
|
444 g_free(tmp);
|
|
445 }
|
|
446 else {
|
|
447 input = bmp_title_input_new();
|
|
448
|
|
449 tmp = g_strdup(filename);
|
|
450 if ((ext = strrchr(tmp, '.')))
|
|
451 *ext = '\0';
|
|
452
|
|
453 input->file_name = g_path_get_basename(tmp);
|
|
454 input->file_ext = ext ? ext + 1 : NULL;
|
|
455 input->file_path = tmp;
|
|
456
|
|
457 if ((tmp = xmms_get_titlestring(xmms_get_gentitle_format(), input))) {
|
|
458 (*title) = str_to_utf8(tmp);
|
|
459 g_free(tmp);
|
|
460 }
|
|
461 else {
|
|
462 (*title) = filename_to_utf8(input->file_name);
|
|
463 }
|
|
464
|
|
465 (*length) = -1;
|
|
466
|
|
467 bmp_title_input_free(input);
|
|
468 }
|
|
469
|
|
470 g_free(filename_proxy);
|
|
471 }
|
|
472
|
|
473 static void
|
|
474 input_general_file_info_box(const gchar * filename, InputPlugin * ip)
|
|
475 {
|
|
476 GtkWidget *window, *vbox;
|
|
477 GtkWidget *label, *filename_hbox, *filename_entry;
|
|
478 GtkWidget *bbox, *cancel;
|
|
479
|
|
480 gchar *title, *fileinfo, *basename, *iplugin;
|
|
481 gchar *filename_utf8;
|
|
482
|
|
483 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
484 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
|
|
485 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
|
|
486
|
|
487 basename = g_path_get_basename(filename);
|
|
488 fileinfo = filename_to_utf8(basename);
|
|
489 title = g_strdup_printf(_("bmp: %s"), fileinfo);
|
|
490
|
|
491 gtk_window_set_title(GTK_WINDOW(window), title);
|
|
492
|
|
493 g_free(title);
|
|
494 g_free(fileinfo);
|
|
495 g_free(basename);
|
|
496
|
|
497 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
|
|
498
|
|
499 vbox = gtk_vbox_new(FALSE, 10);
|
|
500 gtk_container_add(GTK_CONTAINER(window), vbox);
|
|
501
|
|
502 filename_hbox = gtk_hbox_new(FALSE, 5);
|
|
503 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0);
|
|
504
|
|
505 label = gtk_label_new(_("Filename:"));
|
|
506 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0);
|
|
507
|
|
508 filename_entry = xmms_entry_new();
|
|
509 filename_utf8 = filename_to_utf8(filename);
|
|
510
|
|
511 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8);
|
|
512 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE);
|
|
513 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0);
|
|
514
|
|
515 g_free(filename_utf8);
|
|
516
|
|
517 if (ip)
|
|
518 if (ip->description)
|
|
519 iplugin = ip->description;
|
|
520 else
|
|
521 iplugin = ip->filename;
|
|
522 else
|
|
523 iplugin = _("No input plugin recognized this file");
|
|
524
|
|
525 title = g_strdup_printf(_("Input plugin: %s"), iplugin);
|
|
526
|
|
527 label = gtk_label_new(title);
|
|
528 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
|
|
529 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
|
|
530 g_free(title);
|
|
531 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
|
|
532
|
|
533 bbox = gtk_hbutton_box_new();
|
|
534 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
|
535 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
536
|
|
537 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
|
538 g_signal_connect_swapped(G_OBJECT(cancel), "clicked",
|
|
539 GTK_SIGNAL_FUNC(gtk_widget_destroy),
|
|
540 GTK_OBJECT(window));
|
|
541 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
|
|
542 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
|
|
543
|
|
544 gtk_widget_show_all(window);
|
|
545 }
|
|
546
|
|
547 void
|
|
548 input_file_info_box(const gchar * filename)
|
|
549 {
|
|
550 GList *node;
|
|
551 InputPlugin *ip;
|
|
552 gchar *filename_proxy;
|
|
553
|
|
554 filename_proxy = g_strdup(filename);
|
|
555
|
|
556 for (node = get_input_list(); node != NULL; node = g_list_next(node)) {
|
|
557 ip = INPUT_PLUGIN(node->data);
|
|
558 if (input_is_enabled(ip->filename)
|
|
559 && ip->is_our_file(filename_proxy)) {
|
|
560 if (ip->file_info_box)
|
|
561 ip->file_info_box(filename_proxy);
|
|
562 else
|
|
563 input_general_file_info_box(filename, ip);
|
|
564
|
|
565 g_free(filename_proxy);
|
|
566 return;
|
|
567 }
|
|
568 }
|
|
569
|
|
570 input_general_file_info_box(filename, NULL);
|
|
571 g_free(filename_proxy);
|
|
572 }
|
|
573
|
|
574 GList *
|
|
575 input_scan_dir(const gchar * path)
|
|
576 {
|
|
577 GList *node, *result = NULL;
|
|
578 InputPlugin *ip;
|
|
579 gchar *path_proxy;
|
|
580
|
|
581 g_return_val_if_fail(path != NULL, NULL);
|
|
582
|
|
583 if (*path == '/')
|
|
584 while (path[1] == '/')
|
|
585 path++;
|
|
586
|
|
587 path_proxy = g_strdup(path);
|
|
588
|
|
589 for (node = get_input_list(); node; node = g_list_next(node)) {
|
|
590 ip = INPUT_PLUGIN(node->data);
|
|
591
|
|
592 if (!ip)
|
|
593 continue;
|
|
594
|
|
595 if (!ip->scan_dir)
|
|
596 continue;
|
|
597
|
|
598 if (!input_is_enabled(ip->filename))
|
|
599 continue;
|
|
600
|
|
601 if ((result = ip->scan_dir(path_proxy)))
|
|
602 break;
|
|
603 }
|
|
604
|
|
605 g_free(path_proxy);
|
|
606
|
|
607 return result;
|
|
608 }
|
|
609
|
|
610 void
|
|
611 input_get_volume(gint * l, gint * r)
|
|
612 {
|
|
613 *l = -1;
|
|
614 *r = -1;
|
|
615 if (bmp_playback_get_playing()) {
|
|
616 if (get_current_input_plugin() &&
|
|
617 get_current_input_plugin()->get_volume) {
|
|
618 get_current_input_plugin()->get_volume(l, r);
|
|
619 return;
|
|
620 }
|
|
621 }
|
|
622 output_get_volume(l, r);
|
|
623 }
|
|
624
|
|
625 void
|
|
626 input_set_volume(gint l, gint r)
|
|
627 {
|
|
628 if (bmp_playback_get_playing()) {
|
|
629 if (get_current_input_plugin() &&
|
|
630 get_current_input_plugin()->set_volume) {
|
|
631 get_current_input_plugin()->set_volume(l, r);
|
|
632 return;
|
|
633 }
|
|
634 }
|
|
635 output_set_volume(l, r);
|
|
636 }
|
|
637
|
|
638 void
|
|
639 input_update_vis(gint time)
|
|
640 {
|
|
641 GList *node;
|
|
642 VisNode *vis = NULL, *visnext = NULL;
|
|
643 gboolean found = FALSE;
|
|
644
|
|
645 G_LOCK(vis_mutex);
|
|
646 node = vis_list;
|
|
647 while (g_list_next(node) && !found) {
|
|
648 visnext = g_list_next(node)->data;
|
|
649 vis = node->data;
|
|
650
|
|
651 if (vis->time >= time)
|
|
652 break;
|
|
653
|
|
654 vis_list = g_list_delete_link(vis_list, node);
|
|
655
|
|
656 if (visnext->time >= time) {
|
|
657 found = TRUE;
|
|
658 break;
|
|
659 }
|
|
660 g_free(vis);
|
|
661 node = vis_list;
|
|
662 }
|
|
663 G_UNLOCK(vis_mutex);
|
|
664
|
|
665 if (found) {
|
|
666 vis_send_data(vis->data, vis->nch, vis->length);
|
|
667 g_free(vis);
|
|
668 }
|
|
669 else
|
|
670 vis_send_data(NULL, 0, 0);
|
|
671 }
|
|
672
|
|
673
|
|
674 gchar *
|
|
675 input_get_info_text(void)
|
|
676 {
|
|
677 return g_strdup(input_info_text);
|
|
678 }
|
|
679
|
|
680 void
|
|
681 input_set_info_text(const gchar * text)
|
|
682 {
|
|
683 g_free(input_info_text);
|
|
684 input_info_text = g_strdup(text);
|
|
685 mainwin_set_info_text();
|
|
686 }
|
|
687
|
|
688 void
|
|
689 input_about(gint index)
|
|
690 {
|
|
691 InputPlugin *ip;
|
|
692
|
|
693 ip = g_list_nth(ip_data.input_list, index)->data;
|
|
694 if (ip && ip->about)
|
|
695 ip->about();
|
|
696 }
|
|
697
|
|
698 void
|
|
699 input_configure(gint index)
|
|
700 {
|
|
701 InputPlugin *ip;
|
|
702
|
|
703 ip = g_list_nth(ip_data.input_list, index)->data;
|
|
704 if (ip && ip->configure)
|
|
705 ip->configure();
|
|
706 }
|