summaryrefslogtreecommitdiff
path: root/apps/gui/statusbar.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/statusbar.c')
-rw-r--r--apps/gui/statusbar.c196
1 files changed, 118 insertions, 78 deletions
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index a8b8c5061b..ae8bba0538 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -124,19 +124,6 @@
124#endif 124#endif
125#define STATUSBAR_TIME_X_END(statusbar_width) statusbar_width - 1 - \ 125#define STATUSBAR_TIME_X_END(statusbar_width) statusbar_width - 1 - \
126 STATUSBAR_DISK_WIDTH 126 STATUSBAR_DISK_WIDTH
127#if defined(HAVE_RECORDING)
128/* analogue frequency numbers taken from the order of frequencies in sample_rate */
129#define FREQ_44 7
130#define FREQ_48 8
131#define FREQ_32 6
132#define FREQ_22 4
133#define FREQ_24 5
134#define FREQ_16 3
135#ifdef HAVE_SPDIF_IN
136#define SOURCE_SPDIF 2
137#endif
138#endif
139
140struct gui_syncstatusbar statusbars; 127struct gui_syncstatusbar statusbars;
141 128
142void gui_statusbar_init(struct gui_statusbar * bar) 129void gui_statusbar_init(struct gui_statusbar * bar)
@@ -600,41 +587,113 @@ void gui_statusbar_time(struct screen * display, int hour, int minute)
600#endif 587#endif
601 588
602#ifdef HAVE_RECORDING 589#ifdef HAVE_RECORDING
603void gui_statusbar_icon_recording_info(struct screen * display) 590#if CONFIG_CODEC == SWCODEC
591/**
592 * Write a number to the display using bitmaps and return new position
593 */
594static int write_bitmap_number(struct screen * display, int value,
595 int x, int y)
604{ 596{
605#if (CONFIG_CODEC != SWCODEC) || (defined(SIMULATOR) && defined(HAVE_SPDIF_IN)) 597 char buf[12], *ptr;
606 char buffer[3]; 598 snprintf(buf, sizeof(buf), "%d", value);
599
600 for (ptr = buf; *ptr != '\0'; ptr++, x += BM_GLYPH_WIDTH)
601 display->mono_bitmap(bitmap_glyphs_4x8[*ptr - '0'], x, y,
602 BM_GLYPH_WIDTH, STATUSBAR_HEIGHT);
603 return x;
604}
605
606/**
607 * Write format info bitmaps - right justified
608 */
609static void gui_statusbar_write_format_info(struct screen * display)
610{
611 /* Can't fit info for sw codec targets in statusbar using FONT_SYSFIXED
612 so must use icons */
613 int rec_format = global_settings.rec_format;
614 unsigned bitrk = 0; /* compiler warns about unitialized use !! */
615 int xpos = STATUSBAR_ENCODER_X_POS;
616 int width = STATUSBAR_ENCODER_WIDTH;
617 const unsigned char *bm = bitmap_formats_18x8[rec_format];
618
619 if (rec_format == REC_FORMAT_MPA_L3)
620 {
621 /* Special handling for mp3 */
622 bitrk = global_settings.mp3_enc_config.bitrate;
623 bitrk = mp3_enc_bitr[bitrk];
624
625 width = BM_MPA_L3_M_WIDTH;
626
627 /* Slide 'M' to right if fewer than three digits used */
628 if (bitrk > 999)
629 bitrk = 999; /* neurotic safety check if corrupted */
630 else
631 {
632 if (bitrk < 100)
633 xpos += BM_GLYPH_WIDTH;
634 if (bitrk < 10)
635 xpos += BM_GLYPH_WIDTH;
636 }
637 }
638
639
640 /* Show bitmap - clipping right edge if needed */
641 display->mono_bitmap_part(bm, 0, 0, STATUSBAR_ENCODER_WIDTH,
642 xpos, STATUSBAR_Y_POS, width, STATUSBAR_HEIGHT);
643
644 if (rec_format == REC_FORMAT_MPA_L3)
645 {
646 xpos += BM_MPA_L3_M_WIDTH; /* to right of 'M' */
647 write_bitmap_number(display, bitrk, xpos, STATUSBAR_Y_POS);
648 }
649}
650
651/**
652 * Write sample rate using bitmaps - left justified
653 */
654static void gui_statusbar_write_samplerate_info(struct screen * display)
655{
656 unsigned long samprk;
657 int xpos;
658
659#ifdef SIMULATOR
660 samprk = 44100;
661#else
662#ifdef HAVE_SPDIF_IN
663 if (global_settings.rec_source == AUDIO_SRC_SPDIF)
664 /* Use rate in use, not current measured rate if it changed */
665 samprk = pcm_rec_sample_rate();
666 else
607#endif 667#endif
668 samprk = rec_freq_sampr[global_settings.rec_frequency];
669#endif /* SIMULATOR */
670
671 samprk /= 1000;
672 if (samprk > 99)
673 samprk = 99; /* Limit to 3 glyphs */
674
675 xpos = write_bitmap_number(display, (unsigned)samprk,
676 STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS);
677
678 /* write the 'k' */
679 display->mono_bitmap(bitmap_glyphs_4x8[Glyph_4x8_k], xpos,
680 STATUSBAR_Y_POS, BM_GLYPH_WIDTH,
681 STATUSBAR_HEIGHT);
682}
683#endif /* CONFIG_CODEC == SWCODEC */
684
685void gui_statusbar_icon_recording_info(struct screen * display)
686{
608#if CONFIG_CODEC != SWCODEC 687#if CONFIG_CODEC != SWCODEC
688 char buffer[3];
609 int width, height; 689 int width, height;
610 static char* const sample_rate[12] =
611 {
612 "8",
613 "11",
614 "12",
615 "16",
616 "22",
617 "24",
618 "32",
619 "44",
620 "48",
621 "64",
622 "88",
623 "96"
624 };
625
626 display->setfont(FONT_SYSFIXED); 690 display->setfont(FONT_SYSFIXED);
627#endif 691#endif /* CONFIG_CODEC != SWCODEC */
628 692
629 /* Display Codec info in statusbar */ 693 /* Display Codec info in statusbar */
630#if CONFIG_CODEC == SWCODEC 694#if CONFIG_CODEC == SWCODEC
631 /* Can't fit info for sw codec targets in statusbar using FONT_SYSFIXED 695 gui_statusbar_write_format_info(display);
632 so must use icons */ 696#else /* !SWCODEC */
633 display->mono_bitmap(bitmap_icons_18x8[global_settings.rec_quality],
634 STATUSBAR_ENCODER_X_POS, STATUSBAR_Y_POS,
635 STATUSBAR_ENCODER_WIDTH, STATUSBAR_HEIGHT);
636#else
637
638 display->mono_bitmap(bitmap_icons_5x8[Icon_q], 697 display->mono_bitmap(bitmap_icons_5x8[Icon_q],
639 STATUSBAR_ENCODER_X_POS + 8, STATUSBAR_Y_POS, 698 STATUSBAR_ENCODER_X_POS + 8, STATUSBAR_Y_POS,
640 5, STATUSBAR_HEIGHT); 699 5, STATUSBAR_HEIGHT);
@@ -643,56 +702,37 @@ void gui_statusbar_icon_recording_info(struct screen * display)
643 display->getstringsize(buffer, &width, &height); 702 display->getstringsize(buffer, &width, &height);
644 if (height <= STATUSBAR_HEIGHT) 703 if (height <= STATUSBAR_HEIGHT)
645 display->putsxy(STATUSBAR_ENCODER_X_POS + 13, STATUSBAR_Y_POS, buffer); 704 display->putsxy(STATUSBAR_ENCODER_X_POS + 13, STATUSBAR_Y_POS, buffer);
646#endif 705#endif /* CONFIG_CODEC == SWCODEC */
647 706
648 /* Display Samplerate info in statusbar */ 707 /* Display Samplerate info in statusbar */
649#if defined(HAVE_SPDIF_IN) 708#if CONFIG_CODEC == SWCODEC
650 if (global_settings.rec_source == SOURCE_SPDIF) 709 /* SWCODEC targets use bitmaps for glyphs */
710 gui_statusbar_write_samplerate_info(display);
711#else /* !SWCODEC */
712 /* hwcodec targets have sysfont characters */
713#ifdef HAVE_SPDIF_IN
714 if (global_settings.rec_source == AUDIO_SRC_SPDIF)
651 { 715 {
652#if (CONFIG_CODEC != MAS3587F) && !defined(SIMULATOR)
653 display->mono_bitmap(bitmap_icons_12x8[audio_get_spdif_sample_rate()],
654 STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS,
655 STATUSBAR_RECFREQ_WIDTH, STATUSBAR_HEIGHT);
656#else
657 /* Can't measure S/PDIF sample rate on Archos/Sim yet */ 716 /* Can't measure S/PDIF sample rate on Archos/Sim yet */
658 snprintf(buffer, sizeof(buffer), "--"); 717 snprintf(buffer, sizeof(buffer), "--");
659#endif
660 } 718 }
661 else 719 else
662#endif /* HAVE_SPDIF_IN */ 720#endif /* HAVE_SPDIF_IN */
663 { 721 {
664 /* Analogue frequency in wrong order so remap settings numbers */ 722 static char const * const freq_strings[12] =
665 int freq = global_settings.rec_frequency; 723 { "44", "48", "32", "22", "24", "16" };
666 if (freq == 0) 724 snprintf(buffer, sizeof(buffer), "%s",
667 freq = FREQ_44; 725 freq_strings[global_settings.rec_frequency]);
668 else if (freq == 1)
669 freq = FREQ_48;
670 else if (freq == 2)
671 freq = FREQ_32;
672 else if (freq == 3)
673 freq = FREQ_22;
674 else if (freq == 4)
675 freq = FREQ_24;
676 else if (freq == 5)
677 freq = FREQ_16;
678
679#if CONFIG_CODEC == SWCODEC
680 /* samplerate icons for swcodec targets*/
681 display->mono_bitmap(bitmap_icons_12x8[freq],
682 STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS,
683 STATUSBAR_RECFREQ_WIDTH, STATUSBAR_HEIGHT);
684 }
685#else
686 /* hwcodec targets have sysfont characters */
687 snprintf(buffer, sizeof(buffer), "%s", sample_rate[freq]);
688 display->getstringsize(buffer, &width, &height);
689 } 726 }
690 727
691 if (height <= STATUSBAR_HEIGHT) 728 display->getstringsize(buffer, &width, &height);
692 display->putsxy(STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS, buffer); 729
730 if (height <= STATUSBAR_HEIGHT)
731 display->putsxy(STATUSBAR_RECFREQ_X_POS, STATUSBAR_Y_POS, buffer);
732
733 display->setfont(FONT_UI);
734#endif /* CONFIG_CODEC == SWCODEC */
693 735
694 display->setfont(FONT_UI);
695#endif
696 /* Display Channel status in status bar */ 736 /* Display Channel status in status bar */
697 if(global_settings.rec_channels) 737 if(global_settings.rec_channels)
698 { 738 {