summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/screens.c73
1 files changed, 44 insertions, 29 deletions
diff --git a/apps/screens.c b/apps/screens.c
index 32edae2f75..d8ce695a9a 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -717,103 +717,108 @@ static const int id3_headers[]=
717#endif 717#endif
718 LANG_ID3_PATH, 718 LANG_ID3_PATH,
719}; 719};
720 720struct id3view_info {
721 struct mp3entry* id3;
722 int count;
723 int info_id[sizeof(id3_headers)/sizeof(id3_headers[0])];
724};
721static char * id3_get_info(int selected_item, void* data, 725static char * id3_get_info(int selected_item, void* data,
722 char *buffer, size_t buffer_len) 726 char *buffer, size_t buffer_len)
723{ 727{
724 struct mp3entry* id3 =(struct mp3entry*)data; 728 struct id3view_info *info = (struct id3view_info*)data;
729 struct mp3entry* id3 =info->id3;
725 int info_no=selected_item/2; 730 int info_no=selected_item/2;
726 if(!(selected_item%2)) 731 if(!(selected_item%2))
727 {/* header */ 732 {/* header */
728 return( str(id3_headers[info_no])); 733 return( str(id3_headers[info->info_id[info_no]]));
729 } 734 }
730 else 735 else
731 {/* data */ 736 {/* data */
732 737
733 char * info=NULL; 738 char * val=NULL;
734 switch(info_no) 739 switch(info->info_id[info_no])
735 { 740 {
736 case 0:/*LANG_ID3_TITLE*/ 741 case 0:/*LANG_ID3_TITLE*/
737 info=id3->title; 742 val=id3->title;
738 break; 743 break;
739 case 1:/*LANG_ID3_ARTIST*/ 744 case 1:/*LANG_ID3_ARTIST*/
740 info=id3->artist; 745 val=id3->artist;
741 break; 746 break;
742 case 2:/*LANG_ID3_ALBUM*/ 747 case 2:/*LANG_ID3_ALBUM*/
743 info=id3->album; 748 val=id3->album;
744 break; 749 break;
745 case 3:/*LANG_ID3_ALBUMARTIST*/ 750 case 3:/*LANG_ID3_ALBUMARTIST*/
746 info=id3->albumartist; 751 val=id3->albumartist;
747 break; 752 break;
748 case 4:/*LANG_ID3_GROUPING*/ 753 case 4:/*LANG_ID3_GROUPING*/
749 info=id3->grouping; 754 val=id3->grouping;
750 break; 755 break;
751 case 5:/*LANG_ID3_DISCNUM*/ 756 case 5:/*LANG_ID3_DISCNUM*/
752 if (id3->disc_string) 757 if (id3->disc_string)
753 info = id3->disc_string; 758 val = id3->disc_string;
754 else if (id3->discnum) 759 else if (id3->discnum)
755 { 760 {
756 snprintf(buffer, buffer_len, "%d", id3->discnum); 761 snprintf(buffer, buffer_len, "%d", id3->discnum);
757 info = buffer; 762 val = buffer;
758 } 763 }
759 break; 764 break;
760 case 6:/*LANG_ID3_TRACKNUM*/ 765 case 6:/*LANG_ID3_TRACKNUM*/
761 if (id3->track_string) 766 if (id3->track_string)
762 info = id3->track_string; 767 val = id3->track_string;
763 else if (id3->tracknum) 768 else if (id3->tracknum)
764 { 769 {
765 snprintf(buffer, buffer_len, "%d", id3->tracknum); 770 snprintf(buffer, buffer_len, "%d", id3->tracknum);
766 info = buffer; 771 val = buffer;
767 } 772 }
768 break; 773 break;
769 case 7:/*LANG_ID3_COMMENT*/ 774 case 7:/*LANG_ID3_COMMENT*/
770 info=id3->comment; 775 val=id3->comment;
771 break; 776 break;
772 case 8:/*LANG_ID3_GENRE*/ 777 case 8:/*LANG_ID3_GENRE*/
773 info = id3->genre_string; 778 val = id3->genre_string;
774 break; 779 break;
775 case 9:/*LANG_ID3_YEAR*/ 780 case 9:/*LANG_ID3_YEAR*/
776 if (id3->year_string) 781 if (id3->year_string)
777 info = id3->year_string; 782 val = id3->year_string;
778 else if (id3->year) 783 else if (id3->year)
779 { 784 {
780 snprintf(buffer, buffer_len, "%d", id3->year); 785 snprintf(buffer, buffer_len, "%d", id3->year);
781 info = buffer; 786 val = buffer;
782 } 787 }
783 break; 788 break;
784 case 10:/*LANG_ID3_LENGTH*/ 789 case 10:/*LANG_ID3_LENGTH*/
785 format_time(buffer, buffer_len, id3->length); 790 format_time(buffer, buffer_len, id3->length);
786 info=buffer; 791 val=buffer;
787 break; 792 break;
788 case 11:/*LANG_ID3_PLAYLIST*/ 793 case 11:/*LANG_ID3_PLAYLIST*/
789 snprintf(buffer, buffer_len, "%d/%d", 794 snprintf(buffer, buffer_len, "%d/%d",
790 playlist_get_display_index(), playlist_amount()); 795 playlist_get_display_index(), playlist_amount());
791 info=buffer; 796 val=buffer;
792 break; 797 break;
793 case 12:/*LANG_ID3_BITRATE*/ 798 case 12:/*LANG_ID3_BITRATE*/
794 snprintf(buffer, buffer_len, "%d kbps%s", id3->bitrate, 799 snprintf(buffer, buffer_len, "%d kbps%s", id3->bitrate,
795 id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) ""); 800 id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) "");
796 info=buffer; 801 val=buffer;
797 break; 802 break;
798 case 13:/*LANG_ID3_FREQUENCY*/ 803 case 13:/*LANG_ID3_FREQUENCY*/
799 snprintf(buffer, buffer_len, "%ld Hz", id3->frequency); 804 snprintf(buffer, buffer_len, "%ld Hz", id3->frequency);
800 info=buffer; 805 val=buffer;
801 break; 806 break;
802#if CONFIG_CODEC == SWCODEC 807#if CONFIG_CODEC == SWCODEC
803 case 14:/*LANG_ID3_TRACK_GAIN*/ 808 case 14:/*LANG_ID3_TRACK_GAIN*/
804 info=id3->track_gain_string; 809 val=id3->track_gain_string;
805 break; 810 break;
806 case 15:/*LANG_ID3_ALBUM_GAIN*/ 811 case 15:/*LANG_ID3_ALBUM_GAIN*/
807 info=id3->album_gain_string; 812 val=id3->album_gain_string;
808 break; 813 break;
809 case 16:/*LANG_ID3_PATH*/ 814 case 16:/*LANG_ID3_PATH*/
810#else 815#else
811 case 14:/*LANG_ID3_PATH*/ 816 case 14:/*LANG_ID3_PATH*/
812#endif 817#endif
813 info=id3->path; 818 val=id3->path;
814 break; 819 break;
815 } 820 }
816 return info && *info ? info : (char*) str(LANG_ID3_NO_INFO); 821 return val && *val ? val : NULL;
817 } 822 }
818} 823}
819 824
@@ -822,10 +827,20 @@ bool browse_id3(void)
822 struct gui_synclist id3_lists; 827 struct gui_synclist id3_lists;
823 struct mp3entry* id3 = audio_current_track(); 828 struct mp3entry* id3 = audio_current_track();
824 int key; 829 int key;
830 unsigned int i;
831 struct id3view_info info;
832 info.count = 0;
833 info.id3 = id3;
834 for (i=0; i<sizeof(id3_headers)/sizeof(id3_headers[0]); i++)
835 {
836 char temp[8];
837 info.info_id[i] = i;
838 if (id3_get_info((i*2)+1, &info, temp, 8) != NULL)
839 info.info_id[info.count++] = i;
840 }
825 841
826 gui_synclist_init(&id3_lists, &id3_get_info, id3, true, 2, NULL); 842 gui_synclist_init(&id3_lists, &id3_get_info, &info, true, 2, NULL);
827 gui_synclist_set_nb_items(&id3_lists, 843 gui_synclist_set_nb_items(&id3_lists, info.count*2);
828 sizeof(id3_headers)/sizeof(id3_headers[0])*2);
829 gui_synclist_draw(&id3_lists); 844 gui_synclist_draw(&id3_lists);
830 gui_syncstatusbar_draw(&statusbars, true); 845 gui_syncstatusbar_draw(&statusbars, true);
831 while (true) { 846 while (true) {