Mercurial > audlegacy
comparison src/audacious/playlist.c @ 3550:6b0be1d088e6 trunk
- subtune handling is now done in playlist core, using tuple fields subsong-id and subsong-num (requires subtune-able plugins to be updated)
author | Giacomo Lozito <james@develia.org> |
---|---|
date | Tue, 18 Sep 2007 19:00:07 +0200 |
parents | 6f8005df972f |
children | bf2b39567b8c |
comparison
equal
deleted
inserted
replaced
3549:a5b1084e7f38 | 3550:6b0be1d088e6 |
---|---|
666 gint pos, | 666 gint pos, |
667 Tuple *tuple, | 667 Tuple *tuple, |
668 InputPlugin * dec) | 668 InputPlugin * dec) |
669 { | 669 { |
670 PlaylistEntry *entry; | 670 PlaylistEntry *entry; |
671 gint subtunes_num = 0, i = 0; | |
671 | 672 |
672 g_return_if_fail(playlist != NULL); | 673 g_return_if_fail(playlist != NULL); |
673 g_return_if_fail(filename != NULL); | 674 g_return_if_fail(filename != NULL); |
674 | 675 |
675 entry = playlist_entry_new(filename, | 676 if (tuple != NULL) |
676 tuple ? tuple_get_string(tuple, FIELD_TITLE, NULL) : NULL, | 677 { |
677 tuple ? tuple_get_int(tuple, FIELD_LENGTH, NULL) : -1, dec); | 678 subtunes_num = tuple_get_int(tuple, FIELD_SUBSONG_NUM, NULL); |
678 | 679 if ( subtunes_num > 0 ) |
679 if(!playlist->tail) | 680 { |
680 playlist->tail = g_list_last(playlist->entries); | 681 i = 1; |
681 | 682 tuple_free(tuple); /* will be replaced by subtune tuples */ |
682 PLAYLIST_LOCK(playlist); | 683 } |
683 | 684 } |
684 if(pos == -1) { // the common case | 685 |
685 GList *element; | 686 for ( ; i <= subtunes_num ; i++ ) |
686 element = g_list_alloc(); | 687 { |
687 element->data = entry; | 688 gchar *filename_entry; |
688 element->prev = playlist->tail; // NULL is allowed here. | 689 if ( subtunes_num > 0 ) |
689 element->next = NULL; | 690 { |
690 | 691 GString *tmpstr = g_string_new(filename); |
691 if(!playlist->entries) { // this is the first element | 692 g_string_append_printf(tmpstr, "?%i", i); |
692 playlist->entries = element; | 693 filename_entry = tmpstr->str; |
693 playlist->tail = element; | 694 g_string_free(tmpstr, FALSE); |
694 } | 695 |
695 else { // the rests | 696 /* we're dealing with subtune, let's ask again tuple information |
696 g_return_if_fail(playlist->tail != NULL); | 697 to plugin, by passing the ?subsong suffix; this way we may get |
697 playlist->tail->next = element; | 698 specific subtune information in the tuple, if available */ |
698 playlist->tail = element; | 699 tuple = dec->get_song_tuple(filename_entry); |
699 } | 700 } |
700 } | 701 else |
701 else { | 702 { |
702 playlist->entries = g_list_insert(playlist->entries, entry, pos); | 703 filename_entry = g_strdup(filename); |
703 } | 704 } |
704 | 705 |
705 PLAYLIST_UNLOCK(playlist); | 706 entry = playlist_entry_new(filename_entry, |
706 | 707 tuple ? tuple_get_string(tuple, FIELD_TITLE, NULL) : NULL, |
707 if (tuple != NULL) { | 708 tuple ? tuple_get_int(tuple, FIELD_LENGTH, NULL) : -1, dec); |
708 const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL); | 709 g_free(filename_entry); |
709 entry->title = tuple_formatter_make_title_string(tuple, formatter ? | 710 |
710 formatter : get_gentitle_format()); | 711 if(!playlist->tail) |
711 entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL); | 712 playlist->tail = g_list_last(playlist->entries); |
712 entry->tuple = tuple; | 713 |
714 PLAYLIST_LOCK(playlist); | |
715 | |
716 if ((pos == -1) && (i < 2)) { // the common case | |
717 GList *element; | |
718 element = g_list_alloc(); | |
719 element->data = entry; | |
720 element->prev = playlist->tail; // NULL is allowed here. | |
721 element->next = NULL; | |
722 | |
723 if(!playlist->entries) { // this is the first element | |
724 playlist->entries = element; | |
725 playlist->tail = element; | |
726 } | |
727 else { // the rests | |
728 g_return_if_fail(playlist->tail != NULL); | |
729 playlist->tail->next = element; | |
730 playlist->tail = element; | |
731 } | |
732 } | |
733 else { | |
734 playlist->entries = g_list_insert(playlist->entries, entry, pos); | |
735 } | |
736 | |
737 PLAYLIST_UNLOCK(playlist); | |
738 | |
739 if (tuple != NULL) { | |
740 const gchar *formatter = tuple_get_string(tuple, FIELD_FORMATTER, NULL); | |
741 entry->title = tuple_formatter_make_title_string(tuple, formatter ? | |
742 formatter : get_gentitle_format()); | |
743 entry->length = tuple_get_int(tuple, FIELD_LENGTH, NULL); | |
744 entry->tuple = tuple; | |
745 } | |
713 } | 746 } |
714 | 747 |
715 if(tuple != NULL && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1) { // kick the scanner thread only if mtime = -1 (uninitialized). | 748 if(tuple != NULL && tuple_get_int(tuple, FIELD_MTIME, NULL) == -1) { // kick the scanner thread only if mtime = -1 (uninitialized). |
716 g_mutex_lock(mutex_scan); | 749 g_mutex_lock(mutex_scan); |
717 playlist_get_info_scan_active = TRUE; | 750 playlist_get_info_scan_active = TRUE; |