diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/gwps-common.c | 14 | ||||
-rw-r--r-- | apps/gui/gwps.c | 15 | ||||
-rw-r--r-- | apps/gui/gwps.h | 42 | ||||
-rw-r--r-- | apps/gui/wps_parser.c | 225 |
4 files changed, 296 insertions, 0 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index fec13d564f..3c29884260 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -48,6 +48,7 @@ | |||
48 | /* Image stuff */ | 48 | /* Image stuff */ |
49 | #include "bmp.h" | 49 | #include "bmp.h" |
50 | #include "atoi.h" | 50 | #include "atoi.h" |
51 | #include "albumart.h" | ||
51 | #endif | 52 | #endif |
52 | #include "dsp.h" | 53 | #include "dsp.h" |
53 | #include "action.h" | 54 | #include "action.h" |
@@ -929,6 +930,19 @@ static char *get_token_value(struct gui_wps *gwps, | |||
929 | case WPS_TOKEN_METADATA_COMMENT: | 930 | case WPS_TOKEN_METADATA_COMMENT: |
930 | return id3->comment; | 931 | return id3->comment; |
931 | 932 | ||
933 | #ifdef HAVE_ALBUMART | ||
934 | case WPS_TOKEN_ALBUMART_DISPLAY: | ||
935 | draw_album_art(gwps, audio_current_aa_hid()); | ||
936 | return NULL; | ||
937 | |||
938 | case WPS_TOKEN_ALBUMART_FOUND: | ||
939 | if (audio_current_aa_hid() >= 0) { | ||
940 | snprintf(buf, buf_size, "C"); | ||
941 | return buf; | ||
942 | } | ||
943 | return NULL; | ||
944 | #endif | ||
945 | |||
932 | case WPS_TOKEN_FILE_BITRATE: | 946 | case WPS_TOKEN_FILE_BITRATE: |
933 | if(id3->bitrate) | 947 | if(id3->bitrate) |
934 | snprintf(buf, buf_size, "%d", id3->bitrate); | 948 | snprintf(buf, buf_size, "%d", id3->bitrate); |
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index b7707cdd0d..ad9fce7a8f 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c | |||
@@ -796,3 +796,18 @@ void gui_sync_wps_init(void) | |||
796 | unload_remote_wps_backdrop(); | 796 | unload_remote_wps_backdrop(); |
797 | #endif | 797 | #endif |
798 | } | 798 | } |
799 | |||
800 | #ifdef HAVE_ALBUMART | ||
801 | /* Returns true if at least one of the gui_wps screens has an album art | ||
802 | tag in its wps structure */ | ||
803 | bool gui_sync_wps_uses_albumart(void) | ||
804 | { | ||
805 | int i; | ||
806 | FOR_NB_SCREENS(i) { | ||
807 | struct gui_wps *gwps = &gui_wps[i]; | ||
808 | if (gwps->data && (gwps->data->wps_uses_albumart != WPS_ALBUMART_NONE)) | ||
809 | return true; | ||
810 | } | ||
811 | return false; | ||
812 | } | ||
813 | #endif | ||
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index 83ff14b80b..391fc72943 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h | |||
@@ -39,6 +39,23 @@ | |||
39 | #define WPS_ALIGN_CENTER 64 | 39 | #define WPS_ALIGN_CENTER 64 |
40 | #define WPS_ALIGN_LEFT 128 | 40 | #define WPS_ALIGN_LEFT 128 |
41 | 41 | ||
42 | #ifdef HAVE_ALBUMART | ||
43 | |||
44 | /* albumart definitions */ | ||
45 | #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */ | ||
46 | #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */ | ||
47 | #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */ | ||
48 | |||
49 | #define WPS_ALBUMART_ALIGN_RIGHT WPS_ALIGN_RIGHT /* x align: right */ | ||
50 | #define WPS_ALBUMART_ALIGN_CENTER WPS_ALIGN_CENTER /* x/y align: center */ | ||
51 | #define WPS_ALBUMART_ALIGN_LEFT WPS_ALIGN_LEFT /* x align: left */ | ||
52 | #define WPS_ALBUMART_ALIGN_TOP WPS_ALIGN_RIGHT /* y align: top */ | ||
53 | #define WPS_ALBUMART_ALIGN_BOTTOM WPS_ALIGN_LEFT /* y align: bottom */ | ||
54 | #define WPS_ALBUMART_INCREASE 8 /* increase if smaller */ | ||
55 | #define WPS_ALBUMART_DECREASE 16 /* decrease if larger */ | ||
56 | |||
57 | #endif /* HAVE_ALBUMART */ | ||
58 | |||
42 | /* wps_data*/ | 59 | /* wps_data*/ |
43 | 60 | ||
44 | #ifdef HAVE_LCD_BITMAP | 61 | #ifdef HAVE_LCD_BITMAP |
@@ -187,6 +204,12 @@ enum wps_token_type { | |||
187 | WPS_TOKEN_IMAGE_DISPLAY, | 204 | WPS_TOKEN_IMAGE_DISPLAY, |
188 | #endif | 205 | #endif |
189 | 206 | ||
207 | #ifdef HAVE_ALBUMART | ||
208 | /* Albumart */ | ||
209 | WPS_TOKEN_ALBUMART_DISPLAY, | ||
210 | WPS_TOKEN_ALBUMART_FOUND, | ||
211 | #endif | ||
212 | |||
190 | /* Metadata */ | 213 | /* Metadata */ |
191 | WPS_TOKEN_METADATA_ARTIST, | 214 | WPS_TOKEN_METADATA_ARTIST, |
192 | WPS_TOKEN_METADATA_COMPOSER, | 215 | WPS_TOKEN_METADATA_COMPOSER, |
@@ -309,6 +332,20 @@ struct wps_data | |||
309 | short progress_start; | 332 | short progress_start; |
310 | short progress_end; | 333 | short progress_end; |
311 | bool peak_meter_enabled; | 334 | bool peak_meter_enabled; |
335 | |||
336 | #ifdef HAVE_ALBUMART | ||
337 | /* Album art support */ | ||
338 | unsigned char wps_uses_albumart; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */ | ||
339 | short albumart_x; | ||
340 | short albumart_y; | ||
341 | unsigned short albumart_xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT, | ||
342 | + .._INCREASE, + .._DECREASE */ | ||
343 | unsigned short albumart_yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM, | ||
344 | + .._INCREASE, + .._DECREASE */ | ||
345 | short albumart_max_width; | ||
346 | short albumart_max_height; | ||
347 | #endif | ||
348 | |||
312 | #else /*HAVE_LCD_CHARCELLS */ | 349 | #else /*HAVE_LCD_CHARCELLS */ |
313 | unsigned short wps_progress_pat[8]; | 350 | unsigned short wps_progress_pat[8]; |
314 | bool full_line_progressbar; | 351 | bool full_line_progressbar; |
@@ -417,4 +454,9 @@ extern struct gui_wps gui_wps[NB_SCREENS]; | |||
417 | void gui_sync_wps_init(void); | 454 | void gui_sync_wps_init(void); |
418 | void gui_sync_wps_screen_init(void); | 455 | void gui_sync_wps_screen_init(void); |
419 | 456 | ||
457 | #ifdef HAVE_ALBUMART | ||
458 | /* gives back if WPS contains an albumart tag */ | ||
459 | bool gui_sync_wps_uses_albumart(void); | ||
460 | #endif | ||
461 | |||
420 | #endif | 462 | #endif |
diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index 8471bff7d8..097a60c90f 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c | |||
@@ -113,6 +113,7 @@ static int parse_progressbar(const char *wps_bufptr, | |||
113 | struct wps_token *token, struct wps_data *wps_data); | 113 | struct wps_token *token, struct wps_data *wps_data); |
114 | static int parse_dir_level(const char *wps_bufptr, | 114 | static int parse_dir_level(const char *wps_bufptr, |
115 | struct wps_token *token, struct wps_data *wps_data); | 115 | struct wps_token *token, struct wps_data *wps_data); |
116 | |||
116 | #ifdef HAVE_LCD_BITMAP | 117 | #ifdef HAVE_LCD_BITMAP |
117 | static int parse_image_special(const char *wps_bufptr, | 118 | static int parse_image_special(const char *wps_bufptr, |
118 | struct wps_token *token, struct wps_data *wps_data); | 119 | struct wps_token *token, struct wps_data *wps_data); |
@@ -126,6 +127,13 @@ static int parse_image_load(const char *wps_bufptr, | |||
126 | struct wps_token *token, struct wps_data *wps_data); | 127 | struct wps_token *token, struct wps_data *wps_data); |
127 | #endif /*HAVE_LCD_BITMAP */ | 128 | #endif /*HAVE_LCD_BITMAP */ |
128 | 129 | ||
130 | #ifdef HAVE_ALBUMART | ||
131 | static int parse_albumart_load(const char *wps_bufptr, | ||
132 | struct wps_token *token, struct wps_data *wps_data); | ||
133 | static int parse_albumart_conditional(const char *wps_bufptr, | ||
134 | struct wps_token *token, struct wps_data *wps_data); | ||
135 | #endif /* HAVE_ALBUMART */ | ||
136 | |||
129 | #ifdef CONFIG_RTC | 137 | #ifdef CONFIG_RTC |
130 | #define WPS_RTC_REFRESH WPS_REFRESH_DYNAMIC | 138 | #define WPS_RTC_REFRESH WPS_REFRESH_DYNAMIC |
131 | #else | 139 | #else |
@@ -283,6 +291,11 @@ static const struct wps_tag all_tags[] = { | |||
283 | 291 | ||
284 | { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, | 292 | { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, |
285 | { WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special }, | 293 | { WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special }, |
294 | #ifdef HAVE_ALBUMART | ||
295 | { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load }, | ||
296 | { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_DYNAMIC, | ||
297 | parse_albumart_conditional }, | ||
298 | #endif | ||
286 | #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1)) | 299 | #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1)) |
287 | { WPS_TOKEN_IMAGE_BACKDROP, "X", 0, parse_image_special }, | 300 | { WPS_TOKEN_IMAGE_BACKDROP, "X", 0, parse_image_special }, |
288 | #endif | 301 | #endif |
@@ -606,6 +619,215 @@ static int parse_progressbar(const char *wps_bufptr, | |||
606 | #endif | 619 | #endif |
607 | } | 620 | } |
608 | 621 | ||
622 | #ifdef HAVE_ALBUMART | ||
623 | static int parse_albumart_load(const char *wps_bufptr, | ||
624 | struct wps_token *token, | ||
625 | struct wps_data *wps_data) | ||
626 | { | ||
627 | const char* _pos; | ||
628 | bool parsing; | ||
629 | const short xalign_mask = WPS_ALBUMART_ALIGN_LEFT | | ||
630 | WPS_ALBUMART_ALIGN_CENTER | | ||
631 | WPS_ALBUMART_ALIGN_RIGHT; | ||
632 | const short yalign_mask = WPS_ALBUMART_ALIGN_TOP | | ||
633 | WPS_ALBUMART_ALIGN_CENTER | | ||
634 | WPS_ALBUMART_ALIGN_BOTTOM; | ||
635 | |||
636 | (void)token; /* silence warning */ | ||
637 | |||
638 | /* reset albumart info in wps */ | ||
639 | wps_data->wps_uses_albumart = WPS_ALBUMART_NONE; | ||
640 | wps_data->albumart_max_width = -1; | ||
641 | wps_data->albumart_max_height = -1; | ||
642 | wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ | ||
643 | wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ | ||
644 | |||
645 | /* format: %Cl|x|y|[[l|c|r][d|i|s]mwidth]|[[t|c|b][d|i|s]mheight]| */ | ||
646 | |||
647 | /* initial validation and parsing of x and y components */ | ||
648 | if (*wps_bufptr != '|') | ||
649 | return 0; /* malformed token: e.g. %Cl7 */ | ||
650 | |||
651 | _pos = wps_bufptr + 1; | ||
652 | if (!isdigit(*_pos)) | ||
653 | return 0; /* malformed token: e.g. %Cl|@ */ | ||
654 | wps_data->albumart_x = atoi(_pos); | ||
655 | |||
656 | _pos = strchr(_pos, '|'); | ||
657 | if (!_pos || !isdigit(*(++_pos))) | ||
658 | return 0; /* malformed token: e.g. %Cl|7\n or %Cl|7|@ */ | ||
659 | |||
660 | wps_data->albumart_y = atoi(_pos); | ||
661 | |||
662 | _pos = strchr(_pos, '|'); | ||
663 | if (!_pos) | ||
664 | return 0; /* malformed token: no | after y coordinate | ||
665 | e.g. %Cl|7|59\n */ | ||
666 | |||
667 | /* parsing width field */ | ||
668 | parsing = true; | ||
669 | while (parsing) | ||
670 | { | ||
671 | /* apply each modifier in turn */ | ||
672 | ++_pos; | ||
673 | switch (*_pos) | ||
674 | { | ||
675 | case 'l': | ||
676 | case 'L': | ||
677 | case '+': | ||
678 | wps_data->albumart_xalign = | ||
679 | (wps_data->albumart_xalign & xalign_mask) | | ||
680 | WPS_ALBUMART_ALIGN_LEFT; | ||
681 | break; | ||
682 | case 'c': | ||
683 | case 'C': | ||
684 | wps_data->albumart_xalign = | ||
685 | (wps_data->albumart_xalign & xalign_mask) | | ||
686 | WPS_ALBUMART_ALIGN_CENTER; | ||
687 | break; | ||
688 | case 'r': | ||
689 | case 'R': | ||
690 | case '-': | ||
691 | wps_data->albumart_xalign = | ||
692 | (wps_data->albumart_xalign & xalign_mask) | | ||
693 | WPS_ALBUMART_ALIGN_RIGHT; | ||
694 | break; | ||
695 | case 'd': | ||
696 | case 'D': | ||
697 | wps_data->albumart_xalign |= WPS_ALBUMART_DECREASE; | ||
698 | break; | ||
699 | case 'i': | ||
700 | case 'I': | ||
701 | wps_data->albumart_xalign |= WPS_ALBUMART_INCREASE; | ||
702 | break; | ||
703 | case 's': | ||
704 | case 'S': | ||
705 | wps_data->albumart_xalign |= | ||
706 | (WPS_ALBUMART_DECREASE | WPS_ALBUMART_INCREASE); | ||
707 | break; | ||
708 | default: | ||
709 | parsing = false; | ||
710 | break; | ||
711 | } | ||
712 | } | ||
713 | /* extract max width data */ | ||
714 | if (*_pos != '|') | ||
715 | { | ||
716 | if (!isdigit(*_pos)) | ||
717 | return 0; /* malformed token: e.g. %Cl|7|59|# */ | ||
718 | wps_data->albumart_max_width = atoi(_pos); | ||
719 | _pos = strchr(_pos, '|'); | ||
720 | if (!_pos) | ||
721 | return 0; /* malformed token: no | after width field | ||
722 | e.g. %Cl|7|59|200\n */ | ||
723 | } | ||
724 | |||
725 | /* parsing height field */ | ||
726 | parsing = true; | ||
727 | while (parsing) | ||
728 | { | ||
729 | /* apply each modifier in turn */ | ||
730 | ++_pos; | ||
731 | switch (*_pos) | ||
732 | { | ||
733 | case 't': | ||
734 | case 'T': | ||
735 | case '-': | ||
736 | wps_data->albumart_yalign = | ||
737 | (wps_data->albumart_yalign & yalign_mask) | | ||
738 | WPS_ALBUMART_ALIGN_TOP; | ||
739 | break; | ||
740 | case 'c': | ||
741 | case 'C': | ||
742 | wps_data->albumart_yalign = | ||
743 | (wps_data->albumart_yalign & yalign_mask) | | ||
744 | WPS_ALBUMART_ALIGN_CENTER; | ||
745 | break; | ||
746 | case 'b': | ||
747 | case 'B': | ||
748 | case '+': | ||
749 | wps_data->albumart_yalign = | ||
750 | (wps_data->albumart_yalign & yalign_mask) | | ||
751 | WPS_ALBUMART_ALIGN_BOTTOM; | ||
752 | break; | ||
753 | case 'd': | ||
754 | case 'D': | ||
755 | wps_data->albumart_yalign |= WPS_ALBUMART_DECREASE; | ||
756 | break; | ||
757 | case 'i': | ||
758 | case 'I': | ||
759 | wps_data->albumart_yalign |= WPS_ALBUMART_INCREASE; | ||
760 | break; | ||
761 | case 's': | ||
762 | case 'S': | ||
763 | wps_data->albumart_yalign |= | ||
764 | (WPS_ALBUMART_DECREASE | WPS_ALBUMART_INCREASE); | ||
765 | break; | ||
766 | default: | ||
767 | parsing = false; | ||
768 | break; | ||
769 | } | ||
770 | } | ||
771 | /* extract max height data */ | ||
772 | if (*_pos != '|') | ||
773 | { | ||
774 | if (!isdigit(*_pos)) | ||
775 | return 0; /* malformed token e.g. %Cl|7|59|200|@ */ | ||
776 | wps_data->albumart_max_height = atoi(_pos); | ||
777 | _pos = strchr(_pos, '|'); | ||
778 | if (!_pos) | ||
779 | return 0; /* malformed token: no closing | | ||
780 | e.g. %Cl|7|59|200|200\n */ | ||
781 | } | ||
782 | |||
783 | /* if we got here, we parsed everything ok .. ! */ | ||
784 | if (wps_data->albumart_max_width < 0) | ||
785 | wps_data->albumart_max_width = 0; | ||
786 | else if (wps_data->albumart_max_width > LCD_WIDTH) | ||
787 | wps_data->albumart_max_width = LCD_WIDTH; | ||
788 | |||
789 | if (wps_data->albumart_max_height < 0) | ||
790 | wps_data->albumart_max_height = 0; | ||
791 | else if (wps_data->albumart_max_height > LCD_HEIGHT) | ||
792 | wps_data->albumart_max_height = LCD_HEIGHT; | ||
793 | |||
794 | wps_data->wps_uses_albumart = WPS_ALBUMART_LOAD; | ||
795 | |||
796 | /* Skip the rest of the line */ | ||
797 | return skip_end_of_line(wps_bufptr); | ||
798 | } | ||
799 | |||
800 | static int parse_albumart_conditional(const char *wps_bufptr, | ||
801 | struct wps_token *token, | ||
802 | struct wps_data *wps_data) | ||
803 | { | ||
804 | struct wps_token *prevtoken = token; | ||
805 | --prevtoken; | ||
806 | if (wps_data->num_tokens >= 1 && prevtoken->type == WPS_TOKEN_CONDITIONAL) | ||
807 | { | ||
808 | /* This %C is part of a %?C construct. | ||
809 | It's either %?C<blah> or %?Cn<blah> */ | ||
810 | token->type = WPS_TOKEN_ALBUMART_FOUND; | ||
811 | if (*wps_bufptr == 'n' && *(wps_bufptr + 1) == '<') | ||
812 | { | ||
813 | token->next = true; | ||
814 | return 1; | ||
815 | } | ||
816 | else if (*wps_bufptr == '<') | ||
817 | { | ||
818 | return 0; | ||
819 | } | ||
820 | else | ||
821 | { | ||
822 | token->type = WPS_NO_TOKEN; | ||
823 | return 0; | ||
824 | } | ||
825 | } | ||
826 | else | ||
827 | return 0; | ||
828 | }; | ||
829 | #endif /* HAVE_ALBUMART */ | ||
830 | |||
609 | /* Parse a generic token from the given string. Return the length read */ | 831 | /* Parse a generic token from the given string. Return the length read */ |
610 | static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) | 832 | static int parse_token(const char *wps_bufptr, struct wps_data *wps_data) |
611 | { | 833 | { |
@@ -915,6 +1137,9 @@ static void wps_reset(struct wps_data *data) | |||
915 | bool rwps = data->remote_wps; /* remember whether the data is for a RWPS */ | 1137 | bool rwps = data->remote_wps; /* remember whether the data is for a RWPS */ |
916 | #endif | 1138 | #endif |
917 | memset(data, 0, sizeof(*data)); | 1139 | memset(data, 0, sizeof(*data)); |
1140 | #ifdef HAVE_ALBUMART | ||
1141 | data->wps_uses_albumart = WPS_ALBUMART_NONE; | ||
1142 | #endif | ||
918 | wps_data_init(data); | 1143 | wps_data_init(data); |
919 | #ifdef HAVE_REMOTE_LCD | 1144 | #ifdef HAVE_REMOTE_LCD |
920 | data->remote_wps = rwps; | 1145 | data->remote_wps = rwps; |