# HG changeset patch # User William Pitcock # Date 1184978231 18000 # Node ID c92070f1014846798efbc5eb955512ae6386a26a # Parent ce5c6a5d64e23f58a6dd0ca21c3cce04a4c4ac20 Use ProbeResult (try 1) diff -r ce5c6a5d64e2 -r c92070f10148 src/audacious/input.c --- a/src/audacious/input.c Fri Jul 20 18:55:15 2007 -0500 +++ b/src/audacious/input.c Fri Jul 20 19:37:11 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); @@ -399,7 +404,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 +428,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 +443,11 @@ { g_free(filename_proxy); vfs_fclose(fd); - return ip; + + pr = g_new0(ProbeResult, 1); + pr->ip = ip; + + return pr; } } @@ -454,6 +483,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 +491,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 +540,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; + + ip = pr->ip; + + g_free(pr); if (ip && ip->get_song_tuple) input = ip->get_song_tuple(filename_proxy); @@ -613,10 +658,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 ce5c6a5d64e2 -r c92070f10148 src/audacious/input.h --- a/src/audacious/input.h Fri Jul 20 18:55:15 2007 -0500 +++ b/src/audacious/input.h Fri Jul 20 19:37:11 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 ce5c6a5d64e2 -r c92070f10148 src/audacious/playback.c --- a/src/audacious/playback.c Fri Jul 20 18:55:15 2007 -0500 +++ b/src/audacious/playback.c Fri Jul 20 19:37:11 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)) { set_current_input_playback(NULL); mainwin_set_info_text(); diff -r ce5c6a5d64e2 -r c92070f10148 src/audacious/playlist.c --- a/src/audacious/playlist.c Fri Jul 20 18:55:15 2007 -0500 +++ b/src/audacious/playlist.c Fri Jul 20 19:37:11 2007 -0500 @@ -189,6 +189,7 @@ playlist_entry_get_info(PlaylistEntry * entry) { TitleInput *tuple; + ProbeResult *pr = NULL; time_t modtime; g_return_val_if_fail(entry != NULL, FALSE); @@ -206,7 +207,10 @@ } if (entry->decoder == NULL) - entry->decoder = input_check_file(entry->filename, FALSE); + { + pr = input_check_file(entry->filename, FALSE); + entry->decoder = pr->ip; + } /* renew tuple if file mtime is newer than tuple mtime. */ if(entry->tuple){ @@ -218,9 +222,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 +238,8 @@ entry->length = tuple->length; entry->tuple = tuple; + g_free(pr); + return TRUE; } @@ -698,7 +704,9 @@ 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 +722,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 +840,7 @@ GDir *dir; GList *list = NULL, *ilist; const gchar *dir_entry; + ProbeResult *pr = NULL; struct stat statbuf; DeviceInode *devino; @@ -878,8 +897,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); @@ -1599,7 +1623,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 +1642,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, dec, 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 +1691,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 +1710,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 +2380,7 @@ GList *node; PlaylistEntry *entry = NULL; TitleInput *tuple = NULL; + ProbeResult *pr = NULL; PLAYLIST_LOCK(playlist->mutex); @@ -2370,7 +2404,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);