# HG changeset patch # User William Pitcock # Date 1184980148 18000 # Node ID dfe8f4eb3dbaf42c38608b00cf1983aadcf9171c # Parent 03b85ed645277ea8457bb7beb7abd79c55cc0f38# Parent ed6c6aa50c7c43767ac310c91cb30f31b5ea969c Automated merge with ssh://hg.atheme.org//hg/audacious diff -r ed6c6aa50c7c -r dfe8f4eb3dba src/audacious/input.c --- a/src/audacious/input.c Sat Jul 21 00:44:07 2007 +0200 +++ b/src/audacious/input.c Fri Jul 20 20:09:08 2007 -0500 @@ -324,8 +324,12 @@ * Adapted to use the mimetype system. * * --nenolod, Jul 9 2007 + * + * Adapted to return ProbeResult structure. + * + * --nenolod, Jul 20 2007 */ -InputPlugin * +ProbeResult * input_check_file(const gchar * filename, gboolean show_warning) { VFSFile *fd; @@ -336,6 +340,7 @@ gchar *ext, *tmp, *tmp_uri; gboolean use_ext_filter; gchar *mimetype; + ProbeResult *pr = NULL; filename_proxy = g_strdup(filename); @@ -367,7 +372,11 @@ { g_free(filename_proxy); vfs_fclose(fd); - return ip; + + pr = g_new0(ProbeResult, 1); + pr->ip = NULL; + + return pr; } for (node = get_input_list(); node != NULL; node = g_list_next(node)) @@ -399,7 +408,23 @@ continue; } - if (fd && ip->is_our_file_from_vfs != NULL) + if (fd && ip->probe_for_tuple != NULL) + { + TitleInput *tuple = ip->probe_for_tuple(filename_proxy, fd); + + if (tuple != NULL) + { + g_free(filename_proxy); + vfs_fclose(fd); + + pr = g_new0(ProbeResult, 1); + pr->ip = ip; + pr->tuple = tuple; + + return pr; + } + } + else if (fd && ip->is_our_file_from_vfs != NULL) { ret = ip->is_our_file_from_vfs(filename_proxy, fd); @@ -407,7 +432,11 @@ { g_free(filename_proxy); vfs_fclose(fd); - return ip; + + pr = g_new0(ProbeResult, 1); + pr->ip = ip; + + return pr; } } else if (ip->is_our_file != NULL) @@ -418,7 +447,11 @@ { g_free(filename_proxy); vfs_fclose(fd); - return ip; + + pr = g_new0(ProbeResult, 1); + pr->ip = ip; + + return pr; } } @@ -454,6 +487,7 @@ BmpTitleInput *input; gchar *tmp = NULL, *ext; gchar *filename_proxy; + ProbeResult *pr; g_return_if_fail(filename != NULL); g_return_if_fail(title != NULL); @@ -461,7 +495,14 @@ filename_proxy = g_strdup(filename); - ip = input_check_file(filename_proxy, FALSE); + pr = input_check_file(filename_proxy, FALSE); + + if (!pr) + return; + + ip = pr->ip; + + g_free(pr); if (ip && ip->get_song_info) { ip->get_song_info(filename_proxy, &tmp, length); @@ -503,13 +544,21 @@ TitleInput *input; gchar *ext = NULL; gchar *filename_proxy; + ProbeResult *pr; if (filename == NULL) return NULL; filename_proxy = g_strdup(filename); - ip = input_check_file(filename_proxy, FALSE); + pr = input_check_file(filename_proxy, FALSE); + + if (!pr) + return NULL; + + ip = pr->ip; + + g_free(pr); if (ip && ip->get_song_tuple) input = ip->get_song_tuple(filename_proxy); @@ -613,10 +662,18 @@ { InputPlugin *ip; gchar *filename_proxy; + ProbeResult *pr; filename_proxy = g_strdup(filename); - ip = input_check_file(filename_proxy, FALSE); + pr = input_check_file(filename_proxy, FALSE); + + if (!pr) + return; + + ip = pr->ip; + + g_free(pr); if (ip->file_info_box) ip->file_info_box(filename_proxy); diff -r ed6c6aa50c7c -r dfe8f4eb3dba src/audacious/input.h --- a/src/audacious/input.h Sat Jul 21 00:44:07 2007 +0200 +++ b/src/audacious/input.h Fri Jul 20 20:09:08 2007 -0500 @@ -40,6 +40,11 @@ GMutex *playback_mutex; }; +typedef struct { + TitleInput *tuple; + InputPlugin *ip; +} ProbeResult; + GList *get_input_list(void); InputPlayback *get_current_input_playback(void); void set_current_input_playback(InputPlayback * ip); @@ -47,7 +52,7 @@ InputVisType input_get_vis_type(); void free_vis_data(void); -InputPlugin *input_check_file(const gchar * filename, gboolean show_warning); +ProbeResult *input_check_file(const gchar * filename, gboolean show_warning); TitleInput *input_get_song_tuple(const gchar * filename); void input_play(gchar * filename); diff -r ed6c6aa50c7c -r dfe8f4eb3dba src/audacious/playback.c --- a/src/audacious/playback.c Sat Jul 21 00:44:07 2007 +0200 +++ b/src/audacious/playback.c Fri Jul 20 20:09:08 2007 -0500 @@ -218,7 +218,7 @@ gboolean playback_play_file(PlaylistEntry *entry) { - InputPlayback * playback; + InputPlayback *playback; g_return_val_if_fail(entry != NULL, FALSE); if (!get_current_output_plugin()) { @@ -230,14 +230,20 @@ if (cfg.random_skin_on_play) skin_set_random_skin(); - /* - * This is slightly uglier than the original version, but should - * fix the "crash" issues as seen in 0.2 when dealing with this situation. - * - nenolod - */ - if (!entry->decoder && - (((entry->decoder = input_check_file(entry->filename, FALSE)) == NULL) || - !input_is_enabled(entry->decoder->filename))) + if (!entry->decoder) + { + ProbeResult *pr = input_check_file(entry->filename, FALSE); + + if (pr != NULL) + { + entry->decoder = pr->ip; + entry->tuple = pr->tuple; + + g_free(pr); + } + } + + if (!entry->decoder || !input_is_enabled(entry->decoder->filename)) { set_current_input_playback(NULL); mainwin_set_info_text(); diff -r ed6c6aa50c7c -r dfe8f4eb3dba src/audacious/playlist.c --- a/src/audacious/playlist.c Sat Jul 21 00:44:07 2007 +0200 +++ b/src/audacious/playlist.c Fri Jul 20 20:09:08 2007 -0500 @@ -188,7 +188,8 @@ static gboolean playlist_entry_get_info(PlaylistEntry * entry) { - TitleInput *tuple; + TitleInput *tuple = NULL; + ProbeResult *pr = NULL; time_t modtime; g_return_val_if_fail(entry != NULL, FALSE); @@ -206,7 +207,11 @@ } if (entry->decoder == NULL) - entry->decoder = input_check_file(entry->filename, FALSE); + { + pr = input_check_file(entry->filename, FALSE); + if (pr) + entry->decoder = pr->ip; + } /* renew tuple if file mtime is newer than tuple mtime. */ if(entry->tuple){ @@ -218,9 +223,9 @@ } } - if (entry->decoder == NULL || entry->decoder->get_song_tuple == NULL) - tuple = input_get_song_tuple(entry->filename); - else + if (pr != NULL && pr->tuple != NULL) + tuple = pr->tuple; + else if (entry->decoder != NULL && entry->decoder->get_song_tuple != NULL) tuple = entry->decoder->get_song_tuple(entry->filename); if (tuple == NULL) @@ -234,6 +239,8 @@ entry->length = tuple->length; entry->tuple = tuple; + g_free(pr); + return TRUE; } @@ -684,21 +691,15 @@ } } -static void -__playlist_ins(Playlist * playlist, const gchar * filename, gint pos, InputPlugin *dec) -{ - __playlist_ins_with_info(playlist, filename, pos, NULL, -1, dec); - playlist_recalc_total_time(playlist); - playlist_manager_update(); -} - gboolean playlist_ins(Playlist * playlist, const gchar * filename, gint pos) { gchar buf[64], *p; gint r; VFSFile *file; + ProbeResult *pr = NULL; InputPlugin *dec = NULL; + TitleInput *tuple = NULL; g_return_val_if_fail(playlist != NULL, FALSE); g_return_val_if_fail(filename != NULL, FALSE); @@ -714,11 +715,21 @@ dec = NULL; else if (!str_has_prefix_nocase(filename, "http://") && !str_has_prefix_nocase(filename, "https://")) - dec = input_check_file(filename, TRUE); + { + pr = input_check_file(filename, TRUE); + + if (pr) + { + dec = pr->ip; + tuple = pr->tuple; + } + + g_free(pr); + } if (cfg.playlist_detect == TRUE || playlist->loading_playlist == TRUE || (playlist->loading_playlist == FALSE && dec != NULL) || (playlist->loading_playlist == FALSE && !is_playlist_name(filename) && str_has_prefix_nocase(filename, "http"))) { - __playlist_ins(playlist, filename, pos, dec); + __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); playlist_generate_shuffle_list(playlist); playlistwin_update_list(playlist); return TRUE; @@ -822,6 +833,7 @@ GDir *dir; GList *list = NULL, *ilist; const gchar *dir_entry; + ProbeResult *pr = NULL; struct stat statbuf; DeviceInode *devino; @@ -878,8 +890,13 @@ } else if (cfg.playlist_detect == TRUE) list = g_list_prepend(list, filename); - else if (input_check_file(filename, TRUE)) + else if ((pr = input_check_file(filename, TRUE)) != NULL) + { list = g_list_prepend(list, filename); + + g_free(pr); + pr = NULL; + } else g_free(filename); @@ -930,7 +947,7 @@ g_hash_table_foreach_remove(htab, devino_destroy, NULL); for (node = list; node; node = g_list_next(node)) { - __playlist_ins(playlist, node->data, pos, NULL); + playlist_ins(playlist, node->data, pos); g_free(node->data); entries++; if (pos >= 0) @@ -1599,7 +1616,7 @@ { gchar *filename; gchar *tmp, *path; - InputPlugin *dec = NULL; /* for decoder cache */ + ProbeResult *pr = NULL; g_return_if_fail(filename_p != NULL); g_return_if_fail(playlist != NULL); @@ -1618,36 +1635,41 @@ else { if ((playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE)) - dec = NULL; + pr = NULL; else if (!str_has_prefix_nocase(filename, "http://") && !str_has_prefix_nocase(filename, "https://")) - dec = input_check_file(filename, FALSE); - - __playlist_ins_with_info(playlist, filename, pos, title, len, dec); + pr = input_check_file(filename, FALSE); + + __playlist_ins_with_info(playlist, filename, pos, title, len, pr ? pr->ip : NULL); + + g_free(pr); return; } tmp = g_build_filename(path, filename, NULL); if (playlist->loading_playlist == TRUE && cfg.playlist_detect == TRUE) - dec = NULL; + pr = NULL; else if (!str_has_prefix_nocase(tmp, "http://") && !str_has_prefix_nocase(tmp, "https://")) - dec = input_check_file(tmp, FALSE); - - __playlist_ins_with_info(playlist, tmp, pos, title, len, dec); + pr = input_check_file(tmp, FALSE); + + __playlist_ins_with_info(playlist, tmp, pos, title, len, pr ? pr->ip : NULL); g_free(tmp); g_free(path); + g_free(pr); } else { if ((playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE)) - dec = NULL; + pr = NULL; else if (!str_has_prefix_nocase(filename, "http://") && !str_has_prefix_nocase(filename, "https://")) - dec = input_check_file(filename, FALSE); - - __playlist_ins_with_info(playlist, filename, pos, title, len, dec); + pr = input_check_file(filename, FALSE); + + __playlist_ins_with_info(playlist, filename, pos, title, len, pr ? pr->ip : NULL); + + g_free(pr); } g_free(filename); @@ -1662,7 +1684,7 @@ { gchar *filename; gchar *tmp, *path; - InputPlugin *dec = NULL; /* for decoder cache */ + ProbeResult *pr = NULL; /* for decoder cache */ g_return_if_fail(filename_p != NULL); g_return_if_fail(playlist_name != NULL); @@ -1681,37 +1703,41 @@ else { if ((playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE)) - dec = NULL; + pr = NULL; else if (!str_has_prefix_nocase(filename, "http://") && !str_has_prefix_nocase(filename, "https://")) - dec = input_check_file(filename, FALSE); - - __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); + pr = input_check_file(filename, FALSE); + + __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, pr ? pr->ip : NULL); + + g_free(pr); return; } tmp = g_build_filename(path, filename, NULL); if ((playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE)) - dec = NULL; + pr = NULL; else if (!str_has_prefix_nocase(filename, "http://") && !str_has_prefix_nocase(filename, "https://")) - dec = input_check_file(filename, FALSE); - - __playlist_ins_with_info_tuple(playlist, tmp, pos, tuple, dec); + pr = input_check_file(filename, FALSE); + + __playlist_ins_with_info_tuple(playlist, tmp, pos, tuple, pr ? pr->ip : NULL); g_free(tmp); g_free(path); + g_free(pr); } else { if ((playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE)) - dec = NULL; + pr = NULL; else if (!str_has_prefix_nocase(filename, "http://") && !str_has_prefix_nocase(filename, "https://")) - dec = input_check_file(filename, FALSE); - - __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); + pr = input_check_file(filename, FALSE); + + __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, pr ? pr->ip : NULL); + g_free(pr); } g_free(filename); @@ -2347,6 +2373,7 @@ GList *node; PlaylistEntry *entry = NULL; TitleInput *tuple = NULL; + ProbeResult *pr = NULL; PLAYLIST_LOCK(playlist->mutex); @@ -2370,7 +2397,12 @@ if (tuple != NULL) { if (entry->decoder == NULL) - entry->decoder = input_check_file(entry->filename, FALSE); /* try to find a decoder */ + { + pr = input_check_file(entry->filename, FALSE); /* try to find a decoder */ + entry->decoder = pr ? pr->ip : NULL; + + g_free(pr); + } if (entry->decoder != NULL && entry->decoder->file_info_box == NULL) fileinfo_show_for_tuple(tuple); diff -r ed6c6aa50c7c -r dfe8f4eb3dba src/audacious/plugin.h --- a/src/audacious/plugin.h Sat Jul 21 00:44:07 2007 +0200 +++ b/src/audacious/plugin.h Fri Jul 20 20:09:08 2007 -0500 @@ -240,6 +240,7 @@ /* Added in Audacious 1.4.0 */ void (*mseek) (InputPlayback * playback, gulong millisecond); + TitleInput *(*probe_for_tuple)(gchar *uri, VFSFile *fd); }; struct _GeneralPlugin {