comparison src/audacious/playlist.c @ 3127:c92070f10148 trunk

Use ProbeResult (try 1)
author William Pitcock <nenolod@atheme-project.org>
date Fri, 20 Jul 2007 19:37:11 -0500
parents f1c756f39e6c
children 343504d43afc
comparison
equal deleted inserted replaced
3126:ce5c6a5d64e2 3127:c92070f10148
187 187
188 static gboolean 188 static gboolean
189 playlist_entry_get_info(PlaylistEntry * entry) 189 playlist_entry_get_info(PlaylistEntry * entry)
190 { 190 {
191 TitleInput *tuple; 191 TitleInput *tuple;
192 ProbeResult *pr = NULL;
192 time_t modtime; 193 time_t modtime;
193 194
194 g_return_val_if_fail(entry != NULL, FALSE); 195 g_return_val_if_fail(entry != NULL, FALSE);
195 196
196 if (entry->tuple == NULL || entry->tuple->mtime > 0 || entry->tuple->mtime == -1) 197 if (entry->tuple == NULL || entry->tuple->mtime > 0 || entry->tuple->mtime == -1)
204 g_print("attempting to retrieve remote info not in background thread!\n"); 205 g_print("attempting to retrieve remote info not in background thread!\n");
205 return FALSE; 206 return FALSE;
206 } 207 }
207 208
208 if (entry->decoder == NULL) 209 if (entry->decoder == NULL)
209 entry->decoder = input_check_file(entry->filename, FALSE); 210 {
211 pr = input_check_file(entry->filename, FALSE);
212 entry->decoder = pr->ip;
213 }
210 214
211 /* renew tuple if file mtime is newer than tuple mtime. */ 215 /* renew tuple if file mtime is newer than tuple mtime. */
212 if(entry->tuple){ 216 if(entry->tuple){
213 if(entry->tuple->mtime == modtime) 217 if(entry->tuple->mtime == modtime)
214 return TRUE; 218 return TRUE;
216 bmp_title_input_free(entry->tuple); 220 bmp_title_input_free(entry->tuple);
217 entry->tuple = NULL; 221 entry->tuple = NULL;
218 } 222 }
219 } 223 }
220 224
221 if (entry->decoder == NULL || entry->decoder->get_song_tuple == NULL) 225 if (pr != NULL && pr->tuple != NULL)
222 tuple = input_get_song_tuple(entry->filename); 226 tuple = pr->tuple;
223 else 227 else if (entry->decoder != NULL && entry->decoder->get_song_tuple != NULL)
224 tuple = entry->decoder->get_song_tuple(entry->filename); 228 tuple = entry->decoder->get_song_tuple(entry->filename);
225 229
226 if (tuple == NULL) 230 if (tuple == NULL)
227 return FALSE; 231 return FALSE;
228 232
231 235
232 /* entry is still around */ 236 /* entry is still around */
233 entry->title = xmms_get_titlestring(tuple->formatter != NULL ? tuple->formatter : xmms_get_gentitle_format(), tuple); 237 entry->title = xmms_get_titlestring(tuple->formatter != NULL ? tuple->formatter : xmms_get_gentitle_format(), tuple);
234 entry->length = tuple->length; 238 entry->length = tuple->length;
235 entry->tuple = tuple; 239 entry->tuple = tuple;
240
241 g_free(pr);
236 242
237 return TRUE; 243 return TRUE;
238 } 244 }
239 245
240 /* *********************** playlist selector code ************************* */ 246 /* *********************** playlist selector code ************************* */
696 playlist_ins(Playlist * playlist, const gchar * filename, gint pos) 702 playlist_ins(Playlist * playlist, const gchar * filename, gint pos)
697 { 703 {
698 gchar buf[64], *p; 704 gchar buf[64], *p;
699 gint r; 705 gint r;
700 VFSFile *file; 706 VFSFile *file;
707 ProbeResult *pr = NULL;
701 InputPlugin *dec = NULL; 708 InputPlugin *dec = NULL;
709 TitleInput *tuple = NULL;
702 710
703 g_return_val_if_fail(playlist != NULL, FALSE); 711 g_return_val_if_fail(playlist != NULL, FALSE);
704 g_return_val_if_fail(filename != NULL, FALSE); 712 g_return_val_if_fail(filename != NULL, FALSE);
705 713
706 if (is_playlist_name(filename)) { 714 if (is_playlist_name(filename)) {
712 720
713 if (playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE) 721 if (playlist->loading_playlist == TRUE || cfg.playlist_detect == TRUE)
714 dec = NULL; 722 dec = NULL;
715 else if (!str_has_prefix_nocase(filename, "http://") && 723 else if (!str_has_prefix_nocase(filename, "http://") &&
716 !str_has_prefix_nocase(filename, "https://")) 724 !str_has_prefix_nocase(filename, "https://"))
717 dec = input_check_file(filename, TRUE); 725 {
726 pr = input_check_file(filename, TRUE);
727
728 if (pr)
729 {
730 dec = pr->ip;
731 tuple = pr->tuple;
732 }
733
734 g_free(pr);
735 }
718 736
719 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"))) 737 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")))
720 { 738 {
721 __playlist_ins(playlist, filename, pos, dec); 739 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec);
722 playlist_generate_shuffle_list(playlist); 740 playlist_generate_shuffle_list(playlist);
723 playlistwin_update_list(playlist); 741 playlistwin_update_list(playlist);
724 return TRUE; 742 return TRUE;
725 } 743 }
726 744
820 GHashTable * htab) 838 GHashTable * htab)
821 { 839 {
822 GDir *dir; 840 GDir *dir;
823 GList *list = NULL, *ilist; 841 GList *list = NULL, *ilist;
824 const gchar *dir_entry; 842 const gchar *dir_entry;
843 ProbeResult *pr = NULL;
825 844
826 struct stat statbuf; 845 struct stat statbuf;
827 DeviceInode *devino; 846 DeviceInode *devino;
828 847
829 if (!path) 848 if (!path)
876 g_free(filename); 895 g_free(filename);
877 list = g_list_concat(list, sub); 896 list = g_list_concat(list, sub);
878 } 897 }
879 else if (cfg.playlist_detect == TRUE) 898 else if (cfg.playlist_detect == TRUE)
880 list = g_list_prepend(list, filename); 899 list = g_list_prepend(list, filename);
881 else if (input_check_file(filename, TRUE)) 900 else if ((pr = input_check_file(filename, TRUE)) != NULL)
901 {
882 list = g_list_prepend(list, filename); 902 list = g_list_prepend(list, filename);
903
904 g_free(pr);
905 pr = NULL;
906 }
883 else 907 else
884 g_free(filename); 908 g_free(filename);
885 909
886 while (background && gtk_events_pending()) 910 while (background && gtk_events_pending())
887 gtk_main_iteration(); 911 gtk_main_iteration();
1597 const gchar * playlist_name, gint pos, 1621 const gchar * playlist_name, gint pos,
1598 const gchar * title, gint len) 1622 const gchar * title, gint len)
1599 { 1623 {
1600 gchar *filename; 1624 gchar *filename;
1601 gchar *tmp, *path; 1625 gchar *tmp, *path;
1602 InputPlugin *dec = NULL; /* for decoder cache */ 1626 ProbeResult *pr = NULL;
1603 1627
1604 g_return_if_fail(filename_p != NULL); 1628 g_return_if_fail(filename_p != NULL);
1605 g_return_if_fail(playlist != NULL); 1629 g_return_if_fail(playlist != NULL);
1606 g_return_if_fail(playlist_name != NULL); 1630 g_return_if_fail(playlist_name != NULL);
1607 1631
1616 if ((tmp = strrchr(path, '/'))) 1640 if ((tmp = strrchr(path, '/')))
1617 *tmp = '\0'; 1641 *tmp = '\0';
1618 else { 1642 else {
1619 if ((playlist->loading_playlist == TRUE || 1643 if ((playlist->loading_playlist == TRUE ||
1620 cfg.playlist_detect == TRUE)) 1644 cfg.playlist_detect == TRUE))
1621 dec = NULL; 1645 pr = NULL;
1622 else if (!str_has_prefix_nocase(filename, "http://") && 1646 else if (!str_has_prefix_nocase(filename, "http://") &&
1623 !str_has_prefix_nocase(filename, "https://")) 1647 !str_has_prefix_nocase(filename, "https://"))
1624 dec = input_check_file(filename, FALSE); 1648 pr = input_check_file(filename, FALSE);
1625 1649
1626 __playlist_ins_with_info(playlist, filename, pos, title, len, dec); 1650 __playlist_ins_with_info(playlist, filename, pos, title, len, pr ? pr->ip : NULL);
1651
1652 g_free(pr);
1627 return; 1653 return;
1628 } 1654 }
1629 tmp = g_build_filename(path, filename, NULL); 1655 tmp = g_build_filename(path, filename, NULL);
1630 1656
1631 if (playlist->loading_playlist == TRUE && cfg.playlist_detect == TRUE) 1657 if (playlist->loading_playlist == TRUE && cfg.playlist_detect == TRUE)
1632 dec = NULL; 1658 pr = NULL;
1633 else if (!str_has_prefix_nocase(tmp, "http://") && 1659 else if (!str_has_prefix_nocase(tmp, "http://") &&
1634 !str_has_prefix_nocase(tmp, "https://")) 1660 !str_has_prefix_nocase(tmp, "https://"))
1635 dec = input_check_file(tmp, FALSE); 1661 pr = input_check_file(tmp, FALSE);
1636 1662
1637 __playlist_ins_with_info(playlist, tmp, pos, title, len, dec); 1663 __playlist_ins_with_info(playlist, tmp, pos, title, len, dec, pr ? pr->ip : NULL);
1638 g_free(tmp); 1664 g_free(tmp);
1639 g_free(path); 1665 g_free(path);
1666 g_free(pr);
1640 } 1667 }
1641 else 1668 else
1642 { 1669 {
1643 if ((playlist->loading_playlist == TRUE || 1670 if ((playlist->loading_playlist == TRUE ||
1644 cfg.playlist_detect == TRUE)) 1671 cfg.playlist_detect == TRUE))
1645 dec = NULL; 1672 pr = NULL;
1646 else if (!str_has_prefix_nocase(filename, "http://") && 1673 else if (!str_has_prefix_nocase(filename, "http://") &&
1647 !str_has_prefix_nocase(filename, "https://")) 1674 !str_has_prefix_nocase(filename, "https://"))
1648 dec = input_check_file(filename, FALSE); 1675 pr = input_check_file(filename, FALSE);
1649 1676
1650 __playlist_ins_with_info(playlist, filename, pos, title, len, dec); 1677 __playlist_ins_with_info(playlist, filename, pos, title, len, pr ? pr->ip : NULL);
1678
1679 g_free(pr);
1651 } 1680 }
1652 1681
1653 g_free(filename); 1682 g_free(filename);
1654 } 1683 }
1655 1684
1660 gint pos, 1689 gint pos,
1661 TitleInput *tuple) 1690 TitleInput *tuple)
1662 { 1691 {
1663 gchar *filename; 1692 gchar *filename;
1664 gchar *tmp, *path; 1693 gchar *tmp, *path;
1665 InputPlugin *dec = NULL; /* for decoder cache */ 1694 ProbeResult *pr = NULL; /* for decoder cache */
1666 1695
1667 g_return_if_fail(filename_p != NULL); 1696 g_return_if_fail(filename_p != NULL);
1668 g_return_if_fail(playlist_name != NULL); 1697 g_return_if_fail(playlist_name != NULL);
1669 g_return_if_fail(playlist != NULL); 1698 g_return_if_fail(playlist != NULL);
1670 1699
1679 if ((tmp = strrchr(path, '/'))) 1708 if ((tmp = strrchr(path, '/')))
1680 *tmp = '\0'; 1709 *tmp = '\0';
1681 else { 1710 else {
1682 if ((playlist->loading_playlist == TRUE || 1711 if ((playlist->loading_playlist == TRUE ||
1683 cfg.playlist_detect == TRUE)) 1712 cfg.playlist_detect == TRUE))
1684 dec = NULL; 1713 pr = NULL;
1685 else if (!str_has_prefix_nocase(filename, "http://") && 1714 else if (!str_has_prefix_nocase(filename, "http://") &&
1686 !str_has_prefix_nocase(filename, "https://")) 1715 !str_has_prefix_nocase(filename, "https://"))
1687 dec = input_check_file(filename, FALSE); 1716 pr = input_check_file(filename, FALSE);
1688 1717
1689 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); 1718 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, pr ? pr->ip : NULL);
1719
1720 g_free(pr);
1690 return; 1721 return;
1691 } 1722 }
1692 tmp = g_build_filename(path, filename, NULL); 1723 tmp = g_build_filename(path, filename, NULL);
1693 1724
1694 if ((playlist->loading_playlist == TRUE || 1725 if ((playlist->loading_playlist == TRUE ||
1695 cfg.playlist_detect == TRUE)) 1726 cfg.playlist_detect == TRUE))
1696 dec = NULL; 1727 pr = NULL;
1697 else if (!str_has_prefix_nocase(filename, "http://") && 1728 else if (!str_has_prefix_nocase(filename, "http://") &&
1698 !str_has_prefix_nocase(filename, "https://")) 1729 !str_has_prefix_nocase(filename, "https://"))
1699 dec = input_check_file(filename, FALSE); 1730 pr = input_check_file(filename, FALSE);
1700 1731
1701 __playlist_ins_with_info_tuple(playlist, tmp, pos, tuple, dec); 1732 __playlist_ins_with_info_tuple(playlist, tmp, pos, tuple, pr ? pr->ip : NULL);
1702 g_free(tmp); 1733 g_free(tmp);
1703 g_free(path); 1734 g_free(path);
1735 g_free(pr);
1704 } 1736 }
1705 else 1737 else
1706 { 1738 {
1707 if ((playlist->loading_playlist == TRUE || 1739 if ((playlist->loading_playlist == TRUE ||
1708 cfg.playlist_detect == TRUE)) 1740 cfg.playlist_detect == TRUE))
1709 dec = NULL; 1741 pr = NULL;
1710 else if (!str_has_prefix_nocase(filename, "http://") && 1742 else if (!str_has_prefix_nocase(filename, "http://") &&
1711 !str_has_prefix_nocase(filename, "https://")) 1743 !str_has_prefix_nocase(filename, "https://"))
1712 dec = input_check_file(filename, FALSE); 1744 pr = input_check_file(filename, FALSE);
1713 1745
1714 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, dec); 1746 __playlist_ins_with_info_tuple(playlist, filename, pos, tuple, pr ? pr->ip : NULL);
1747 g_free(pr);
1715 } 1748 }
1716 1749
1717 g_free(filename); 1750 g_free(filename);
1718 } 1751 }
1719 1752
2345 { 2378 {
2346 gchar *path = NULL; 2379 gchar *path = NULL;
2347 GList *node; 2380 GList *node;
2348 PlaylistEntry *entry = NULL; 2381 PlaylistEntry *entry = NULL;
2349 TitleInput *tuple = NULL; 2382 TitleInput *tuple = NULL;
2383 ProbeResult *pr = NULL;
2350 2384
2351 PLAYLIST_LOCK(playlist->mutex); 2385 PLAYLIST_LOCK(playlist->mutex);
2352 2386
2353 if ((node = g_list_nth(playlist->entries, pos))) 2387 if ((node = g_list_nth(playlist->entries, pos)))
2354 { 2388 {
2368 } 2402 }
2369 2403
2370 if (tuple != NULL) 2404 if (tuple != NULL)
2371 { 2405 {
2372 if (entry->decoder == NULL) 2406 if (entry->decoder == NULL)
2373 entry->decoder = input_check_file(entry->filename, FALSE); /* try to find a decoder */ 2407 {
2408 pr = input_check_file(entry->filename, FALSE); /* try to find a decoder */
2409 entry->decoder = pr ? pr->ip : NULL;
2410
2411 g_free(pr);
2412 }
2374 2413
2375 if (entry->decoder != NULL && entry->decoder->file_info_box == NULL) 2414 if (entry->decoder != NULL && entry->decoder->file_info_box == NULL)
2376 fileinfo_show_for_tuple(tuple); 2415 fileinfo_show_for_tuple(tuple);
2377 else if (entry->decoder != NULL && entry->decoder->file_info_box != NULL) 2416 else if (entry->decoder != NULL && entry->decoder->file_info_box != NULL)
2378 entry->decoder->file_info_box(path); 2417 entry->decoder->file_info_box(path);