comparison src/audacious/playlist.c @ 3782:a3fc112b10f1

Fix insertion into playlist for plugins that _don't_ have subtunes. Sorry for breaking it. :D
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 18 Oct 2007 17:07:00 +0300
parents ec989c2cde74
children 2c92b8947057
comparison
equal deleted inserted replaced
3780:ec989c2cde74 3782:a3fc112b10f1
677 677
678 if (tuple != NULL) { 678 if (tuple != NULL) {
679 nsubtunes = tuple->nsubtunes; 679 nsubtunes = tuple->nsubtunes;
680 if (nsubtunes > 0) 680 if (nsubtunes > 0)
681 parent_tuple = tuple; 681 parent_tuple = tuple;
682 } else 682 subtune = 1;
683 } else {
683 nsubtunes = 0; 684 nsubtunes = 0;
684 685 subtune = 0;
685 for (subtune = 0; add_flag && subtune < nsubtunes; subtune++) { 686 }
687
688 for (; add_flag && subtune <= nsubtunes; subtune++) {
686 gchar *filename_entry; 689 gchar *filename_entry;
687 690
688 if (nsubtunes > 0) { 691 if (nsubtunes > 0) {
689 filename_entry = g_strdup_printf("%s?%d", filename, 692 filename_entry = g_strdup_printf("%s?%d", filename,
690 parent_tuple->subtunes ? parent_tuple->subtunes[subtune] : subtune + 1); 693 parent_tuple->subtunes ? parent_tuple->subtunes[subtune - 1] : subtune);
691 694
692 /* We're dealing with subtune, let's ask again tuple information 695 /* We're dealing with subtune, let's ask again tuple information
693 * to plugin, by passing the ?subtune suffix; this way we get 696 * to plugin, by passing the ?subtune suffix; this way we get
694 * specific subtune information in the tuple, if available. 697 * specific subtune information in the tuple, if available.
695 */ 698 */
706 if (!playlist->tail) 709 if (!playlist->tail)
707 playlist->tail = g_list_last(playlist->entries); 710 playlist->tail = g_list_last(playlist->entries);
708 711
709 PLAYLIST_LOCK(playlist); 712 PLAYLIST_LOCK(playlist);
710 713
711 if (pos == -1 && subtune < 1 && nsubtunes < 1) { // the common case 714 if (pos == -1) { // the common case
712 GList *element; 715 GList *element;
713 element = g_list_alloc(); 716 element = g_list_alloc();
714 element->data = entry; 717 element->data = entry;
715 element->prev = playlist->tail; // NULL is allowed here. 718 element->prev = playlist->tail; // NULL is allowed here.
716 element->next = NULL; 719 element->next = NULL;
723 playlist->tail->next = element; 726 playlist->tail->next = element;
724 playlist->tail = element; 727 playlist->tail = element;
725 } else 728 } else
726 add_flag = FALSE; 729 add_flag = FALSE;
727 } 730 }
728 } else { 731 } else
729 playlist->entries = g_list_insert(playlist->entries, entry, pos); 732 playlist->entries = g_list_insert(playlist->entries, entry, pos++);
730 } 733
731
732 PLAYLIST_UNLOCK(playlist);
733
734 if (tuple != NULL) { 734 if (tuple != NULL) {
735 const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL); 735 const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL);
736 entry->title = tuple_formatter_make_title_string(tuple, 736 entry->title = tuple_formatter_make_title_string(tuple,
737 formatter ? formatter : get_gentitle_format()); 737 formatter ? formatter : get_gentitle_format());
738 entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL); 738 entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL);
739 entry->tuple = tuple; 739 entry->tuple = tuple;
740 } 740 }
741 } 741
742 PLAYLIST_UNLOCK(playlist);
743 }
744
742 745
743 if (parent_tuple) 746 if (parent_tuple)
744 tuple_free(parent_tuple); 747 tuple_free(parent_tuple);
745 748
746 if (tuple != NULL && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1) { 749 if (tuple != NULL && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1) {