Mercurial > audlegacy
annotate src/audacious/input.c @ 3143:34b4b7c9bcd4 trunk
made the decoder chooser aware of lastfm MP3 streams so that it will only try mad
| author | Cristi Magherusan <majeru@atheme-project.org> |
|---|---|
| date | Sun, 22 Jul 2007 14:03:17 +0300 |
| parents | a2f1d831065f |
| children | 2812140dba3f |
| rev | line source |
|---|---|
| 2313 | 1 /* Audacious - Cross-platform multimedia player |
| 2 * Copyright (C) 2005-2006 Audacious development team | |
| 3 * | |
| 4 * Based on BMP: | |
| 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 | |
|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3110
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
| 2313 | 13 * |
| 14 * This program is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 18 * | |
| 19 * You should have received a copy of the GNU General Public License | |
|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3110
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
|
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
| 2313 | 24 */ |
| 25 | |
| 26 #ifdef HAVE_CONFIG_H | |
| 27 # include "config.h" | |
| 28 #endif | |
| 29 | |
| 30 #include <glib.h> | |
| 31 #include <glib/gi18n.h> | |
| 32 #include <gtk/gtk.h> | |
| 33 #include <string.h> | |
| 34 | |
| 35 #include "fft.h" | |
| 36 #include "input.h" | |
| 37 #include "main.h" | |
| 38 #include "output.h" | |
| 39 #include "playback.h" | |
| 40 #include "pluginenum.h" | |
| 2420 | 41 #include "strings.h" |
| 2313 | 42 #include "titlestring.h" |
| 2420 | 43 #include "ui_main.h" |
| 44 #include "util.h" | |
| 45 #include "visualization.h" | |
| 46 #include "widgets/widgetcore.h" | |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
47 #include "ui_skinned_playstatus.h" |
| 2505 | 48 #include "hook.h" |
| 2313 | 49 |
|
2347
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
50 #include "vfs.h" |
|
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
51 #include "vfs_buffer.h" |
|
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
52 #include "vfs_buffered_file.h" |
|
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
53 |
| 2313 | 54 G_LOCK_DEFINE_STATIC(vis_mutex); |
| 55 | |
| 56 struct _VisNode { | |
| 57 gint time; | |
| 58 gint nch; | |
| 59 gint length; /* number of samples per channel */ | |
| 60 gint16 data[2][512]; | |
| 61 }; | |
| 62 | |
| 63 typedef struct _VisNode VisNode; | |
| 64 | |
| 65 | |
| 66 InputPluginData ip_data = { | |
| 67 NULL, | |
| 68 NULL, | |
| 69 FALSE, | |
| 70 FALSE, | |
| 71 FALSE, | |
| 72 FALSE, | |
| 73 NULL | |
| 74 }; | |
| 75 | |
| 76 static GList *vis_list = NULL; | |
| 77 | |
| 78 gchar *input_info_text = NULL; | |
| 79 | |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
80 InputPlayback * |
|
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
81 get_current_input_playback(void) |
| 2313 | 82 { |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
83 return ip_data.current_input_playback; |
| 2313 | 84 } |
| 85 | |
| 86 void | |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
87 set_current_input_playback(InputPlayback * ip) |
| 2313 | 88 { |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
89 ip_data.current_input_playback = ip; |
| 2313 | 90 } |
| 91 | |
| 92 GList * | |
| 93 get_input_list(void) | |
| 94 { | |
| 95 return ip_data.input_list; | |
| 96 } | |
| 97 | |
| 98 | |
| 99 gboolean | |
| 100 input_is_enabled(const gchar * filename) | |
| 101 { | |
| 102 gchar *basename = g_path_get_basename(filename); | |
| 103 gint enabled; | |
| 104 | |
| 105 enabled = GPOINTER_TO_INT(g_hash_table_lookup(plugin_matrix, basename)); | |
| 106 g_free(basename); | |
| 107 | |
| 108 return enabled; | |
| 109 } | |
| 110 | |
| 111 static void | |
| 112 disabled_iplugins_foreach_func(const gchar * name, | |
| 113 gboolean enabled, | |
| 114 GString * list) | |
| 115 { | |
| 116 g_return_if_fail(list != NULL); | |
| 117 | |
| 118 if (enabled) | |
| 119 return; | |
| 120 | |
| 121 if (list->len > 0) | |
| 122 g_string_append(list, ":"); | |
| 123 | |
| 124 g_string_append(list, name); | |
| 125 } | |
| 126 | |
| 127 gchar * | |
| 128 input_stringify_disabled_list(void) | |
| 129 { | |
| 130 GString *disabled_list; | |
| 131 | |
| 132 disabled_list = g_string_new(""); | |
| 133 g_hash_table_foreach(plugin_matrix, | |
| 134 (GHFunc) disabled_iplugins_foreach_func, | |
| 135 disabled_list); | |
| 136 | |
| 137 return g_string_free(disabled_list, FALSE); | |
| 138 } | |
| 139 | |
| 140 void | |
| 141 free_vis_data(void) | |
| 142 { | |
| 143 G_LOCK(vis_mutex); | |
| 144 g_list_foreach(vis_list, (GFunc) g_free, NULL); | |
| 145 g_list_free(vis_list); | |
| 146 vis_list = NULL; | |
| 147 G_UNLOCK(vis_mutex); | |
| 148 } | |
| 149 | |
| 150 static void | |
| 151 convert_to_s16_ne(AFormat fmt, gpointer ptr, gint16 * left, | |
| 152 gint16 * right, gint nch, gint max) | |
| 153 { | |
| 154 gint16 *ptr16; | |
| 155 guint16 *ptru16; | |
| 156 guint8 *ptru8; | |
| 157 gint i; | |
| 158 | |
| 159 switch (fmt) { | |
| 160 case FMT_U8: | |
| 161 ptru8 = ptr; | |
| 162 if (nch == 1) | |
| 163 for (i = 0; i < max; i++) | |
| 164 left[i] = ((*ptru8++) ^ 128) << 8; | |
| 165 else | |
| 166 for (i = 0; i < max; i++) { | |
| 167 left[i] = ((*ptru8++) ^ 128) << 8; | |
| 168 right[i] = ((*ptru8++) ^ 128) << 8; | |
| 169 } | |
| 170 break; | |
| 171 case FMT_S8: | |
| 172 ptru8 = ptr; | |
| 173 if (nch == 1) | |
| 174 for (i = 0; i < max; i++) | |
| 175 left[i] = (*ptru8++) << 8; | |
| 176 else | |
| 177 for (i = 0; i < max; i++) { | |
| 178 left[i] = (*ptru8++) << 8; | |
| 179 right[i] = (*ptru8++) << 8; | |
| 180 } | |
| 181 break; | |
| 182 case FMT_U16_LE: | |
| 183 ptru16 = ptr; | |
| 184 if (nch == 1) | |
| 185 for (i = 0; i < max; i++, ptru16++) | |
| 186 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
| 187 else | |
| 188 for (i = 0; i < max; i++) { | |
| 189 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
| 190 ptru16++; | |
| 191 right[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
| 192 ptru16++; | |
| 193 } | |
| 194 break; | |
| 195 case FMT_U16_BE: | |
| 196 ptru16 = ptr; | |
| 197 if (nch == 1) | |
| 198 for (i = 0; i < max; i++, ptru16++) | |
| 199 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
| 200 else | |
| 201 for (i = 0; i < max; i++) { | |
| 202 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
| 203 ptru16++; | |
| 204 right[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
| 205 ptru16++; | |
| 206 } | |
| 207 break; | |
| 208 case FMT_U16_NE: | |
| 209 ptru16 = ptr; | |
| 210 if (nch == 1) | |
| 211 for (i = 0; i < max; i++) | |
| 212 left[i] = (*ptru16++) ^ 32768; | |
| 213 else | |
| 214 for (i = 0; i < max; i++) { | |
| 215 left[i] = (*ptru16++) ^ 32768; | |
| 216 right[i] = (*ptru16++) ^ 32768; | |
| 217 } | |
| 218 break; | |
| 219 case FMT_S16_LE: | |
| 220 ptr16 = ptr; | |
| 221 if (nch == 1) | |
| 222 for (i = 0; i < max; i++, ptr16++) | |
| 223 left[i] = GINT16_FROM_LE(*ptr16); | |
| 224 else | |
| 225 for (i = 0; i < max; i++) { | |
| 226 left[i] = GINT16_FROM_LE(*ptr16); | |
| 227 ptr16++; | |
| 228 right[i] = GINT16_FROM_LE(*ptr16); | |
| 229 ptr16++; | |
| 230 } | |
| 231 break; | |
| 232 case FMT_S16_BE: | |
| 233 ptr16 = ptr; | |
| 234 if (nch == 1) | |
| 235 for (i = 0; i < max; i++, ptr16++) | |
| 236 left[i] = GINT16_FROM_BE(*ptr16); | |
| 237 else | |
| 238 for (i = 0; i < max; i++) { | |
| 239 left[i] = GINT16_FROM_BE(*ptr16); | |
| 240 ptr16++; | |
| 241 right[i] = GINT16_FROM_BE(*ptr16); | |
| 242 ptr16++; | |
| 243 } | |
| 244 break; | |
| 245 case FMT_S16_NE: | |
| 246 ptr16 = ptr; | |
| 247 if (nch == 1) | |
| 248 for (i = 0; i < max; i++) | |
| 249 left[i] = (*ptr16++); | |
| 250 else | |
| 251 for (i = 0; i < max; i++) { | |
| 252 left[i] = (*ptr16++); | |
| 253 right[i] = (*ptr16++); | |
| 254 } | |
| 255 break; | |
| 256 } | |
| 257 } | |
| 258 | |
| 259 InputVisType | |
| 260 input_get_vis_type() | |
| 261 { | |
| 262 return INPUT_VIS_OFF; | |
| 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 | |
|
3133
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
296 static time_t |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
297 input_get_mtime(const gchar *filename) |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
298 { |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
299 struct stat buf; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
300 gint rv; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
301 gchar *realfn = NULL; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
302 |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
303 /* stat() does not accept file:// --yaz */ |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
304 realfn = g_filename_from_uri(filename, NULL, NULL); |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
305 rv = stat(realfn ? realfn : filename, &buf); |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
306 g_free(realfn); realfn = NULL; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
307 |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
308 if (rv == 0) { |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
309 return buf.st_mtime; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
310 } else { |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
311 return 0; //error |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
312 } |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
313 } |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
314 |
| 2313 | 315 /* |
| 316 * input_check_file() | |
| 317 * | |
| 318 * Inputs: | |
| 319 * filename to check recursively against input plugins | |
| 320 * whether or not to show an error | |
| 321 * | |
| 322 * Outputs: | |
| 323 * pointer to input plugin which can handle this file | |
| 324 * otherwise, NULL | |
| 325 * | |
| 326 * (the previous code returned a boolean of whether or not we can | |
| 327 * play the file... even WORSE for performance) | |
| 328 * | |
| 329 * Side Effects: | |
| 330 * various input plugins open the file and probe it | |
| 331 * -- this can have very ugly effects performance wise on streams | |
| 332 * | |
| 333 * --nenolod, Dec 31 2005 | |
| 334 * | |
| 335 * Rewritten to use NewVFS probing, semantics are still basically the same. | |
| 336 * | |
| 337 * --nenolod, Dec 5 2006 | |
| 338 * | |
| 339 * Adapted to use the NewVFS extension probing system if enabled. | |
| 340 * | |
| 341 * --nenolod, Dec 12 2006 | |
|
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
342 * |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
343 * Adapted to use the mimetype system. |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
344 * |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
345 * --nenolod, Jul 9 2007 |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
346 * |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
347 * Adapted to return ProbeResult structure. |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
348 * |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
349 * --nenolod, Jul 20 2007 |
| 2313 | 350 */ |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
351 ProbeResult * |
| 2313 | 352 input_check_file(const gchar * filename, gboolean show_warning) |
| 353 { | |
| 354 VFSFile *fd; | |
| 355 GList *node; | |
| 356 InputPlugin *ip; | |
| 357 gchar *filename_proxy; | |
| 358 gint ret = 1; | |
|
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
359 gchar *ext, *tmp, *tmp_uri; |
| 2313 | 360 gboolean use_ext_filter; |
|
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
361 gchar *mimetype; |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
362 ProbeResult *pr = NULL; |
| 2313 | 363 |
| 364 filename_proxy = g_strdup(filename); | |
|
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
365 |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
366 /* Some URIs will end in ?<subsong> to determine the subsong requested. */ |
|
3143
34b4b7c9bcd4
made the decoder chooser aware of lastfm MP3 streams so that it will only try mad
Cristi Magherusan <majeru@atheme-project.org>
parents:
3141
diff
changeset
|
367 /* other streams (like lastfm's) end in ?Session=<session>*/ |
|
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
368 tmp_uri = g_strdup(filename); |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
369 |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
370 tmp = strrchr(tmp_uri, '?'); |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
371 |
|
3143
34b4b7c9bcd4
made the decoder chooser aware of lastfm MP3 streams so that it will only try mad
Cristi Magherusan <majeru@atheme-project.org>
parents:
3141
diff
changeset
|
372 if (tmp != NULL && (g_ascii_isdigit(*(tmp + 1))|| !g_strncasecmp(tmp+1,"Session=",8))) |
|
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
373 *tmp = '\0'; |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
374 |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
375 fd = vfs_buffered_file_new_from_uri(tmp_uri); |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
376 g_free(tmp_uri); |
| 2313 | 377 |
|
3110
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
378 if (!fd) { |
| 3125 | 379 printf("Unable to read from %s, giving up.\n", filename_proxy); |
|
3110
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
380 g_free(filename_proxy); |
|
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
381 return NULL; |
|
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
382 } |
|
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
383 |
| 2313 | 384 ext = strrchr(filename_proxy, '.') + 1; |
| 385 | |
| 2569 | 386 use_ext_filter = |
| 387 (fd != NULL && (!g_strncasecmp(filename, "/", 1) || | |
| 388 !g_strncasecmp(filename, "file://", 7))) ? TRUE : FALSE; | |
| 2313 | 389 |
|
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
390 mimetype = vfs_get_metadata(fd, "content-type"); |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
391 if ((ip = mime_get_plugin(mimetype)) != NULL) |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
392 { |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
393 g_free(filename_proxy); |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
394 vfs_fclose(fd); |
|
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
395 |
|
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
396 pr = g_new0(ProbeResult, 1); |
|
3141
a2f1d831065f
when mime match succeed, pr->ip should be obtained ip.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3133
diff
changeset
|
397 pr->ip = ip; |
|
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
398 |
|
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
399 return pr; |
|
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
400 } |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
401 |
| 2313 | 402 for (node = get_input_list(); node != NULL; node = g_list_next(node)) |
| 403 { | |
| 404 ip = INPUT_PLUGIN(node->data); | |
| 405 | |
| 406 if (!ip || !input_is_enabled(ip->filename)) | |
| 407 continue; | |
| 408 | |
|
2342
f140d0a27093
[svn] - use vfs_rewind() instead of vfs_fseek(fd, 0, seek_set) which was wrong
nenolod
parents:
2331
diff
changeset
|
409 vfs_rewind(fd); |
| 2313 | 410 |
| 2569 | 411 if (cfg.use_extension_probing == TRUE && ip->vfs_extensions != NULL && |
| 412 ext != NULL && ext != (gpointer) 0x1 && use_ext_filter == TRUE) | |
| 2313 | 413 { |
| 414 gint i; | |
| 415 gboolean is_our_ext = FALSE; | |
| 416 | |
| 417 for (i = 0; ip->vfs_extensions[i] != NULL; i++) | |
| 418 { | |
| 419 if (str_has_prefix_nocase(ext, ip->vfs_extensions[i])) | |
| 2331 | 420 { |
| 421 is_our_ext = TRUE; | |
| 422 break; | |
| 423 } | |
| 2313 | 424 } |
| 425 | |
| 426 /* not a plugin that supports this extension */ | |
| 427 if (is_our_ext == FALSE) | |
| 428 continue; | |
| 429 } | |
| 430 | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
431 if (fd && ip->probe_for_tuple != NULL) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
432 { |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
433 TitleInput *tuple = ip->probe_for_tuple(filename_proxy, fd); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
434 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
435 if (tuple != NULL) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
436 { |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
437 g_free(filename_proxy); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
438 vfs_fclose(fd); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
439 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
440 pr = g_new0(ProbeResult, 1); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
441 pr->ip = ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
442 pr->tuple = tuple; |
|
3133
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
443 pr->tuple->mtime = input_get_mtime(filename_proxy); |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
444 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
445 return pr; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
446 } |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
447 } |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
448 else if (fd && ip->is_our_file_from_vfs != NULL) |
| 2313 | 449 { |
| 450 ret = ip->is_our_file_from_vfs(filename_proxy, fd); | |
| 451 | |
| 452 if (ret > 0) | |
| 453 { | |
| 454 g_free(filename_proxy); | |
| 455 vfs_fclose(fd); | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
456 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
457 pr = g_new0(ProbeResult, 1); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
458 pr->ip = ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
459 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
460 return pr; |
| 2313 | 461 } |
| 462 } | |
| 463 else if (ip->is_our_file != NULL) | |
| 464 { | |
| 465 ret = ip->is_our_file(filename_proxy); | |
| 466 | |
| 467 if (ret > 0) | |
| 468 { | |
| 469 g_free(filename_proxy); | |
| 470 vfs_fclose(fd); | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
471 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
472 pr = g_new0(ProbeResult, 1); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
473 pr->ip = ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
474 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
475 return pr; |
| 2313 | 476 } |
| 477 } | |
| 478 | |
| 2331 | 479 if (ret <= -1) |
| 480 break; | |
| 2313 | 481 } |
| 482 | |
| 483 g_free(filename_proxy); | |
| 484 | |
| 485 vfs_fclose(fd); | |
| 486 | |
| 487 return NULL; | |
| 488 } | |
| 489 | |
| 490 | |
| 491 void | |
| 492 input_set_eq(gint on, gfloat preamp, gfloat * bands) | |
| 493 { | |
| 494 if (!ip_data.playing) | |
| 495 return; | |
| 496 | |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
497 if (!get_current_input_playback()) |
| 2313 | 498 return; |
| 499 | |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
500 if (get_current_input_playback()->plugin->set_eq) |
|
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
501 get_current_input_playback()->plugin->set_eq(on, preamp, bands); |
| 2313 | 502 } |
| 503 | |
| 504 void | |
| 505 input_get_song_info(const gchar * filename, gchar ** title, gint * length) | |
| 506 { | |
| 507 InputPlugin *ip = NULL; | |
| 508 BmpTitleInput *input; | |
| 509 gchar *tmp = NULL, *ext; | |
| 510 gchar *filename_proxy; | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
511 ProbeResult *pr; |
| 2313 | 512 |
| 513 g_return_if_fail(filename != NULL); | |
| 514 g_return_if_fail(title != NULL); | |
| 515 g_return_if_fail(length != NULL); | |
| 516 | |
| 517 filename_proxy = g_strdup(filename); | |
| 518 | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
519 pr = input_check_file(filename_proxy, FALSE); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
520 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
521 if (!pr) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
522 return; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
523 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
524 ip = pr->ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
525 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
526 g_free(pr); |
| 2313 | 527 |
| 2331 | 528 if (ip && ip->get_song_info) { |
| 2313 | 529 ip->get_song_info(filename_proxy, &tmp, length); |
| 530 *title = str_to_utf8(tmp); | |
| 531 g_free(tmp); | |
| 532 } | |
| 533 else { | |
| 534 input = bmp_title_input_new(); | |
| 535 | |
| 536 tmp = g_strdup(filename); | |
| 537 if ((ext = strrchr(tmp, '.'))) | |
| 538 *ext = '\0'; | |
| 539 | |
| 540 input->file_name = g_path_get_basename(tmp); | |
| 541 input->file_ext = ext ? ext + 1 : NULL; | |
| 542 input->file_path = g_path_get_dirname(tmp); | |
| 543 | |
| 544 if ((tmp = xmms_get_titlestring(xmms_get_gentitle_format(), input))) { | |
| 545 (*title) = str_to_utf8(tmp); | |
| 546 g_free(tmp); | |
| 547 } | |
| 548 else { | |
| 549 (*title) = filename_to_utf8(input->file_name); | |
| 550 } | |
| 551 | |
| 552 (*length) = -1; | |
| 553 | |
| 554 bmp_title_input_free(input); | |
| 555 input = NULL; | |
| 556 } | |
| 557 | |
| 558 g_free(filename_proxy); | |
| 559 } | |
| 560 | |
| 561 TitleInput * | |
| 562 input_get_song_tuple(const gchar * filename) | |
| 563 { | |
| 564 InputPlugin *ip = NULL; | |
| 565 TitleInput *input; | |
|
2394
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
566 gchar *ext = NULL; |
| 2313 | 567 gchar *filename_proxy; |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
568 ProbeResult *pr; |
| 2313 | 569 |
| 570 if (filename == NULL) | |
| 2331 | 571 return NULL; |
| 2313 | 572 |
| 573 filename_proxy = g_strdup(filename); | |
| 574 | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
575 pr = input_check_file(filename_proxy, FALSE); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
576 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
577 if (!pr) |
|
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
578 return NULL; |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
579 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
580 ip = pr->ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
581 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
582 g_free(pr); |
| 2313 | 583 |
| 2331 | 584 if (ip && ip->get_song_tuple) |
| 2313 | 585 input = ip->get_song_tuple(filename_proxy); |
| 2331 | 586 else |
| 587 { | |
| 2313 | 588 input = bmp_title_input_new(); |
| 589 | |
|
2394
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
590 ext = strrchr(filename, '.'); |
| 2313 | 591 |
| 2331 | 592 input->track_name = NULL; |
| 593 input->length = -1; | |
| 594 input_get_song_info(filename, &input->track_name, &input->length); | |
|
2394
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
595 input->file_name = g_path_get_basename(filename); |
|
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
596 input->file_ext = ( ( ext != NULL ) ? g_strdup(ext + 1) : NULL ); |
|
e2aaa7dca389
[svn] - tuple->file_name coming from input plugins have a string with filename + extension, but tuple->file_name coming from input plugins without a get_song_tuple have a string with filename without extension; fix this incongruency, always pass tuple->filename with a string containing filename + extension
giacomo
parents:
2373
diff
changeset
|
597 input->file_path = g_path_get_dirname(filename); |
| 2313 | 598 } |
| 599 | |
| 2569 | 600 g_free(filename_proxy); |
| 2313 | 601 return input; |
| 602 } | |
| 603 | |
| 604 static void | |
| 605 input_general_file_info_box(const gchar * filename, InputPlugin * ip) | |
| 606 { | |
| 607 GtkWidget *window, *vbox; | |
| 608 GtkWidget *label, *filename_hbox, *filename_entry; | |
| 609 GtkWidget *bbox, *cancel; | |
| 610 | |
| 611 gchar *title, *fileinfo, *basename, *iplugin; | |
| 612 gchar *filename_utf8; | |
|
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
613 gchar *realfn = NULL; |
| 2313 | 614 |
| 615 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 616 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
| 617 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | |
| 618 | |
|
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
619 realfn = g_filename_from_uri(filename, NULL, NULL); |
|
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
620 basename = g_path_get_basename(realfn ? realfn : filename); |
| 2313 | 621 fileinfo = filename_to_utf8(basename); |
| 622 title = g_strdup_printf(_("audacious: %s"), fileinfo); | |
| 623 | |
| 624 gtk_window_set_title(GTK_WINDOW(window), title); | |
| 625 | |
| 626 g_free(title); | |
| 627 g_free(fileinfo); | |
| 628 g_free(basename); | |
| 629 | |
| 630 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
| 631 | |
| 632 vbox = gtk_vbox_new(FALSE, 10); | |
| 633 gtk_container_add(GTK_CONTAINER(window), vbox); | |
| 634 | |
| 635 filename_hbox = gtk_hbox_new(FALSE, 5); | |
| 636 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); | |
| 637 | |
| 638 label = gtk_label_new(_("Filename:")); | |
| 639 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); | |
| 640 | |
| 641 filename_entry = gtk_entry_new(); | |
|
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
642 filename_utf8 = filename_to_utf8(realfn ? realfn : filename); |
|
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
643 g_free(realfn); realfn = NULL; |
| 2313 | 644 |
| 645 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8); | |
| 646 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); | |
| 647 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); | |
| 648 | |
| 649 g_free(filename_utf8); | |
| 650 | |
| 651 if (ip) | |
| 652 if (ip->description) | |
| 653 iplugin = ip->description; | |
| 654 else | |
| 655 iplugin = ip->filename; | |
| 656 else | |
| 657 iplugin = _("No input plugin recognized this file"); | |
| 658 | |
| 659 title = g_strdup_printf(_("Input plugin: %s"), iplugin); | |
| 660 | |
| 661 label = gtk_label_new(title); | |
| 662 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 663 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
| 664 g_free(title); | |
| 665 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); | |
| 666 | |
| 667 bbox = gtk_hbutton_box_new(); | |
| 668 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
| 669 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
| 670 | |
| 671 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
| 672 g_signal_connect_swapped(G_OBJECT(cancel), "clicked", | |
| 673 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
| 674 GTK_OBJECT(window)); | |
| 675 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
| 676 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
| 677 | |
| 678 gtk_widget_show_all(window); | |
| 679 } | |
| 680 | |
| 681 void | |
| 682 input_file_info_box(const gchar * filename) | |
| 683 { | |
| 684 InputPlugin *ip; | |
| 685 gchar *filename_proxy; | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
686 ProbeResult *pr; |
| 2313 | 687 |
| 688 filename_proxy = g_strdup(filename); | |
| 689 | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
690 pr = input_check_file(filename_proxy, FALSE); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
691 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
692 if (!pr) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
693 return; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
694 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
695 ip = pr->ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
696 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
697 g_free(pr); |
| 2313 | 698 |
| 699 if (ip->file_info_box) | |
| 700 ip->file_info_box(filename_proxy); | |
| 701 else | |
| 702 input_general_file_info_box(filename, ip); | |
| 703 | |
| 704 input_general_file_info_box(filename, NULL); | |
| 705 g_free(filename_proxy); | |
| 706 } | |
| 707 | |
| 708 GList * | |
| 709 input_scan_dir(const gchar * path) | |
| 710 { | |
| 711 GList *node, *result = NULL; | |
| 712 InputPlugin *ip; | |
| 713 gchar *path_proxy; | |
| 714 | |
| 715 g_return_val_if_fail(path != NULL, NULL); | |
| 716 | |
| 717 if (*path == '/') | |
| 718 while (path[1] == '/') | |
| 719 path++; | |
| 720 | |
| 721 path_proxy = g_strdup(path); | |
| 722 | |
| 723 for (node = get_input_list(); node; node = g_list_next(node)) { | |
| 724 ip = INPUT_PLUGIN(node->data); | |
| 725 | |
| 726 if (!ip) | |
| 727 continue; | |
| 728 | |
| 729 if (!ip->scan_dir) | |
| 730 continue; | |
| 731 | |
| 732 if (!input_is_enabled(ip->filename)) | |
| 733 continue; | |
| 734 | |
| 735 if ((result = ip->scan_dir(path_proxy))) | |
| 736 break; | |
| 737 } | |
| 738 | |
| 739 g_free(path_proxy); | |
| 740 | |
| 741 return result; | |
| 742 } | |
| 743 | |
| 744 void | |
| 745 input_get_volume(gint * l, gint * r) | |
| 746 { | |
| 747 *l = -1; | |
| 748 *r = -1; | |
| 749 if (playback_get_playing()) { | |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
750 if (get_current_input_playback() && |
|
2439
f2b3d6428b67
[svn] Allow input plugin that implements get_volume to punt to the output plugin.
iabervon
parents:
2437
diff
changeset
|
751 get_current_input_playback()->plugin->get_volume && |
|
f2b3d6428b67
[svn] Allow input plugin that implements get_volume to punt to the output plugin.
iabervon
parents:
2437
diff
changeset
|
752 get_current_input_playback()->plugin->get_volume(l, r)) { |
| 2313 | 753 return; |
| 754 } | |
| 755 } | |
| 756 output_get_volume(l, r); | |
| 757 } | |
| 758 | |
| 759 void | |
| 760 input_set_volume(gint l, gint r) | |
| 761 { | |
| 2505 | 762 gint h_vol[2]; |
| 763 | |
| 2569 | 764 if (playback_get_playing() && |
| 765 get_current_input_playback() && | |
| 766 get_current_input_playback()->plugin->set_volume && | |
| 767 get_current_input_playback()->plugin->set_volume(l, r)) | |
| 768 return; | |
| 769 | |
| 2313 | 770 output_set_volume(l, r); |
| 2505 | 771 |
| 772 h_vol[0] = l; | |
| 773 h_vol[1] = r; | |
| 774 hook_call("volume set", h_vol); | |
| 2313 | 775 } |
| 776 | |
| 777 void | |
| 778 input_update_vis(gint time) | |
| 779 { | |
| 780 GList *node; | |
| 781 VisNode *vis = NULL, *visnext = NULL; | |
| 782 gboolean found = FALSE; | |
| 783 | |
| 784 G_LOCK(vis_mutex); | |
| 785 node = vis_list; | |
| 786 while (g_list_next(node) && !found) { | |
| 787 visnext = g_list_next(node)->data; | |
| 788 vis = node->data; | |
| 789 | |
| 790 if (vis->time >= time) | |
| 791 break; | |
| 792 | |
| 793 vis_list = g_list_delete_link(vis_list, node); | |
| 794 | |
| 795 if (visnext->time >= time) { | |
| 796 found = TRUE; | |
| 797 break; | |
| 798 } | |
| 799 g_free(vis); | |
| 800 node = vis_list; | |
| 801 } | |
| 802 G_UNLOCK(vis_mutex); | |
| 803 | |
| 804 if (found) { | |
| 805 vis_send_data(vis->data, vis->nch, vis->length); | |
| 806 g_free(vis); | |
| 807 } | |
| 808 else | |
| 809 vis_send_data(NULL, 0, 0); | |
| 810 } | |
| 811 | |
| 812 | |
| 813 gchar * | |
| 814 input_get_info_text(void) | |
| 815 { | |
| 816 return g_strdup(input_info_text); | |
| 817 } | |
| 818 | |
| 819 void | |
| 820 input_set_info_text(const gchar * text) | |
| 821 { | |
| 822 g_free(input_info_text); | |
| 823 input_info_text = g_strdup(text); | |
| 824 mainwin_set_info_text(); | |
| 825 } | |
| 826 | |
| 827 void | |
| 828 input_set_status_buffering(gboolean status) | |
| 829 { | |
| 830 if (!playback_get_playing()) | |
| 831 return; | |
| 832 | |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
833 if (!get_current_input_playback()) |
| 2313 | 834 return; |
| 835 | |
| 836 ip_data.buffering = status; | |
| 837 | |
| 838 g_return_if_fail(mainwin_playstatus != NULL); | |
| 839 | |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
840 if (ip_data.buffering == TRUE && mainwin_playstatus != NULL && UI_SKINNED_PLAYSTATUS(mainwin_playstatus)->status == STATUS_STOP) |
|
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
841 UI_SKINNED_PLAYSTATUS(mainwin_playstatus)->status = STATUS_PLAY; |
| 2313 | 842 |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
843 ui_skinned_playstatus_set_buffering(mainwin_playstatus, ip_data.buffering); |
| 2313 | 844 } |
| 845 | |
| 846 void | |
| 847 input_about(gint index) | |
| 848 { | |
| 849 InputPlugin *ip; | |
| 850 | |
| 851 ip = g_list_nth(ip_data.input_list, index)->data; | |
| 852 if (ip && ip->about) | |
| 853 ip->about(); | |
| 854 } | |
| 855 | |
| 856 void | |
| 857 input_configure(gint index) | |
| 858 { | |
| 859 InputPlugin *ip; | |
| 860 | |
| 861 ip = g_list_nth(ip_data.input_list, index)->data; | |
| 862 if (ip && ip->configure) | |
| 863 ip->configure(); | |
| 864 } |
