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