Mercurial > audlegacy
annotate src/audacious/input.c @ 3476:9152829f3c19 trunk
Allow non-active playlist to be saved to file
| author | Kieran Clancy <clancy.kieran+audacious@gmail.com> |
|---|---|
| date | Mon, 10 Sep 2007 13:47:16 +0930 |
| parents | b0f4ab42dd3b |
| children | b413aa0c939c |
| rev | line source |
|---|---|
| 2313 | 1 /* Audacious - Cross-platform multimedia player |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
2 * Copyright (C) 2005-2007 Audacious development team |
| 2313 | 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 | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
35 #include <mowgli.h> |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
36 |
| 2313 | 37 #include "fft.h" |
| 38 #include "input.h" | |
| 39 #include "main.h" | |
| 40 #include "output.h" | |
| 41 #include "playback.h" | |
| 42 #include "pluginenum.h" | |
| 2420 | 43 #include "strings.h" |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
44 #include "tuple.h" |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
45 #include "tuple_formatter.h" |
| 2420 | 46 #include "ui_main.h" |
| 47 #include "util.h" | |
| 48 #include "visualization.h" | |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
49 #include "ui_skinned_playstatus.h" |
| 2505 | 50 #include "hook.h" |
| 2313 | 51 |
|
2347
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
52 #include "vfs.h" |
|
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
53 #include "vfs_buffer.h" |
|
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
54 #include "vfs_buffered_file.h" |
|
74bbc3e18cba
[svn] - fix W:input.c(422) [input_check_file]:Implicit declaration
nenolod
parents:
2344
diff
changeset
|
55 |
| 2313 | 56 G_LOCK_DEFINE_STATIC(vis_mutex); |
| 57 | |
| 58 struct _VisNode { | |
| 59 gint time; | |
| 60 gint nch; | |
| 61 gint length; /* number of samples per channel */ | |
| 62 gint16 data[2][512]; | |
| 63 }; | |
| 64 | |
| 65 typedef struct _VisNode VisNode; | |
| 66 | |
| 67 | |
| 68 InputPluginData ip_data = { | |
| 69 NULL, | |
| 70 NULL, | |
| 71 FALSE, | |
| 72 FALSE, | |
| 73 FALSE, | |
| 74 FALSE, | |
| 75 NULL | |
| 76 }; | |
| 77 | |
| 78 static GList *vis_list = 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 | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
98 /* |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
99 * TODO: move this to utility as something like |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
100 * plugin_generate_list(GList *plugin_list, gboolean enabled_state) |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
101 * |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
102 * -nenolod |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
103 */ |
| 2313 | 104 gchar * |
| 105 input_stringify_disabled_list(void) | |
| 106 { | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
107 GList *node; |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
108 GString *list = g_string_new(""); |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
109 |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
110 MOWGLI_ITER_FOREACH(node, ip_data.input_list) |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
111 { |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
112 Plugin *plugin = (Plugin *) node->data; |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
113 gchar *filename = g_path_get_basename(plugin->filename); |
| 2313 | 114 |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
115 if (plugin->enabled) |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
116 continue; |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
117 |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
118 if (list->len > 0) |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
119 g_string_append(list, ":"); |
| 2313 | 120 |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
121 g_string_append(list, filename); |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
122 g_free(filename); |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
123 } |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
124 |
|
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
125 return g_string_free(list, FALSE); |
| 2313 | 126 } |
| 127 | |
| 128 void | |
| 129 free_vis_data(void) | |
| 130 { | |
| 131 G_LOCK(vis_mutex); | |
| 132 g_list_foreach(vis_list, (GFunc) g_free, NULL); | |
| 133 g_list_free(vis_list); | |
| 134 vis_list = NULL; | |
| 135 G_UNLOCK(vis_mutex); | |
| 136 } | |
| 137 | |
| 138 static void | |
| 139 convert_to_s16_ne(AFormat fmt, gpointer ptr, gint16 * left, | |
| 140 gint16 * right, gint nch, gint max) | |
| 141 { | |
| 142 gint16 *ptr16; | |
| 143 guint16 *ptru16; | |
| 144 guint8 *ptru8; | |
| 145 gint i; | |
| 146 | |
| 147 switch (fmt) { | |
| 148 case FMT_U8: | |
| 149 ptru8 = ptr; | |
| 150 if (nch == 1) | |
| 151 for (i = 0; i < max; i++) | |
| 152 left[i] = ((*ptru8++) ^ 128) << 8; | |
| 153 else | |
| 154 for (i = 0; i < max; i++) { | |
| 155 left[i] = ((*ptru8++) ^ 128) << 8; | |
| 156 right[i] = ((*ptru8++) ^ 128) << 8; | |
| 157 } | |
| 158 break; | |
| 159 case FMT_S8: | |
| 160 ptru8 = ptr; | |
| 161 if (nch == 1) | |
| 162 for (i = 0; i < max; i++) | |
| 163 left[i] = (*ptru8++) << 8; | |
| 164 else | |
| 165 for (i = 0; i < max; i++) { | |
| 166 left[i] = (*ptru8++) << 8; | |
| 167 right[i] = (*ptru8++) << 8; | |
| 168 } | |
| 169 break; | |
| 170 case FMT_U16_LE: | |
| 171 ptru16 = ptr; | |
| 172 if (nch == 1) | |
| 173 for (i = 0; i < max; i++, ptru16++) | |
| 174 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
| 175 else | |
| 176 for (i = 0; i < max; i++) { | |
| 177 left[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
| 178 ptru16++; | |
| 179 right[i] = GUINT16_FROM_LE(*ptru16) ^ 32768; | |
| 180 ptru16++; | |
| 181 } | |
| 182 break; | |
| 183 case FMT_U16_BE: | |
| 184 ptru16 = ptr; | |
| 185 if (nch == 1) | |
| 186 for (i = 0; i < max; i++, ptru16++) | |
| 187 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
| 188 else | |
| 189 for (i = 0; i < max; i++) { | |
| 190 left[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
| 191 ptru16++; | |
| 192 right[i] = GUINT16_FROM_BE(*ptru16) ^ 32768; | |
| 193 ptru16++; | |
| 194 } | |
| 195 break; | |
| 196 case FMT_U16_NE: | |
| 197 ptru16 = ptr; | |
| 198 if (nch == 1) | |
| 199 for (i = 0; i < max; i++) | |
| 200 left[i] = (*ptru16++) ^ 32768; | |
| 201 else | |
| 202 for (i = 0; i < max; i++) { | |
| 203 left[i] = (*ptru16++) ^ 32768; | |
| 204 right[i] = (*ptru16++) ^ 32768; | |
| 205 } | |
| 206 break; | |
| 207 case FMT_S16_LE: | |
| 208 ptr16 = ptr; | |
| 209 if (nch == 1) | |
| 210 for (i = 0; i < max; i++, ptr16++) | |
| 211 left[i] = GINT16_FROM_LE(*ptr16); | |
| 212 else | |
| 213 for (i = 0; i < max; i++) { | |
| 214 left[i] = GINT16_FROM_LE(*ptr16); | |
| 215 ptr16++; | |
| 216 right[i] = GINT16_FROM_LE(*ptr16); | |
| 217 ptr16++; | |
| 218 } | |
| 219 break; | |
| 220 case FMT_S16_BE: | |
| 221 ptr16 = ptr; | |
| 222 if (nch == 1) | |
| 223 for (i = 0; i < max; i++, ptr16++) | |
| 224 left[i] = GINT16_FROM_BE(*ptr16); | |
| 225 else | |
| 226 for (i = 0; i < max; i++) { | |
| 227 left[i] = GINT16_FROM_BE(*ptr16); | |
| 228 ptr16++; | |
| 229 right[i] = GINT16_FROM_BE(*ptr16); | |
| 230 ptr16++; | |
| 231 } | |
| 232 break; | |
| 233 case FMT_S16_NE: | |
| 234 ptr16 = ptr; | |
| 235 if (nch == 1) | |
| 236 for (i = 0; i < max; i++) | |
| 237 left[i] = (*ptr16++); | |
| 238 else | |
| 239 for (i = 0; i < max; i++) { | |
| 240 left[i] = (*ptr16++); | |
| 241 right[i] = (*ptr16++); | |
| 242 } | |
| 243 break; | |
| 244 } | |
| 245 } | |
| 246 | |
| 247 InputVisType | |
| 248 input_get_vis_type() | |
| 249 { | |
| 250 return INPUT_VIS_OFF; | |
| 251 } | |
| 252 | |
| 253 void | |
| 254 input_add_vis_pcm(gint time, AFormat fmt, gint nch, gint length, gpointer ptr) | |
| 255 { | |
| 256 VisNode *vis_node; | |
| 257 gint max; | |
| 258 | |
| 259 max = length / nch; | |
| 260 if (fmt == FMT_U16_LE || fmt == FMT_U16_BE || fmt == FMT_U16_NE || | |
| 261 fmt == FMT_S16_LE || fmt == FMT_S16_BE || fmt == FMT_S16_NE) | |
| 262 max /= 2; | |
| 263 max = CLAMP(max, 0, 512); | |
| 264 | |
| 265 vis_node = g_new0(VisNode, 1); | |
| 266 vis_node->time = time; | |
| 267 vis_node->nch = nch; | |
| 268 vis_node->length = max; | |
| 269 convert_to_s16_ne(fmt, ptr, vis_node->data[0], vis_node->data[1], nch, | |
| 270 max); | |
| 271 | |
| 272 G_LOCK(vis_mutex); | |
| 273 vis_list = g_list_append(vis_list, vis_node); | |
| 274 G_UNLOCK(vis_mutex); | |
| 275 } | |
| 276 | |
| 277 void | |
| 278 input_dont_show_warning(GtkObject * object, gpointer user_data) | |
| 279 { | |
| 280 *((gboolean *) user_data) = | |
| 281 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(object)); | |
| 282 } | |
| 283 | |
|
3133
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
284 static time_t |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
285 input_get_mtime(const gchar *filename) |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
286 { |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
287 struct stat buf; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
288 gint rv; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
289 gchar *realfn = NULL; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
290 |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
291 /* stat() does not accept file:// --yaz */ |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
292 realfn = g_filename_from_uri(filename, NULL, NULL); |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
293 rv = stat(realfn ? realfn : filename, &buf); |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
294 g_free(realfn); realfn = NULL; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
295 |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
296 if (rv == 0) { |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
297 return buf.st_mtime; |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
298 } else { |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
299 return 0; //error |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
300 } |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
301 } |
|
25f92bfd50c4
Initialize tuple.mtime.
William Pitcock <nenolod@atheme-project.org>
parents:
3131
diff
changeset
|
302 |
| 2313 | 303 /* |
| 304 * input_check_file() | |
| 305 * | |
| 306 * Inputs: | |
| 307 * filename to check recursively against input plugins | |
| 308 * whether or not to show an error | |
| 309 * | |
| 310 * Outputs: | |
| 311 * pointer to input plugin which can handle this file | |
| 312 * otherwise, NULL | |
| 313 * | |
| 314 * (the previous code returned a boolean of whether or not we can | |
| 315 * play the file... even WORSE for performance) | |
| 316 * | |
| 317 * Side Effects: | |
| 318 * various input plugins open the file and probe it | |
| 319 * -- this can have very ugly effects performance wise on streams | |
| 320 * | |
| 321 * --nenolod, Dec 31 2005 | |
| 322 * | |
| 323 * Rewritten to use NewVFS probing, semantics are still basically the same. | |
| 324 * | |
| 325 * --nenolod, Dec 5 2006 | |
| 326 * | |
| 327 * Adapted to use the NewVFS extension probing system if enabled. | |
| 328 * | |
| 329 * --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
|
330 * |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
331 * 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
|
332 * |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
333 * --nenolod, Jul 9 2007 |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
334 * |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
335 * Adapted to return ProbeResult structure. |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
336 * |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
337 * --nenolod, Jul 20 2007 |
| 2313 | 338 */ |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
339 ProbeResult * |
| 2313 | 340 input_check_file(const gchar * filename, gboolean show_warning) |
| 341 { | |
| 342 VFSFile *fd; | |
| 343 GList *node; | |
| 344 InputPlugin *ip; | |
| 345 gchar *filename_proxy; | |
| 346 gint ret = 1; | |
|
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
347 gchar *ext, *tmp, *tmp_uri; |
| 2313 | 348 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
|
349 gchar *mimetype; |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
350 ProbeResult *pr = NULL; |
| 2313 | 351 |
| 352 filename_proxy = g_strdup(filename); | |
|
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
353 |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
354 /* Some URIs will end in ?<subsong> to determine the subsong requested. */ |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
355 tmp_uri = g_strdup(filename); |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
356 |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
357 tmp = strrchr(tmp_uri, '?'); |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
358 |
|
3144
2812140dba3f
Backed out changeset 4673533d7cc3
Cristi Magherusan <majeru@atheme-project.org>
parents:
3143
diff
changeset
|
359 if (tmp != NULL && g_ascii_isdigit(*(tmp + 1))) |
|
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
360 *tmp = '\0'; |
|
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
361 |
|
3341
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
362 /* Check for plugins with custom URI:// strings */ |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
363 /* cue:// cdda:// tone:// tact:// */ |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
364 if ((ip = uri_get_plugin(filename)) != NULL && ip->enabled) |
|
3341
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
365 { |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
366 if (ip->is_our_file != NULL) |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
367 ret = ip->is_our_file(filename_proxy); |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
368 else |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
369 ret = 0; |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
370 if (ret > 0) |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
371 { |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
372 g_free(filename_proxy); |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
373 pr = g_new0(ProbeResult, 1); |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
374 pr->ip = ip; |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
375 return pr; |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
376 } |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
377 g_free(filename_proxy); |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
378 return NULL; |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
379 } |
|
3da640de0e99
Check for registered URI://s defined by uri_set_plugin
Christian Birchinger <joker@netswarm.net>
parents:
3334
diff
changeset
|
380 |
|
3145
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
381 /* CD-Audio uses cdda:// dummy paths, no filedescriptor handling for it */ |
|
3162
5161ced1bce2
exclude cue:// from regular scheme check. it is temporal too.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3145
diff
changeset
|
382 /* also cuesheet uses cue:// */ |
|
3343
f5a413804217
cue:// should get accepted before. Contact me if it breaks cue:// support somehow.
Christian Birchinger <joker@netswarm.net>
parents:
3342
diff
changeset
|
383 /* |
|
3342
5d50b9604ddc
Remove hardcoded test because uri_get_plugin should take care of it now
Christian Birchinger <joker@netswarm.net>
parents:
3341
diff
changeset
|
384 if (!g_strncasecmp(filename, "cue://", 6)) { |
|
3145
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
385 for (node = get_input_list(); node != NULL; node = g_list_next(node)) |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
386 { |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
387 ip = INPUT_PLUGIN(node->data); |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
388 if (!ip || !ip->enabled) |
|
3145
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
389 continue; |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
390 if (ip->is_our_file != NULL) |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
391 ret = ip->is_our_file(filename_proxy); |
|
3169
b1964057a1a0
Hardcoded a dummy path to use with cdaudio-ng plugin
Calin Crisan ccrisan@gmail.com
parents:
3166
diff
changeset
|
392 else |
|
b1964057a1a0
Hardcoded a dummy path to use with cdaudio-ng plugin
Calin Crisan ccrisan@gmail.com
parents:
3166
diff
changeset
|
393 ret = 0; |
|
3145
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
394 if (ret > 0) |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
395 { |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
396 g_free(filename_proxy); |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
397 pr = g_new0(ProbeResult, 1); |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
398 pr->ip = ip; |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
399 return pr; |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
400 } |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
401 } |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
402 g_free(filename_proxy); |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
403 return NULL; |
|
0aaad77951c7
Treating cdda:// as a regular file is bad, hmmkay? This is just a hack and nenolod will improve on it later.
Tony Vroon <chainsaw@gentoo.org>
parents:
3144
diff
changeset
|
404 } |
|
3343
f5a413804217
cue:// should get accepted before. Contact me if it breaks cue:// support somehow.
Christian Birchinger <joker@netswarm.net>
parents:
3342
diff
changeset
|
405 */ |
|
2430
4e2fc64d95ef
[svn] - make vfs_buffered_file_new_from_uri declaration const
nenolod
parents:
2427
diff
changeset
|
406 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
|
407 g_free(tmp_uri); |
| 2313 | 408 |
|
3110
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
409 if (!fd) { |
| 3125 | 410 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
|
411 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
|
412 return NULL; |
|
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
413 } |
|
35e560fa183f
Added a fd NULL check to avoid probing on none-existing fds
Christian Birchinger <joker@netswarm.net>
parents:
3081
diff
changeset
|
414 |
| 2313 | 415 ext = strrchr(filename_proxy, '.') + 1; |
| 416 | |
| 2569 | 417 use_ext_filter = |
| 418 (fd != NULL && (!g_strncasecmp(filename, "/", 1) || | |
| 419 !g_strncasecmp(filename, "file://", 7))) ? TRUE : FALSE; | |
| 2313 | 420 |
|
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
421 mimetype = vfs_get_metadata(fd, "content-type"); |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
422 if ((ip = mime_get_plugin(mimetype)) != NULL && ip->enabled) |
|
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
423 { |
|
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
424 if (ip->probe_for_tuple != NULL) |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
425 { |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
426 Tuple *tuple = ip->probe_for_tuple(filename_proxy, fd); |
|
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
427 |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
428 if (tuple != NULL) |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
429 { |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
430 g_free(filename_proxy); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
431 vfs_fclose(fd); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
432 |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
433 pr = g_new0(ProbeResult, 1); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
434 pr->ip = ip; |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
435 pr->tuple = tuple; |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
436 tuple_associate_int(pr->tuple, "mtime", input_get_mtime(filename_proxy)); |
|
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
437 |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
438 return pr; |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
439 } |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
440 } |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
441 else if (fd && ip->is_our_file_from_vfs != NULL) |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
442 { |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
443 ret = ip->is_our_file_from_vfs(filename_proxy, fd); |
|
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
444 |
|
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
445 if (ret > 0) |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
446 { |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
447 g_free(filename_proxy); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
448 vfs_fclose(fd); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
449 |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
450 pr = g_new0(ProbeResult, 1); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
451 pr->ip = ip; |
|
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
452 |
|
3198
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
453 return pr; |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
454 } |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
455 } |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
456 else if (ip->is_our_file != NULL) |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
457 { |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
458 ret = ip->is_our_file(filename_proxy); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
459 |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
460 if (ret > 0) |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
461 { |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
462 g_free(filename_proxy); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
463 vfs_fclose(fd); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
464 |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
465 pr = g_new0(ProbeResult, 1); |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
466 pr->ip = ip; |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
467 |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
468 return pr; |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
469 } |
|
7628b2b7a688
Don't explicitly trust the mimetype, still do a probe.
William Pitcock <nenolod@atheme-project.org>
parents:
3171
diff
changeset
|
470 } |
|
3013
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
471 } |
|
a5f606b01038
Use mimetype system to accelerate detection of network streams.
William Pitcock <nenolod@atheme-project.org>
parents:
2707
diff
changeset
|
472 |
| 2313 | 473 for (node = get_input_list(); node != NULL; node = g_list_next(node)) |
| 474 { | |
| 475 ip = INPUT_PLUGIN(node->data); | |
| 476 | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
477 if (!ip || !ip->enabled) |
| 2313 | 478 continue; |
| 479 | |
|
2342
f140d0a27093
[svn] - use vfs_rewind() instead of vfs_fseek(fd, 0, seek_set) which was wrong
nenolod
parents:
2331
diff
changeset
|
480 vfs_rewind(fd); |
| 2313 | 481 |
| 2569 | 482 if (cfg.use_extension_probing == TRUE && ip->vfs_extensions != NULL && |
| 483 ext != NULL && ext != (gpointer) 0x1 && use_ext_filter == TRUE) | |
| 2313 | 484 { |
| 485 gint i; | |
| 486 gboolean is_our_ext = FALSE; | |
| 487 | |
| 488 for (i = 0; ip->vfs_extensions[i] != NULL; i++) | |
| 489 { | |
| 490 if (str_has_prefix_nocase(ext, ip->vfs_extensions[i])) | |
| 2331 | 491 { |
| 492 is_our_ext = TRUE; | |
| 493 break; | |
| 494 } | |
| 2313 | 495 } |
| 496 | |
| 497 /* not a plugin that supports this extension */ | |
| 498 if (is_our_ext == FALSE) | |
| 499 continue; | |
| 500 } | |
| 501 | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
502 if (fd && ip->probe_for_tuple != NULL) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
503 { |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
504 Tuple *tuple = ip->probe_for_tuple(filename_proxy, fd); |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
505 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
506 if (tuple != NULL) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
507 { |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
508 g_free(filename_proxy); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
509 vfs_fclose(fd); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
510 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
511 pr = g_new0(ProbeResult, 1); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
512 pr->ip = ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
513 pr->tuple = tuple; |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
514 tuple_associate_int(pr->tuple, "mtime", input_get_mtime(filename_proxy)); |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
515 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
516 return pr; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
517 } |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
518 } |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
519 else if (fd && ip->is_our_file_from_vfs != NULL) |
| 2313 | 520 { |
| 521 ret = ip->is_our_file_from_vfs(filename_proxy, fd); | |
| 522 | |
| 523 if (ret > 0) | |
| 524 { | |
| 525 g_free(filename_proxy); | |
| 526 vfs_fclose(fd); | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
527 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
528 pr = g_new0(ProbeResult, 1); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
529 pr->ip = ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
530 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
531 return pr; |
| 2313 | 532 } |
| 533 } | |
| 534 else if (ip->is_our_file != NULL) | |
| 535 { | |
| 536 ret = ip->is_our_file(filename_proxy); | |
| 537 | |
| 538 if (ret > 0) | |
| 539 { | |
| 540 g_free(filename_proxy); | |
| 541 vfs_fclose(fd); | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
542 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
543 pr = g_new0(ProbeResult, 1); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
544 pr->ip = ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
545 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
546 return pr; |
| 2313 | 547 } |
| 548 } | |
| 549 | |
| 2331 | 550 if (ret <= -1) |
| 551 break; | |
| 2313 | 552 } |
| 553 | |
| 554 g_free(filename_proxy); | |
| 555 | |
| 556 vfs_fclose(fd); | |
| 557 | |
| 558 return NULL; | |
| 559 } | |
| 560 | |
| 561 | |
| 562 void | |
| 563 input_set_eq(gint on, gfloat preamp, gfloat * bands) | |
| 564 { | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
565 InputPlayback *playback; |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
566 |
| 2313 | 567 if (!ip_data.playing) |
| 568 return; | |
| 569 | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
570 if ((playback = get_current_input_playback()) == NULL) |
| 2313 | 571 return; |
| 572 | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
573 if (playback->plugin->set_eq) |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
574 playback->plugin->set_eq(on, preamp, bands); |
| 2313 | 575 } |
| 576 | |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
577 Tuple * |
| 2313 | 578 input_get_song_tuple(const gchar * filename) |
| 579 { | |
| 580 InputPlugin *ip = NULL; | |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
581 Tuple *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
|
582 gchar *ext = NULL; |
| 2313 | 583 gchar *filename_proxy; |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
584 ProbeResult *pr; |
| 2313 | 585 |
| 586 if (filename == NULL) | |
| 2331 | 587 return NULL; |
| 2313 | 588 |
| 589 filename_proxy = g_strdup(filename); | |
| 590 | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
591 pr = input_check_file(filename_proxy, FALSE); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
592 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
593 if (!pr) |
|
3128
343504d43afc
Fix warnings.
William Pitcock <nenolod@atheme-project.org>
parents:
3127
diff
changeset
|
594 return NULL; |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
595 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
596 ip = pr->ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
597 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
598 g_free(pr); |
| 2313 | 599 |
| 2331 | 600 if (ip && ip->get_song_tuple) |
| 2313 | 601 input = ip->get_song_tuple(filename_proxy); |
| 2331 | 602 else |
| 603 { | |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
604 gchar *tmp; |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
605 |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
606 input = tuple_new(); |
| 2313 | 607 |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
608 tmp = g_strdup(filename); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
609 if ((ext = strrchr(tmp, '.'))) |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
610 *ext = '\0'; |
| 2313 | 611 |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
612 tuple_associate_string(input, "file-name", g_path_get_basename(tmp)); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
613 |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
614 if (ext) |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
615 tuple_associate_string(input, "file-ext", ext + 1); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
616 |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
617 tuple_associate_string(input, "file-path", g_path_get_dirname(tmp)); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
618 tuple_associate_int(input, "length", -1); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
619 |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3251
diff
changeset
|
620 g_free(tmp); |
| 2313 | 621 } |
| 622 | |
| 2569 | 623 g_free(filename_proxy); |
| 2313 | 624 return input; |
| 625 } | |
| 626 | |
| 627 static void | |
| 628 input_general_file_info_box(const gchar * filename, InputPlugin * ip) | |
| 629 { | |
| 630 GtkWidget *window, *vbox; | |
| 631 GtkWidget *label, *filename_hbox, *filename_entry; | |
| 632 GtkWidget *bbox, *cancel; | |
| 633 | |
| 634 gchar *title, *fileinfo, *basename, *iplugin; | |
| 635 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
|
636 gchar *realfn = NULL; |
| 2313 | 637 |
| 638 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 639 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
| 640 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | |
| 641 | |
|
3081
ba2143c1c6f5
unescape url encoded filename where real filename is needed.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
3072
diff
changeset
|
642 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
|
643 basename = g_path_get_basename(realfn ? realfn : filename); |
| 2313 | 644 fileinfo = filename_to_utf8(basename); |
| 645 title = g_strdup_printf(_("audacious: %s"), fileinfo); | |
| 646 | |
| 647 gtk_window_set_title(GTK_WINDOW(window), title); | |
| 648 | |
| 649 g_free(title); | |
| 650 g_free(fileinfo); | |
| 651 g_free(basename); | |
| 652 | |
| 653 gtk_container_set_border_width(GTK_CONTAINER(window), 10); | |
| 654 | |
| 655 vbox = gtk_vbox_new(FALSE, 10); | |
| 656 gtk_container_add(GTK_CONTAINER(window), vbox); | |
| 657 | |
| 658 filename_hbox = gtk_hbox_new(FALSE, 5); | |
| 659 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); | |
| 660 | |
| 661 label = gtk_label_new(_("Filename:")); | |
| 662 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); | |
| 663 | |
| 664 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
|
665 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
|
666 g_free(realfn); realfn = NULL; |
| 2313 | 667 |
| 668 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8); | |
| 669 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); | |
| 670 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0); | |
| 671 | |
| 672 g_free(filename_utf8); | |
| 673 | |
| 674 if (ip) | |
| 675 if (ip->description) | |
| 676 iplugin = ip->description; | |
| 677 else | |
| 678 iplugin = ip->filename; | |
| 679 else | |
| 680 iplugin = _("No input plugin recognized this file"); | |
| 681 | |
| 682 title = g_strdup_printf(_("Input plugin: %s"), iplugin); | |
| 683 | |
| 684 label = gtk_label_new(title); | |
| 685 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 686 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); | |
| 687 g_free(title); | |
| 688 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); | |
| 689 | |
| 690 bbox = gtk_hbutton_box_new(); | |
| 691 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
| 692 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
| 693 | |
| 694 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
| 695 g_signal_connect_swapped(G_OBJECT(cancel), "clicked", | |
| 696 GTK_SIGNAL_FUNC(gtk_widget_destroy), | |
| 697 GTK_OBJECT(window)); | |
| 698 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); | |
| 699 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
| 700 | |
| 701 gtk_widget_show_all(window); | |
| 702 } | |
| 703 | |
| 704 void | |
| 705 input_file_info_box(const gchar * filename) | |
| 706 { | |
| 707 InputPlugin *ip; | |
| 708 gchar *filename_proxy; | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
709 ProbeResult *pr; |
| 2313 | 710 |
| 711 filename_proxy = g_strdup(filename); | |
| 712 | |
|
3127
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
713 pr = input_check_file(filename_proxy, FALSE); |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
714 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
715 if (!pr) |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
716 return; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
717 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
718 ip = pr->ip; |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
719 |
|
c92070f10148
Use ProbeResult (try 1)
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
720 g_free(pr); |
| 2313 | 721 |
| 722 if (ip->file_info_box) | |
| 723 ip->file_info_box(filename_proxy); | |
| 724 else | |
| 725 input_general_file_info_box(filename, ip); | |
| 726 | |
| 727 input_general_file_info_box(filename, NULL); | |
| 728 g_free(filename_proxy); | |
| 729 } | |
| 730 | |
| 731 GList * | |
| 732 input_scan_dir(const gchar * path) | |
| 733 { | |
| 734 GList *node, *result = NULL; | |
| 735 InputPlugin *ip; | |
| 736 gchar *path_proxy; | |
| 737 | |
| 738 g_return_val_if_fail(path != NULL, NULL); | |
| 739 | |
| 740 if (*path == '/') | |
| 741 while (path[1] == '/') | |
| 742 path++; | |
| 743 | |
| 744 path_proxy = g_strdup(path); | |
| 745 | |
| 746 for (node = get_input_list(); node; node = g_list_next(node)) { | |
| 747 ip = INPUT_PLUGIN(node->data); | |
| 748 | |
| 749 if (!ip) | |
| 750 continue; | |
| 751 | |
| 752 if (!ip->scan_dir) | |
| 753 continue; | |
| 754 | |
|
3437
3092a8b3fe34
Big plugin system changes (part 1 of who knows, it's still a big mess):
William Pitcock <nenolod@atheme.org>
parents:
3416
diff
changeset
|
755 if (!ip->enabled) |
| 2313 | 756 continue; |
| 757 | |
| 758 if ((result = ip->scan_dir(path_proxy))) | |
| 759 break; | |
| 760 } | |
| 761 | |
| 762 g_free(path_proxy); | |
| 763 | |
| 764 return result; | |
| 765 } | |
| 766 | |
| 767 void | |
| 768 input_get_volume(gint * l, gint * r) | |
| 769 { | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
770 InputPlayback *playback; |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
771 |
| 2313 | 772 *l = -1; |
| 773 *r = -1; | |
| 774 if (playback_get_playing()) { | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
775 if ((playback = get_current_input_playback()) != NULL && |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
776 playback->plugin->get_volume && |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
777 playback->plugin->get_volume(l, r)) |
| 2313 | 778 return; |
| 779 } | |
| 780 output_get_volume(l, r); | |
| 781 } | |
| 782 | |
| 783 void | |
| 784 input_set_volume(gint l, gint r) | |
| 785 { | |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
786 InputPlayback *playback; |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
787 |
| 2505 | 788 gint h_vol[2]; |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
789 |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
790 h_vol[0] = l; |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
791 h_vol[1] = r; |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
792 hook_call("volume set", h_vol); |
| 2505 | 793 |
| 2569 | 794 if (playback_get_playing() && |
|
3170
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
795 (playback = get_current_input_playback()) != NULL && |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
796 playback->plugin->set_volume && |
|
603577228518
get_current_input_playback() cleanups.
William Pitcock <nenolod@atheme-project.org>
parents:
3166
diff
changeset
|
797 playback->plugin->set_volume(l, r)) |
| 2569 | 798 return; |
| 799 | |
| 2313 | 800 output_set_volume(l, r); |
| 801 } | |
| 802 | |
| 803 void | |
| 804 input_update_vis(gint time) | |
| 805 { | |
| 806 GList *node; | |
| 807 VisNode *vis = NULL, *visnext = NULL; | |
| 808 gboolean found = FALSE; | |
| 809 | |
| 810 G_LOCK(vis_mutex); | |
| 811 node = vis_list; | |
| 812 while (g_list_next(node) && !found) { | |
| 813 visnext = g_list_next(node)->data; | |
| 814 vis = node->data; | |
| 815 | |
| 816 if (vis->time >= time) | |
| 817 break; | |
| 818 | |
| 819 vis_list = g_list_delete_link(vis_list, node); | |
| 820 | |
| 821 if (visnext->time >= time) { | |
| 822 found = TRUE; | |
| 823 break; | |
| 824 } | |
| 825 g_free(vis); | |
| 826 node = vis_list; | |
| 827 } | |
| 828 G_UNLOCK(vis_mutex); | |
| 829 | |
| 830 if (found) { | |
| 831 vis_send_data(vis->data, vis->nch, vis->length); | |
| 832 g_free(vis); | |
| 833 } | |
| 834 else | |
| 835 vis_send_data(NULL, 0, 0); | |
| 836 } | |
| 837 | |
|
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
838 /* FIXME: move this somewhere else */ |
|
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
839 void |
|
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
840 input_set_info_text(gchar *text) |
| 2313 | 841 { |
|
3165
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
842 gchar *title = g_strdup(text); |
|
8775dfc57ead
Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
3145
diff
changeset
|
843 event_queue("title change", title); |
| 2313 | 844 } |
| 845 | |
| 846 void | |
| 847 input_set_status_buffering(gboolean status) | |
| 848 { | |
| 849 if (!playback_get_playing()) | |
| 850 return; | |
| 851 | |
|
2436
f346d30bf5ab
[svn] Change the input plugin API to use a struct for the currently-playing file.
iabervon
parents:
2430
diff
changeset
|
852 if (!get_current_input_playback()) |
| 2313 | 853 return; |
| 854 | |
| 855 ip_data.buffering = status; | |
| 856 | |
| 857 g_return_if_fail(mainwin_playstatus != NULL); | |
| 858 | |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
859 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
|
860 UI_SKINNED_PLAYSTATUS(mainwin_playstatus)->status = STATUS_PLAY; |
| 2313 | 861 |
|
3072
84de3244aeaa
replace Playstatus with UiSkinnedPlaystatus
Tomasz Mon <desowin@gmail.com>
parents:
3013
diff
changeset
|
862 ui_skinned_playstatus_set_buffering(mainwin_playstatus, ip_data.buffering); |
| 2313 | 863 } |
