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