summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2008-08-06 20:12:44 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2008-08-06 20:12:44 +0000
commit496e1f7e85f929c487eb89f85ff0fc7edfcf3a27 (patch)
tree6c1ebac920b55979d6ac56972ffaee0747403e25 /apps/recorder/recording.c
parent729d259388f0f418bcf285698a6c751335457ac0 (diff)
downloadrockbox-496e1f7e85f929c487eb89f85ff0fc7edfcf3a27.tar.gz
rockbox-496e1f7e85f929c487eb89f85ff0fc7edfcf3a27.zip
First step of the recording screen redesign. The screen is split into a fixed top part containing essential data and the peakmeters/triggerbar, and a bottom part that is in fact a list. The list contains the items that can be changed, and also some stuff that isn't important enough to be on the top part, like the filename. That filename is now shown completely. If the font is too big to have 6 lines on the display, sysfont is used.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18202 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c1173
1 files changed, 518 insertions, 655 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index d9ef6812e1..7dfa16cb93 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -71,6 +71,7 @@
71#include "radio.h" 71#include "radio.h"
72#include "sound_menu.h" 72#include "sound_menu.h"
73#include "viewport.h" 73#include "viewport.h"
74#include "list.h"
74 75
75#ifdef HAVE_RECORDING 76#ifdef HAVE_RECORDING
76/* This array holds the record timer interval lengths, in seconds */ 77/* This array holds the record timer interval lengths, in seconds */
@@ -164,8 +165,6 @@ bool in_recording_screen(void)
164 return (rec_status & RCSTAT_IN_RECSCREEN) != 0; 165 return (rec_status & RCSTAT_IN_RECSCREEN) != 0;
165} 166}
166 167
167#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
168
169#if CONFIG_KEYPAD == RECORDER_PAD 168#if CONFIG_KEYPAD == RECORDER_PAD
170static bool f2_rec_screen(void); 169static bool f2_rec_screen(void);
171static bool f3_rec_screen(void); 170static bool f3_rec_screen(void);
@@ -180,6 +179,11 @@ static int screen_update = NB_SCREENS;
180static bool remote_display_on = true; 179static bool remote_display_on = true;
181#endif 180#endif
182 181
182/* as we have the ability to disable the remote, we need an alternative loop */
183#define FOR_NB_ACTIVE_SCREENS(i) for(i = 0; i < screen_update; i++)
184
185static bool update_list = false; /* (GIU) list needs updating */
186
183/** File name creation **/ 187/** File name creation **/
184#if CONFIG_RTC == 0 188#if CONFIG_RTC == 0
185/* current file number to assist in creating unique numbered filenames 189/* current file number to assist in creating unique numbered filenames
@@ -279,6 +283,7 @@ static void set_gain(void)
279 } 283 }
280 /* reset the clipping indicators */ 284 /* reset the clipping indicators */
281 peak_meter_set_clip_hold(global_settings.peak_meter_clip_hold); 285 peak_meter_set_clip_hold(global_settings.peak_meter_clip_hold);
286 update_list = true;
282} 287}
283 288
284#ifdef HAVE_AGC 289#ifdef HAVE_AGC
@@ -541,51 +546,6 @@ static char *fmt_gain(int snd, int val, char *str, int len)
541 return str; 546 return str;
542} 547}
543 548
544static int cursor;
545
546static void adjust_cursor(void)
547{
548 int max_cursor;
549
550 if(cursor < 0)
551 cursor = 0;
552
553#ifdef HAVE_AGC
554 switch(global_settings.rec_source)
555 {
556 case REC_SRC_MIC:
557 if(cursor == 2)
558 cursor = 4;
559 else if(cursor == 3)
560 cursor = 1;
561 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
562 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
563 max_cursor = 5;
564 break;
565 default:
566 max_cursor = 0;
567 break;
568 }
569#else /* !HAVE_AGC */
570 switch(global_settings.rec_source)
571 {
572 case AUDIO_SRC_MIC:
573 max_cursor = 1;
574 break;
575 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
576 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
577 max_cursor = 3;
578 break;
579 default:
580 max_cursor = 0;
581 break;
582 }
583#endif /* HAVE_AGC */
584
585 if(cursor > max_cursor)
586 cursor = max_cursor;
587}
588
589/* the list below must match enum audio_sources in audio.h */ 549/* the list below must match enum audio_sources in audio.h */
590static const char* const prestr[] = 550static const char* const prestr[] =
591{ 551{
@@ -744,6 +704,7 @@ void rec_command(enum recording_command cmd)
744 audio_resume_recording(); 704 audio_resume_recording();
745 break; 705 break;
746 } 706 }
707 update_list = true;
747} 708}
748 709
749/* used in trigger_listerner and recording_screen */ 710/* used in trigger_listerner and recording_screen */
@@ -807,7 +768,7 @@ static void trigger_listener(int trigger_status)
807 /* tell recording_screen to reset the time */ 768 /* tell recording_screen to reset the time */
808 last_seconds = 0; 769 last_seconds = 0;
809 break; 770 break;
810 771
811 case 3: /* Stop and shutdown */ 772 case 3: /* Stop and shutdown */
812 rec_command(RECORDING_CMD_STOP_SHUTDOWN); 773 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
813 break; 774 break;
@@ -823,25 +784,176 @@ static void trigger_listener(int trigger_status)
823 } 784 }
824} 785}
825 786
787/* Stuff for drawing the screen */
788
789enum rec_list_items_stereo {
790 ITEM_VOLUME = 0,
791 ITEM_GAIN = 1,
792 ITEM_GAIN_L = 2,
793 ITEM_GAIN_R = 3,
794#ifdef HAVE_AGC
795 ITEM_AGC_MODE = 4,
796 ITEM_AGC_MAXDB = 5,
797 ITEM_FILENAME = 6,
798 ITEM_COUNT = 7,
799#else
800 ITEM_FILENAME = 4,
801 ITEM_COUNT = 5,
802#endif
803};
804
805enum rec_list_items_mono {
806 ITEM_VOLUME_M = 0,
807 ITEM_GAIN_M = 1,
808#ifdef HAVE_AGC
809 ITEM_AGC_MODE_M = 4,
810 ITEM_AGC_MAXDB_M = 5,
811 ITEM_FILENAME_M = 6,
812 ITEM_COUNT_M = 5,
813#else
814 ITEM_FILENAME_M = 4,
815 ITEM_COUNT_M = 3,
816#endif
817};
818
819static int listid_to_enum[ITEM_COUNT];
820
821static char * reclist_get_name(int selected_item, void * data,
822 char * buffer, size_t buffer_len)
823{
824 char buf2[32];
825#ifdef HAVE_AGC
826 char buf3[32];
827#endif
828 data = data; /* not used */
829 if(selected_item >= ITEM_COUNT)
830 return "";
831
832 switch (listid_to_enum[selected_item])
833 {
834 case ITEM_VOLUME:
835 snprintf(buffer, buffer_len, "%s: %s", str(LANG_VOLUME),
836 fmt_gain(SOUND_VOLUME,
837 global_settings.volume,
838 buf2, sizeof(buf2)));
839 break;
840 case ITEM_GAIN:
841 if(global_settings.rec_source == AUDIO_SRC_MIC)
842 {
843 /* Draw MIC recording gain */
844 snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
845 fmt_gain(SOUND_MIC_GAIN,
846 global_settings.rec_mic_gain,
847 buf2, sizeof(buf2)));
848 }
849 else
850 {
851 int avg_gain = (global_settings.rec_left_gain +
852 global_settings.rec_right_gain) / 2;
853 snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
854 fmt_gain(SOUND_LEFT_GAIN,
855 avg_gain,
856 buf2, sizeof(buf2)));
857 }
858 break;
859 case ITEM_GAIN_L:
860 snprintf(buffer, buffer_len, "%s: %s",
861 str(LANG_GAIN_LEFT),
862 fmt_gain(SOUND_LEFT_GAIN,
863 global_settings.rec_left_gain,
864 buf2, sizeof(buf2)));
865 break;
866 case ITEM_GAIN_R:
867 snprintf(buffer, buffer_len, "%s: %s",
868 str(LANG_GAIN_RIGHT),
869 fmt_gain(SOUND_RIGHT_GAIN,
870 global_settings.rec_right_gain,
871 buf2, sizeof(buf2)));
872 break;
873#ifdef HAVE_AGC
874 case ITEM_AGC_MODE:
875 snprintf(buffer, buffer_len, "%s: %s",
876 str(LANG_RECORDING_AGC_PRESET),
877 agc_preset_str[agc_preset]);
878 break;
879 case ITEM_AGC_MAXDB:
880 if (agc_preset == 0)
881 snprintf(buffer, buffer_len, "%s: %s",
882 str(LANG_RECORDING_AGC_MAXGAIN),
883 fmt_gain(SOUND_LEFT_GAIN,
884 agc_maxgain, buf2, sizeof(buf2)));
885 else if (global_settings.rec_source == AUDIO_SRC_MIC)
886 snprintf(buffer, buffer_len, "%s: %s (%s)",
887 str(LANG_RECORDING_AGC_MAXGAIN),
888 fmt_gain(SOUND_MIC_GAIN,
889 agc_maxgain, buf2, sizeof(buf2)),
890 fmt_gain(SOUND_MIC_GAIN,
891 agc_maxgain - global_settings.rec_mic_gain,
892 buf3, sizeof(buf3)));
893 else
894 snprintf(buffer, buffer_len, "%s: %s (%s)",
895 str(LANG_RECORDING_AGC_MAXGAIN),
896 fmt_gain(SOUND_LEFT_GAIN,
897 agc_maxgain, buf2, sizeof(buf2)),
898 fmt_gain(SOUND_LEFT_GAIN,
899 agc_maxgain -
900 (global_settings.rec_left_gain +
901 global_settings.rec_right_gain)/2,
902 buf3, sizeof(buf3)));
903 break;
904#endif
905 case ITEM_FILENAME:
906 {
907 if(audio_status() & AUDIO_STATUS_RECORD)
908 {
909 size_t tot_len = strlen(path_buffer) +
910 strlen(str(LANG_RECORDING_FILENAME)) + 1;
911 if(tot_len > buffer_len)
912 {
913 snprintf(buffer, buffer_len, "%s %s",
914 str(LANG_RECORDING_FILENAME),
915 path_buffer + tot_len - buffer_len);
916 }
917 else
918 {
919 snprintf(buffer, buffer_len, "%s %s",
920 str(LANG_RECORDING_FILENAME), path_buffer);
921 }
922 }
923 else
924 {
925 strncpy(buffer, str(LANG_RECORDING_FILENAME), buffer_len);
926 }
927 break;
928 }
929 default:
930 return "";
931 }
932 return buffer;
933}
934
935
826bool recording_start_automatic = false; 936bool recording_start_automatic = false;
827 937
828bool recording_screen(bool no_source) 938bool recording_screen(bool no_source)
829{ 939{
830 long button; 940 int button;
831 bool done = false; 941 int done = -1; /* negative to re-init, positive to quit, zero to run */
832 char buf[32]; 942 char buf[32]; /* for preparing strings */
833 char buf2[32]; 943 char buf2[32]; /* for preparing strings */
834 int w, h; 944 int w, h; /* character width/height */
835 int update_countdown = 1; 945 int update_countdown = 1; /* refresh counter */
836 unsigned int seconds; 946 unsigned int seconds;
837 int hours, minutes; 947 int hours, minutes;
838 char filename[13]; 948 int audio_stat = 0; /* status of the audio system */
839 int last_audio_stat = -1; 949 int last_audio_stat = -1; /* previous status so we can act on changes */
840 int audio_stat; 950 struct viewport vp_list[NB_SCREENS], vp_top[NB_SCREENS]; /* the viewports */
951
841#if CONFIG_CODEC == SWCODEC 952#if CONFIG_CODEC == SWCODEC
842 int warning_counter = 0; 953 int warning_counter = 0;
843 #define WARNING_PERIOD 7 954 #define WARNING_PERIOD 7
844#endif 955#endif
956
845#ifdef HAVE_FMRADIO_REC 957#ifdef HAVE_FMRADIO_REC
846 /* Radio is left on if: 958 /* Radio is left on if:
847 * 1) Is was on at the start and the initial source is FM Radio 959 * 1) Is was on at the start and the initial source is FM Radio
@@ -859,18 +971,24 @@ bool recording_screen(bool no_source)
859 bool peak_valid = false; 971 bool peak_valid = false;
860 int peak_l, peak_r; 972 int peak_l, peak_r;
861 int balance = 0; 973 int balance = 0;
862 bool display_agc[NB_SCREENS];
863#endif 974#endif
864 int line[NB_SCREENS];
865 int i; 975 int i;
866 int filename_offset[NB_SCREENS]; 976 int pm_x[NB_SCREENS]; /* peakmeter (and trigger bar) x pos */
867 int pm_y[NB_SCREENS]; 977 int pm_y[NB_SCREENS]; /* peakmeter y pos */
868 int trig_xpos[NB_SCREENS]; 978 int pm_h[NB_SCREENS]; /* peakmeter height */
869 int trig_ypos[NB_SCREENS]; 979 int trig_ypos[NB_SCREENS]; /* trigger bar y pos */
870 int trig_width[NB_SCREENS]; 980 int trig_width[NB_SCREENS]; /* trigger bar width */
871 /* pm_x = offset pm to put clipcount in front. 981 struct gui_synclist lists; /* the list in the bottom vp */
872 Use lcd_getstringsize() when not using SYSFONT */ 982#ifdef HAVE_FMRADIO_REC
873 int pm_x = global_settings.peak_meter_clipcounter ? 30 : 0; 983 int prev_rec_source = global_settings.rec_source; /* detect source change */
984#endif
985
986#if CONFIG_TUNER
987 bool statusbar = global_settings.statusbar;
988 global_status.statusbar_forced = statusbar?0:1;
989 global_settings.statusbar = true;
990 gui_syncstatusbar_draw(&statusbars,true);
991#endif
874 992
875 static const unsigned char *byte_units[] = { 993 static const unsigned char *byte_units[] = {
876 ID2P(LANG_BYTE), 994 ID2P(LANG_BYTE),
@@ -879,29 +997,9 @@ bool recording_screen(bool no_source)
879 ID2P(LANG_GIGABYTE) 997 ID2P(LANG_GIGABYTE)
880 }; 998 };
881 999
882 int base_style = STYLE_INVERT;
883 int style;
884 struct viewport vp[NB_SCREENS];
885 int ymargin = global_settings.cursor_style?0:10;
886#ifdef HAVE_LCD_COLOR
887 if (global_settings.cursor_style == 2) {
888 base_style |= STYLE_COLORBAR;
889 }
890 else if (global_settings.cursor_style == 3) {
891 base_style |= STYLE_GRADIENT;
892 }
893#endif
894
895 struct audio_recording_options rec_options; 1000 struct audio_recording_options rec_options;
896 rec_status = RCSTAT_IN_RECSCREEN; 1001 rec_status = RCSTAT_IN_RECSCREEN;
897 1002
898 if (rec_create_directory() < 0)
899 {
900 rec_status = 0;
901 return false;
902 }
903
904 cursor = 0;
905#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 1003#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
906 ata_set_led_enabled(false); 1004 ata_set_led_enabled(false);
907#endif 1005#endif
@@ -917,68 +1015,166 @@ bool recording_screen(bool no_source)
917 peak_meter_playback(true); 1015 peak_meter_playback(true);
918#endif 1016#endif
919 1017
920 audio_init_recording(0);
921 sound_set_volume(global_settings.volume);
922
923#ifdef HAVE_AGC 1018#ifdef HAVE_AGC
924 peak_meter_get_peakhold(&peak_l, &peak_r); 1019 peak_meter_get_peakhold(&peak_l, &peak_r);
925#endif 1020#endif
926 1021
927 rec_init_recording_options(&rec_options);
928 rec_set_recording_options(&rec_options);
929
930 set_gain();
931
932#if CONFIG_RTC == 0
933 /* Create new filename for recording start */
934 rec_init_filename();
935#endif
936
937 pm_reset_clipcount(); 1022 pm_reset_clipcount();
938 pm_activate_clipcount(false); 1023 pm_activate_clipcount(false);
939 settings_apply_trigger(); 1024 settings_apply_trigger();
940 1025
941#ifdef HAVE_AGC 1026#ifdef HAVE_AGC
942 agc_preset_str[0] = str(LANG_SYSFONT_OFF); 1027 agc_preset_str[0] = str(LANG_OFF);
943 agc_preset_str[1] = str(LANG_SYSFONT_AGC_SAFETY); 1028 agc_preset_str[1] = str(LANG_AGC_SAFETY);
944 agc_preset_str[2] = str(LANG_SYSFONT_AGC_LIVE); 1029 agc_preset_str[2] = str(LANG_AGC_LIVE);
945 agc_preset_str[3] = str(LANG_SYSFONT_AGC_DJSET); 1030 agc_preset_str[3] = str(LANG_AGC_DJSET);
946 agc_preset_str[4] = str(LANG_SYSFONT_AGC_MEDIUM); 1031 agc_preset_str[4] = str(LANG_AGC_MEDIUM);
947 agc_preset_str[5] = str(LANG_SYSFONT_AGC_VOICE); 1032 agc_preset_str[5] = str(LANG_AGC_VOICE);
948 if (global_settings.rec_source == AUDIO_SRC_MIC) {
949 agc_preset = global_settings.rec_agc_preset_mic;
950 agc_maxgain = global_settings.rec_agc_maxgain_mic;
951 }
952 else {
953 agc_preset = global_settings.rec_agc_preset_line;
954 agc_maxgain = global_settings.rec_agc_maxgain_line;
955 }
956#endif /* HAVE_AGC */ 1033#endif /* HAVE_AGC */
957 1034
1035#if CONFIG_CODEC == SWCODEC
1036 audio_close_recording();
1037#endif
1038 audio_init_recording(0);
1039 sound_set_volume(global_settings.volume);
1040
1041#if CONFIG_RTC == 0
1042 /* Create new filename for recording start */
1043 rec_init_filename();
1044#endif
1045
1046 /* viewport init and calculations that only needs to be done once */
958 FOR_NB_SCREENS(i) 1047 FOR_NB_SCREENS(i)
959 { 1048 {
960 viewport_set_defaults(&vp[i], i); 1049 struct viewport *v;
961 vp[i].font = FONT_SYSFIXED; 1050 /* top vp, 4 lines, force sys font if total screen < 6 lines
962 screens[i].set_viewport(&vp[i]); 1051 NOTE: one could limit the list to 1 line and get away with 5 lines */
963 screens[i].getstringsize("M", &w, &h); 1052 v = &vp_top[i];
964 filename_offset[i] = ((vp[i].height >= 7*h) ? 1 : 0); 1053 viewport_set_defaults(v, i); /*already takes care of statusbar*/
965 pm_y[i] = h * (2 + filename_offset[i]); 1054 if (viewport_get_nb_lines(v) < (4+2)) /*top=4,list=2*/
1055 v->font = FONT_SYSFIXED;
1056 v->height = (font_get(v->font)->height)*4;
1057
1058 /* list section, rest of the screen */
1059 v = &vp_list[i];
1060 viewport_set_defaults(v, i);
1061 v->font = vp_top[i].font;
1062 v->y = vp_top[i].y + vp_top[i].height;
1063 v->height = screens[i].lcdheight - v->y; /* the rest */
1064 screens[i].set_viewport(&vp_top[i]); /* req for next calls */
1065
1066 screens[i].getstringsize("W", &w, &h);
1067 pm_y[i] = font_get(vp_top[i].font)->height * 2;
1068 trig_ypos[i] = font_get(vp_top[i].font)->height * 3;
966 } 1069 }
967 1070
968#ifdef HAVE_REMOTE_LCD 1071 /* init the bottom list */
969 if (!remote_display_on) 1072 gui_synclist_init(&lists, reclist_get_name, NULL, false, 1, vp_list);
1073 gui_synclist_set_title(&lists, NULL, Icon_NOICON);
1074
1075 /* start of the loop: we stay in this loop until user quits recscreen */
1076 while(done <= 0)
970 { 1077 {
971 screens[1].clear_display(); 1078 if(done < 0)
972 snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON)); 1079 {
973 screens[1].puts((vp[1].width/w - strlen(buf))/2 + 1, 1080 /* request to re-init stuff, done after settings screen */
974 vp[1].height/(h*2) + 1, buf); 1081 done = 0;
975 screens[1].update(); 1082#ifdef HAVE_FMRADIO_REC
976 gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF)); 1083 /* If input changes away from FM Radio,
977 } 1084 radio will remain off when recording screen closes. */
1085 if (global_settings.rec_source != prev_rec_source
1086 && prev_rec_source == AUDIO_SRC_FMRADIO)
1087 radio_status = FMRADIO_OFF;
1088 prev_rec_source = global_settings.rec_source;
978#endif 1089#endif
979 1090
980 while(!done) 1091 FOR_NB_SCREENS(i)
981 { 1092 {
1093 pm_x[i] = 0;
1094 if(global_settings.peak_meter_clipcounter)
1095 {
1096 int clipwidth = 0;
1097 screens[i].getstringsize(str(LANG_PM_CLIPCOUNT),
1098 &clipwidth, &h); /* h is same */
1099 pm_x[i] = clipwidth+1;
1100 }
1101 if(global_settings.rec_trigger_mode == TRIG_MODE_OFF)
1102 pm_h[i] = font_get(vp_top[i].font)->height * 2;
1103 else
1104 pm_h[i] = font_get(vp_top[i].font)->height;
1105 trig_width[i] = vp_top[i].width - pm_x[i];
1106 screens[i].clear_display();
1107 screens[i].update();
1108 }
1109
1110#if CONFIG_CODEC == SWCODEC
1111 audio_close_recording();
1112 audio_init_recording(0);
1113#endif
1114
1115 rec_init_recording_options(&rec_options);
1116 rec_set_recording_options(&rec_options);
1117
1118 if(rec_create_directory() < 0)
1119 {
1120 rec_status = 0;
1121 goto rec_abort;
1122 }
1123
1124#if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
1125 /* If format changed, a new number is required */
1126 rec_init_filename();
1127#endif
1128
1129#ifdef HAVE_AGC
1130 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1131 agc_preset = global_settings.rec_agc_preset_mic;
1132 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1133 }
1134 else {
1135 agc_preset = global_settings.rec_agc_preset_line;
1136 agc_maxgain = global_settings.rec_agc_maxgain_line;
1137 }
1138#endif
1139
1140 set_gain();
1141 update_countdown = 1; /* Update immediately */
1142
1143 /* populate translation table for list id -> enum */
1144 if(global_settings.rec_source == AUDIO_SRC_MIC)
1145 {
1146 listid_to_enum[0] = ITEM_VOLUME_M;
1147 listid_to_enum[1] = ITEM_GAIN_M;
1148#ifdef HAVE_AGC
1149 listid_to_enum[2] = ITEM_AGC_MODE_M;
1150 listid_to_enum[3] = ITEM_AGC_MAXDB_M;
1151 listid_to_enum[4] = ITEM_FILENAME_M;
1152#else
1153 listid_to_enum[2] = ITEM_FILENAME_M;
1154#endif
1155 }
1156 else
1157 {
1158 listid_to_enum[0] = ITEM_VOLUME;
1159 listid_to_enum[1] = ITEM_GAIN;
1160 listid_to_enum[2] = ITEM_GAIN_L;
1161 listid_to_enum[3] = ITEM_GAIN_R;
1162#ifdef HAVE_AGC
1163 listid_to_enum[4] = ITEM_AGC_MODE;
1164 listid_to_enum[5] = ITEM_AGC_MAXDB;
1165 listid_to_enum[6] = ITEM_FILENAME;
1166#else
1167 listid_to_enum[4] = ITEM_FILENAME;
1168#endif
1169 }
1170
1171 if(global_settings.rec_source == AUDIO_SRC_MIC)
1172 gui_synclist_set_nb_items(&lists, ITEM_COUNT_M); /* mono */
1173 else
1174 gui_synclist_set_nb_items(&lists, ITEM_COUNT); /* stereo */
1175 gui_synclist_draw(&lists);
1176 } /* if(done < 0) */
1177
982 audio_stat = audio_status(); 1178 audio_stat = audio_status();
983 1179
984#if (CONFIG_LED == LED_REAL) 1180#if (CONFIG_LED == LED_REAL)
@@ -1028,9 +1224,13 @@ bool recording_screen(bool no_source)
1028 } 1224 }
1029#endif /* CONFIG_LED */ 1225#endif /* CONFIG_LED */
1030 1226
1227 /* first set current vp - stays like this for drawing that follows */
1228 FOR_NB_SCREENS(i)
1229 screens[i].set_viewport(&vp_top[i]);
1230
1031 /* Wait for a button a while (HZ/10) drawing the peak meter */ 1231 /* Wait for a button a while (HZ/10) drawing the peak meter */
1032 button = peak_meter_draw_get_btn(CONTEXT_RECSCREEN, 1232 button = peak_meter_draw_get_btn(CONTEXT_RECSCREEN,
1033 pm_x, pm_y, h * PM_HEIGHT, 1233 pm_x, pm_y, pm_h,
1034 screen_update); 1234 screen_update);
1035 1235
1036 if (last_audio_stat != audio_stat) 1236 if (last_audio_stat != audio_stat)
@@ -1040,9 +1240,9 @@ bool recording_screen(bool no_source)
1040 rec_status |= RCSTAT_HAVE_RECORDED; 1240 rec_status |= RCSTAT_HAVE_RECORDED;
1041 } 1241 }
1042 last_audio_stat = audio_stat; 1242 last_audio_stat = audio_stat;
1243 update_list = true;
1043 } 1244 }
1044 1245
1045
1046 if (recording_start_automatic) 1246 if (recording_start_automatic)
1047 { 1247 {
1048 /* simulate a button press */ 1248 /* simulate a button press */
@@ -1050,133 +1250,29 @@ bool recording_screen(bool no_source)
1050 recording_start_automatic = false; 1250 recording_start_automatic = false;
1051 } 1251 }
1052 1252
1053 switch(button) 1253 /* let list handle the button */
1054 { 1254 gui_synclist_do_button(&lists, &button, LIST_WRAP_UNLESS_HELD);
1055#ifdef HAVE_REMOTE_LCD
1056 case ACTION_REC_LCD:
1057 if (remote_display_on)
1058 {
1059 remote_display_on = false;
1060 screen_update = 1;
1061 screens[1].clear_display();
1062 snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON));
1063 screens[1].puts((screens[1].getwidth()/w - strlen(buf))/2 +
1064 1,
1065 screens[1].getheight()/(h*2) + 1, buf);
1066 screens[1].update();
1067 gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF));
1068 }
1069 else
1070 {
1071 remote_display_on = true;
1072 screen_update = NB_SCREENS;
1073 }
1074 break;
1075#endif
1076 case ACTION_STD_CANCEL:
1077 /* turn off the trigger */
1078 peak_meter_trigger(false);
1079 peak_meter_set_trigger_listener(NULL);
1080 1255
1081 if(audio_stat & AUDIO_STATUS_RECORD) 1256 /* list code changes active viewport - change it back */
1082 { 1257 FOR_NB_SCREENS(i)
1083 rec_command(RECORDING_CMD_STOP); 1258 screens[i].set_viewport(&vp_top[i]);
1084 }
1085 else
1086 {
1087#if CONFIG_CODEC != SWCODEC
1088 peak_meter_playback(true);
1089 peak_meter_enabled = false;
1090#endif
1091 done = true;
1092 }
1093 update_countdown = 1; /* Update immediately */
1094 break;
1095
1096 case ACTION_REC_PAUSE:
1097 case ACTION_REC_NEWFILE:
1098 /* Only act if the mpeg is stopped */
1099 if(!(audio_stat & AUDIO_STATUS_RECORD))
1100 {
1101 /* is this manual or triggered recording? */
1102 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1103 (peak_meter_trigger_status() != TRIG_OFF))
1104 {
1105 /* manual recording */
1106 rec_status |= RCSTAT_HAVE_RECORDED;
1107 rec_command(RECORDING_CMD_START);
1108 last_seconds = 0;
1109 if (global_settings.talk_menu)
1110 {
1111 /* no voice possible here, but a beep */
1112 audio_beep(HZ/2); /* longer beep on start */
1113 }
1114 }
1115 /* this is triggered recording */
1116 else
1117 {
1118 /* we don't start recording now, but enable the
1119 trigger and let the callback function
1120 trigger_listener control when the recording starts */
1121 peak_meter_trigger(true);
1122 peak_meter_set_trigger_listener(&trigger_listener);
1123 }
1124 }
1125 else
1126 {
1127 /*if new file button pressed, start new file */
1128 if (button == ACTION_REC_NEWFILE)
1129 {
1130 rec_command(RECORDING_CMD_START_NEWFILE);
1131 last_seconds = 0;
1132 }
1133 else
1134 /* if pause button pressed, pause or resume */
1135 {
1136 if(audio_stat & AUDIO_STATUS_PAUSE)
1137 {
1138 rec_command(RECORDING_CMD_RESUME);
1139 if (global_settings.talk_menu)
1140 {
1141 /* no voice possible here, but a beep */
1142 audio_beep(HZ/4); /* short beep on resume */
1143 }
1144 }
1145 else
1146 {
1147 rec_command(RECORDING_CMD_PAUSE);
1148 }
1149 }
1150 }
1151 update_countdown = 1; /* Update immediately */
1152 break;
1153
1154 case ACTION_STD_PREV:
1155 cursor--;
1156 adjust_cursor();
1157 update_countdown = 1; /* Update immediately */
1158 break;
1159
1160 case ACTION_STD_NEXT:
1161 cursor++;
1162 adjust_cursor();
1163 update_countdown = 1; /* Update immediately */
1164 break;
1165 1259
1260 switch(button)
1261 {
1166 case ACTION_SETTINGS_INC: 1262 case ACTION_SETTINGS_INC:
1167 case ACTION_SETTINGS_INCREPEAT: 1263 case ACTION_SETTINGS_INCREPEAT:
1168 switch(cursor) 1264 switch (listid_to_enum[gui_synclist_get_sel_pos(&lists)])
1169 { 1265 {
1170 case 0: 1266 case ITEM_VOLUME:
1171 global_settings.volume++; 1267 global_settings.volume++;
1172 setvol(); 1268 setvol();
1173 break; 1269 break;
1174 case 1: 1270 case ITEM_GAIN:
1175 if(global_settings.rec_source == AUDIO_SRC_MIC) 1271 if(global_settings.rec_source == AUDIO_SRC_MIC)
1176 { 1272 {
1177 if(global_settings.rec_mic_gain < 1273 if(global_settings.rec_mic_gain <
1178 sound_max(SOUND_MIC_GAIN)) 1274 sound_max(SOUND_MIC_GAIN))
1179 global_settings.rec_mic_gain++; 1275 global_settings.rec_mic_gain++;
1180 } 1276 }
1181 else 1277 else
1182 { 1278 {
@@ -1188,18 +1284,18 @@ bool recording_screen(bool no_source)
1188 global_settings.rec_right_gain++; 1284 global_settings.rec_right_gain++;
1189 } 1285 }
1190 break; 1286 break;
1191 case 2: 1287 case ITEM_GAIN_L:
1192 if(global_settings.rec_left_gain < 1288 if(global_settings.rec_left_gain <
1193 sound_max(SOUND_LEFT_GAIN)) 1289 sound_max(SOUND_LEFT_GAIN))
1194 global_settings.rec_left_gain++; 1290 global_settings.rec_left_gain++;
1195 break; 1291 break;
1196 case 3: 1292 case ITEM_GAIN_R:
1197 if(global_settings.rec_right_gain < 1293 if(global_settings.rec_right_gain <
1198 sound_max(SOUND_RIGHT_GAIN)) 1294 sound_max(SOUND_RIGHT_GAIN))
1199 global_settings.rec_right_gain++; 1295 global_settings.rec_right_gain++;
1200 break; 1296 break;
1201#ifdef HAVE_AGC 1297#ifdef HAVE_AGC
1202 case 4: 1298 case ITEM_AGC_MODE:
1203 agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE); 1299 agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE);
1204 agc_enable = (agc_preset != 0); 1300 agc_enable = (agc_preset != 0);
1205 if (global_settings.rec_source == AUDIO_SRC_MIC) { 1301 if (global_settings.rec_source == AUDIO_SRC_MIC) {
@@ -1210,7 +1306,7 @@ bool recording_screen(bool no_source)
1210 agc_maxgain = global_settings.rec_agc_maxgain_line; 1306 agc_maxgain = global_settings.rec_agc_maxgain_line;
1211 } 1307 }
1212 break; 1308 break;
1213 case 5: 1309 case ITEM_AGC_MAXDB:
1214 if (global_settings.rec_source == AUDIO_SRC_MIC) 1310 if (global_settings.rec_source == AUDIO_SRC_MIC)
1215 { 1311 {
1216 agc_maxgain = MIN(agc_maxgain + 1, 1312 agc_maxgain = MIN(agc_maxgain + 1,
@@ -1229,16 +1325,15 @@ bool recording_screen(bool no_source)
1229 set_gain(); 1325 set_gain();
1230 update_countdown = 1; /* Update immediately */ 1326 update_countdown = 1; /* Update immediately */
1231 break; 1327 break;
1232
1233 case ACTION_SETTINGS_DEC: 1328 case ACTION_SETTINGS_DEC:
1234 case ACTION_SETTINGS_DECREPEAT: 1329 case ACTION_SETTINGS_DECREPEAT:
1235 switch(cursor) 1330 switch (listid_to_enum[gui_synclist_get_sel_pos(&lists)])
1236 { 1331 {
1237 case 0: 1332 case ITEM_VOLUME:
1238 global_settings.volume--; 1333 global_settings.volume--;
1239 setvol(); 1334 setvol();
1240 break; 1335 break;
1241 case 1: 1336 case ITEM_GAIN:
1242 if(global_settings.rec_source == AUDIO_SRC_MIC) 1337 if(global_settings.rec_source == AUDIO_SRC_MIC)
1243 { 1338 {
1244 if(global_settings.rec_mic_gain > 1339 if(global_settings.rec_mic_gain >
@@ -1255,18 +1350,18 @@ bool recording_screen(bool no_source)
1255 global_settings.rec_right_gain--; 1350 global_settings.rec_right_gain--;
1256 } 1351 }
1257 break; 1352 break;
1258 case 2: 1353 case ITEM_GAIN_L:
1259 if(global_settings.rec_left_gain > 1354 if(global_settings.rec_left_gain >
1260 sound_min(SOUND_LEFT_GAIN)) 1355 sound_min(SOUND_LEFT_GAIN))
1261 global_settings.rec_left_gain--; 1356 global_settings.rec_left_gain--;
1262 break; 1357 break;
1263 case 3: 1358 case ITEM_GAIN_R:
1264 if(global_settings.rec_right_gain > 1359 if(global_settings.rec_right_gain >
1265 sound_min(SOUND_RIGHT_GAIN)) 1360 sound_min(SOUND_RIGHT_GAIN))
1266 global_settings.rec_right_gain--; 1361 global_settings.rec_right_gain--;
1267 break; 1362 break;
1268#ifdef HAVE_AGC 1363#ifdef HAVE_AGC
1269 case 4: 1364 case ITEM_AGC_MODE:
1270 agc_preset = MAX(agc_preset - 1, 0); 1365 agc_preset = MAX(agc_preset - 1, 0);
1271 agc_enable = (agc_preset != 0); 1366 agc_enable = (agc_preset != 0);
1272 if (global_settings.rec_source == AUDIO_SRC_MIC) { 1367 if (global_settings.rec_source == AUDIO_SRC_MIC) {
@@ -1277,7 +1372,7 @@ bool recording_screen(bool no_source)
1277 agc_maxgain = global_settings.rec_agc_maxgain_line; 1372 agc_maxgain = global_settings.rec_agc_maxgain_line;
1278 } 1373 }
1279 break; 1374 break;
1280 case 5: 1375 case ITEM_AGC_MAXDB:
1281 if (global_settings.rec_source == AUDIO_SRC_MIC) 1376 if (global_settings.rec_source == AUDIO_SRC_MIC)
1282 { 1377 {
1283 agc_maxgain = MAX(agc_maxgain - 1, 1378 agc_maxgain = MAX(agc_maxgain - 1,
@@ -1296,25 +1391,123 @@ bool recording_screen(bool no_source)
1296 set_gain(); 1391 set_gain();
1297 update_countdown = 1; /* Update immediately */ 1392 update_countdown = 1; /* Update immediately */
1298 break; 1393 break;
1394 case ACTION_STD_CANCEL:
1395 /* turn off the trigger */
1396 peak_meter_trigger(false);
1397 peak_meter_set_trigger_listener(NULL);
1299 1398
1399 if(audio_stat & AUDIO_STATUS_RECORD)
1400 {
1401 rec_command(RECORDING_CMD_STOP);
1402 }
1403 else
1404 {
1405#if CONFIG_CODEC != SWCODEC
1406 peak_meter_playback(true);
1407 peak_meter_enabled = false;
1408#endif
1409 done = 1;
1410 }
1411 update_countdown = 1; /* Update immediately */
1412 break;
1413#ifdef HAVE_REMOTE_LCD
1414 case ACTION_REC_LCD:
1415 /* this feature exists for some h1x0/h3x0 targets that suffer
1416 from noise caused by remote LCD updates
1417 NOTE 1: this will leave the list on the remote
1418 NOTE 2: to be replaced by a global LCD_off() routine */
1419 if(remote_display_on)
1420 {
1421 /* switch to single screen and put up a splash on the main.
1422 On the remote we put a two line message */
1423 screen_update = 1;
1424 screens[1].clear_viewport();
1425 screens[1].puts(0, 0, str(LANG_REMOTE_LCD_OFF));
1426 screens[1].puts(0, 1, str(LANG_REMOTE_LCD_ON));
1427 screens[1].update_viewport();
1428 gui_splash(&screens[0], 0, str(LANG_REMOTE_LCD_OFF));
1429 }
1430 else
1431 {
1432 /* remote switched on again */
1433 update_list = true;
1434 screen_update = NB_SCREENS;
1435 }
1436 remote_display_on = !remote_display_on; /* toggle */
1437 update_countdown = 1; /* Update immediately */
1438 break;
1439#endif
1440 case ACTION_REC_PAUSE:
1441 case ACTION_REC_NEWFILE:
1442 /* Only act if the mpeg is stopped */
1443 if(!(audio_stat & AUDIO_STATUS_RECORD))
1444 {
1445 /* is this manual or triggered recording? */
1446 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1447 (peak_meter_trigger_status() != TRIG_OFF))
1448 {
1449 /* manual recording */
1450 rec_status |= RCSTAT_HAVE_RECORDED;
1451 rec_command(RECORDING_CMD_START);
1452 last_seconds = 0;
1453 if (global_settings.talk_menu)
1454 {
1455 /* no voice possible here, but a beep */
1456 audio_beep(HZ/2); /* longer beep on start */
1457 }
1458 }
1459 /* this is triggered recording */
1460 else
1461 {
1462 /* we don't start recording now, but enable the
1463 trigger and let the callback function
1464 trigger_listener control when the recording starts */
1465 peak_meter_trigger(true);
1466 peak_meter_set_trigger_listener(&trigger_listener);
1467 }
1468 }
1469 else
1470 {
1471 /*if new file button pressed, start new file */
1472 if (button == ACTION_REC_NEWFILE)
1473 {
1474 rec_command(RECORDING_CMD_START_NEWFILE);
1475 last_seconds = 0;
1476 }
1477 else
1478 /* if pause button pressed, pause or resume */
1479 {
1480 if(audio_stat & AUDIO_STATUS_PAUSE)
1481 {
1482 rec_command(RECORDING_CMD_RESUME);
1483 if (global_settings.talk_menu)
1484 {
1485 /* no voice possible here, but a beep */
1486 audio_beep(HZ/4); /* short beep on resume */
1487 }
1488 }
1489 else
1490 {
1491 rec_command(RECORDING_CMD_PAUSE);
1492 }
1493 }
1494 }
1495 update_countdown = 1; /* Update immediately */
1496 break;
1300 case ACTION_STD_MENU: 1497 case ACTION_STD_MENU:
1301#if CONFIG_CODEC == SWCODEC 1498#if CONFIG_CODEC == SWCODEC
1302 if(!(audio_stat & AUDIO_STATUS_RECORD)) 1499 if(!(audio_stat & AUDIO_STATUS_RECORD))
1303#else 1500#else
1304 if(audio_stat != AUDIO_STATUS_RECORD) 1501 if(audio_stat != AUDIO_STATUS_RECORD)
1305#endif 1502#endif
1306 { 1503 {
1307#ifdef HAVE_FMRADIO_REC
1308 const int prev_rec_source = global_settings.rec_source;
1309#endif
1310
1311#if (CONFIG_LED == LED_REAL) 1504#if (CONFIG_LED == LED_REAL)
1312 /* led is restored at begin of loop / end of function */ 1505 /* led is restored at begin of loop / end of function */
1313 led(false); 1506 led(false);
1314#endif 1507#endif
1315 if (recording_menu(no_source)) 1508 if (recording_menu(no_source))
1316 { 1509 {
1317 done = true; 1510 done = 1;
1318 rec_status |= RCSTAT_BEEN_IN_USB_MODE; 1511 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1319#ifdef HAVE_FMRADIO_REC 1512#ifdef HAVE_FMRADIO_REC
1320 radio_status = FMRADIO_OFF; 1513 radio_status = FMRADIO_OFF;
@@ -1322,53 +1515,8 @@ bool recording_screen(bool no_source)
1322 } 1515 }
1323 else 1516 else
1324 { 1517 {
1325#ifdef HAVE_FMRADIO_REC 1518 done = -1;
1326 /* If input changes away from FM Radio, radio will 1519 /* the init is now done at the beginning of the loop */
1327 remain off when recording screen closes. */
1328 if (global_settings.rec_source != prev_rec_source
1329 && prev_rec_source == AUDIO_SRC_FMRADIO)
1330 radio_status = FMRADIO_OFF;
1331#endif
1332
1333#if CONFIG_CODEC == SWCODEC
1334 /* reinit after submenu exit */
1335 audio_close_recording();
1336 audio_init_recording(0);
1337#endif
1338
1339 rec_init_recording_options(&rec_options);
1340 rec_set_recording_options(&rec_options);
1341
1342 if(rec_create_directory() < 0)
1343 {
1344 goto rec_abort;
1345 }
1346
1347#if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
1348 /* If format changed, a new number is required */
1349 rec_init_filename();
1350#endif
1351
1352#ifdef HAVE_AGC
1353 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1354 agc_preset = global_settings.rec_agc_preset_mic;
1355 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1356 }
1357 else {
1358 agc_preset = global_settings.rec_agc_preset_line;
1359 agc_maxgain = global_settings.rec_agc_maxgain_line;
1360 }
1361#endif
1362
1363 adjust_cursor();
1364 set_gain();
1365 update_countdown = 1; /* Update immediately */
1366
1367 FOR_NB_SCREENS(i)
1368 {
1369 screens[i].set_viewport(&vp[i]);
1370 screens[i].setfont(FONT_SYSFIXED);
1371 }
1372 } 1520 }
1373 } 1521 }
1374 break; 1522 break;
@@ -1418,6 +1566,8 @@ bool recording_screen(bool no_source)
1418 /* Only accept USB connection when not recording */ 1566 /* Only accept USB connection when not recording */
1419 if(!(audio_stat & AUDIO_STATUS_RECORD)) 1567 if(!(audio_stat & AUDIO_STATUS_RECORD))
1420 { 1568 {
1569 FOR_NB_SCREENS(i)
1570 screens[i].set_viewport(NULL);
1421 default_event_handler(SYS_USB_CONNECTED); 1571 default_event_handler(SYS_USB_CONNECTED);
1422 done = true; 1572 done = true;
1423 rec_status |= RCSTAT_BEEN_IN_USB_MODE; 1573 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
@@ -1426,11 +1576,7 @@ bool recording_screen(bool no_source)
1426#endif 1576#endif
1427 } 1577 }
1428 break; 1578 break;
1429 1579 } /*switch(button)*/
1430 default:
1431 default_event_handler(button);
1432 break;
1433 } /* end switch */
1434 1580
1435#ifdef HAVE_AGC 1581#ifdef HAVE_AGC
1436 peak_read = !peak_read; 1582 peak_read = !peak_read;
@@ -1444,17 +1590,17 @@ bool recording_screen(bool no_source)
1444 auto_gain_control(&peak_l, &peak_r, &balance); 1590 auto_gain_control(&peak_l, &peak_r, &balance);
1445#endif 1591#endif
1446 1592
1447 FOR_NB_SCREENS(i)
1448 screens[i].setfont(FONT_SYSFIXED);
1449
1450 seconds = audio_recorded_time() / HZ; 1593 seconds = audio_recorded_time() / HZ;
1451 1594
1452 update_countdown--; 1595 /* start of vp_top drawing */
1453 if(update_countdown == 0 || seconds > last_seconds) 1596 if(update_countdown-- == 0 || seconds > last_seconds)
1454 { 1597 {
1455 unsigned int dseconds, dhours, dminutes; 1598 unsigned int dseconds, dhours, dminutes;
1456 unsigned long num_recorded_bytes, dsize, dmb; 1599 unsigned long num_recorded_bytes, dsize, dmb;
1457 int pos = 0; 1600
1601 /* we assume vp_top is the current viewport! */
1602 FOR_NB_ACTIVE_SCREENS(i)
1603 screens[i].clear_viewport();
1458 1604
1459 update_countdown = 5; 1605 update_countdown = 5;
1460 last_seconds = seconds; 1606 last_seconds = seconds;
@@ -1463,17 +1609,6 @@ bool recording_screen(bool no_source)
1463 dsize = rec_sizesplit_bytes(); 1609 dsize = rec_sizesplit_bytes();
1464 num_recorded_bytes = audio_num_recorded_bytes(); 1610 num_recorded_bytes = audio_num_recorded_bytes();
1465 1611
1466 for(i = 0; i < screen_update; i++)
1467 screens[i].clear_display();
1468
1469 style = base_style;
1470
1471#ifdef HAVE_LCD_COLOR
1472 /* special action for gradient - set default for 1 line gradient */
1473 if(global_settings.cursor_style == 3)
1474 style = base_style | CURLN_PACK(0) | NUMLN_PACK(1);
1475#endif /* HAVE_LCD_COLOR */
1476
1477#if CONFIG_CODEC == SWCODEC 1612#if CONFIG_CODEC == SWCODEC
1478 if ((audio_stat & AUDIO_STATUS_WARNING) 1613 if ((audio_stat & AUDIO_STATUS_WARNING)
1479 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2) 1614 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
@@ -1493,40 +1628,39 @@ bool recording_screen(bool no_source)
1493 { 1628 {
1494 dmb = dsize/1024/1024; 1629 dmb = dsize/1024/1024;
1495 snprintf(buf, sizeof(buf), "%s %dMB", 1630 snprintf(buf, sizeof(buf), "%s %dMB",
1496 str(LANG_SYSFONT_SPLIT_SIZE), dmb); 1631 str(LANG_SPLIT_SIZE), dmb);
1497 } 1632 }
1498 else 1633 else
1499 { 1634 {
1500 hours = seconds / 3600; 1635 hours = seconds / 3600;
1501 minutes = (seconds - (hours * 3600)) / 60; 1636 minutes = (seconds - (hours * 3600)) / 60;
1502 snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d", 1637 snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d",
1503 str(LANG_SYSFONT_RECORDING_TIME), 1638 str(LANG_RECORDING_TIME),
1504 hours, minutes, seconds%60); 1639 hours, minutes, seconds%60);
1505 } 1640 }
1506 1641
1507 for(i = 0; i < screen_update; i++) 1642 FOR_NB_ACTIVE_SCREENS(i)
1508 screens[i].puts(0, 0, buf); 1643 screens[i].puts(0, 0, buf);
1509 1644
1510 if(audio_stat & AUDIO_STATUS_PRERECORD) 1645 if(audio_stat & AUDIO_STATUS_PRERECORD)
1511 { 1646 {
1512 snprintf(buf, sizeof(buf), "%s...", 1647 snprintf(buf, sizeof(buf), "%s...",
1513 str(LANG_SYSFONT_RECORD_PRERECORD)); 1648 str(LANG_RECORD_PRERECORD));
1514 } 1649 }
1515 else 1650 else
1516 { 1651 {
1517 /* Display the split interval if the record timesplit 1652 /* Display the split interval if the record timesplit
1518 is active */ 1653 is active */
1519 if ((global_settings.rec_timesplit) && 1654 if ((global_settings.rec_timesplit) &&
1520 !(global_settings.rec_split_method)) 1655 !(global_settings.rec_split_method))
1521 { 1656 {
1522 /* Display the record timesplit interval rather 1657 /* Display the record timesplit interval rather
1523 than the file size if the record timer is 1658 than the file size if the record timer is active */
1524 active */
1525 dhours = dseconds / 3600; 1659 dhours = dseconds / 3600;
1526 dminutes = (dseconds - (dhours * 3600)) / 60; 1660 dminutes = (dseconds - (dhours * 3600)) / 60;
1527 snprintf(buf, sizeof(buf), "%s %02d:%02d", 1661 snprintf(buf, sizeof(buf), "%s %02d:%02d",
1528 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC), 1662 str(LANG_RECORDING_TIMESPLIT_REC),
1529 dhours, dminutes); 1663 dhours, dminutes);
1530 } 1664 }
1531 else 1665 else
1532 { 1666 {
@@ -1534,42 +1668,25 @@ bool recording_screen(bool no_source)
1534 num_recorded_bytes, 1668 num_recorded_bytes,
1535 byte_units, true); 1669 byte_units, true);
1536 snprintf(buf, sizeof(buf), "%s %s", 1670 snprintf(buf, sizeof(buf), "%s %s",
1537 str(LANG_SYSFONT_RECORDING_SIZE), buf2); 1671 str(LANG_RECORDING_SIZE), buf2);
1538 } 1672 }
1539 } 1673 }
1540 for(i = 0; i < screen_update; i++)
1541 screens[i].puts(0, 1, buf);
1542 1674
1543 for(i = 0; i < screen_update; i++) 1675 FOR_NB_ACTIVE_SCREENS(i)
1544 { 1676 screens[i].puts(0, 1, buf);
1545 if (filename_offset[i] > 0)
1546 {
1547 *filename = '\0';
1548 if (audio_stat & AUDIO_STATUS_RECORD)
1549 {
1550 strncpy(filename, path_buffer +
1551 strlen(path_buffer) - 12, 13);
1552 filename[12]='\0';
1553 }
1554
1555 snprintf(buf, sizeof(buf), "%s %s",
1556 str(LANG_SYSFONT_RECORDING_FILENAME), filename);
1557 screens[i].puts(0, 2, buf);
1558 }
1559 }
1560 1677
1561 /* We will do file splitting regardless, either at the end of 1678 /* We will do file splitting regardless, either at the end of
1562 a split interval, or when the filesize approaches the 2GB 1679 a split interval, or when the filesize approaches the 2GB
1563 FAT file size (compatibility) limit. */ 1680 FAT file size (compatibility) limit. */
1564 if ((audio_stat && !(global_settings.rec_split_method) 1681 if ((audio_stat && !(global_settings.rec_split_method)
1565 && global_settings.rec_timesplit && (seconds >= dseconds)) 1682 && global_settings.rec_timesplit && (seconds >= dseconds))
1566 || (audio_stat && global_settings.rec_split_method 1683 || (audio_stat && global_settings.rec_split_method
1567 && global_settings.rec_sizesplit 1684 && global_settings.rec_sizesplit
1568 && (num_recorded_bytes >= dsize)) 1685 && (num_recorded_bytes >= dsize))
1569 || (num_recorded_bytes >= MAX_FILE_SIZE)) 1686 || (num_recorded_bytes >= MAX_FILE_SIZE))
1570 { 1687 {
1571 if (!(global_settings.rec_split_type) 1688 if (!(global_settings.rec_split_type)
1572 || (num_recorded_bytes >= MAX_FILE_SIZE)) 1689 || (num_recorded_bytes >= MAX_FILE_SIZE))
1573 { 1690 {
1574 rec_command(RECORDING_CMD_START_NEWFILE); 1691 rec_command(RECORDING_CMD_START_NEWFILE);
1575 last_seconds = 0; 1692 last_seconds = 0;
@@ -1591,214 +1708,28 @@ bool recording_screen(bool no_source)
1591 { 1708 {
1592 char clpstr[32]; 1709 char clpstr[32];
1593 snprintf(clpstr, 32, "%4d", pm_get_clipcount()); 1710 snprintf(clpstr, 32, "%4d", pm_get_clipcount());
1594 for(i = 0; i < screen_update; i++) 1711 FOR_NB_ACTIVE_SCREENS(i)
1595 {
1596 if(PM_HEIGHT > 1)
1597 screens[i].puts(0, 2 + filename_offset[i],
1598 str(LANG_SYSFONT_PM_CLIPCOUNT));
1599 screens[i].puts(0, 1 + PM_HEIGHT + filename_offset[i],
1600 clpstr);
1601 }
1602 }
1603
1604 snprintf(buf, sizeof(buf), "%s: %s", str(LANG_SYSFONT_VOLUME),
1605 fmt_gain(SOUND_VOLUME,
1606 global_settings.volume,
1607 buf2, sizeof(buf2)));
1608
1609 if (global_settings.cursor_style && (pos++ == cursor))
1610 {
1611 for(i = 0; i < screen_update; i++)
1612 screens[i].puts_style_offset(0, filename_offset[i] +
1613 PM_HEIGHT + 2, buf, style,0);
1614 }
1615 else
1616 {
1617 for(i = 0; i < screen_update; i++)
1618 screens[i].putsxy(ymargin,
1619 SYSFONT_HEIGHT*(filename_offset[i]+
1620 PM_HEIGHT + 2), buf);
1621 }
1622
1623 if(global_settings.rec_source == AUDIO_SRC_MIC)
1624 {
1625 /* Draw MIC recording gain */
1626 snprintf(buf, sizeof(buf), "%s:%s", str(LANG_SYSFONT_GAIN),
1627 fmt_gain(SOUND_MIC_GAIN,
1628 global_settings.rec_mic_gain,
1629 buf2, sizeof(buf2)));
1630 if(global_settings.cursor_style && ((1==cursor)||(2==cursor)))
1631 {
1632 for(i = 0; i < screen_update; i++)
1633 screens[i].puts_style_offset(0, filename_offset[i] +
1634 PM_HEIGHT + 3, buf, style,0);
1635 }
1636 else
1637 {
1638 for(i = 0; i < screen_update; i++)
1639 screens[i].putsxy(ymargin,
1640 SYSFONT_HEIGHT*(filename_offset[i] +
1641 PM_HEIGHT + 3), buf);
1642 }
1643 }
1644 else if(0
1645 HAVE_LINE_REC_( || global_settings.rec_source ==
1646 AUDIO_SRC_LINEIN)
1647 HAVE_FMRADIO_REC_( || global_settings.rec_source ==
1648 AUDIO_SRC_FMRADIO)
1649 )
1650 {
1651 /* Draw LINE or FMRADIO recording gain */
1652 snprintf(buf, sizeof(buf), "%s:%s",
1653 str(LANG_SYSFONT_RECORDING_LEFT),
1654 fmt_gain(SOUND_LEFT_GAIN,
1655 global_settings.rec_left_gain,
1656 buf2, sizeof(buf2)));
1657#ifdef HAVE_LCD_COLOR
1658 /* special action for gradient - double line gradient - line1 */
1659 if((global_settings.cursor_style == 3) &&
1660 (1==cursor))
1661 style = base_style | CURLN_PACK(0) | NUMLN_PACK(2);
1662#endif /* HAVE_LCD_COLOR */
1663 if(global_settings.cursor_style && ((1==cursor)||(2==cursor)))
1664 {
1665 for(i = 0; i < screen_update; i++)
1666 screens[i].puts_style_offset(0, filename_offset[i] +
1667 PM_HEIGHT + 3, buf, style,0);
1668 }
1669 else
1670 {
1671 for(i = 0; i < screen_update; i++)
1672 screens[i].putsxy(ymargin,
1673 SYSFONT_HEIGHT*(filename_offset[i] +
1674 PM_HEIGHT + 3), buf);
1675 }
1676
1677 snprintf(buf, sizeof(buf), "%s:%s",
1678 str(LANG_SYSFONT_RECORDING_RIGHT),
1679 fmt_gain(SOUND_RIGHT_GAIN,
1680 global_settings.rec_right_gain,
1681 buf2, sizeof(buf2)));
1682#ifdef HAVE_LCD_COLOR
1683 /* special action for gradient - double line gradient - line2 */
1684 if((global_settings.cursor_style == 3) &&
1685 (1==cursor))
1686 style = base_style | CURLN_PACK(1) | NUMLN_PACK(2);
1687#endif /* HAVE_LCD_COLOR */
1688 if(global_settings.cursor_style && ((1==cursor)||(3==cursor)))
1689 {
1690 for(i = 0; i < screen_update; i++)
1691 screens[i].puts_style_offset(0, filename_offset[i] +
1692 PM_HEIGHT + 4, buf, style,0);
1693 }
1694 else
1695 { 1712 {
1696 for(i = 0; i < screen_update; i++) 1713 screens[i].puts(0, 2,str(LANG_PM_CLIPCOUNT));
1697 screens[i].putsxy(ymargin, 1714 screens[i].puts(0, 3, clpstr);
1698 SYSFONT_HEIGHT*(filename_offset[i] +
1699 PM_HEIGHT + 4), buf);
1700 } 1715 }
1701 } 1716 }
1702#ifdef HAVE_LCD_COLOR
1703 /* special action for gradient - back to single line gradient */
1704 if(global_settings.cursor_style == 3)
1705 style = base_style | CURLN_PACK(0) | NUMLN_PACK(1);
1706#endif /* HAVE_LCD_COLOR */
1707 1717
1708 FOR_NB_SCREENS(i)
1709 {
1710 switch (global_settings.rec_source)
1711 {
1712 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
1713 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
1714 line[i] = 5;
1715 break;
1716
1717 case AUDIO_SRC_MIC:
1718 line[i] = 4;
1719 break;
1720#ifdef HAVE_SPDIF_REC
1721 case AUDIO_SRC_SPDIF:
1722 line[i] = 3;
1723 break;
1724#endif
1725 default:
1726 line[i] = 5; /* to prevent uninitialisation
1727 warnings for line[0] */
1728 break;
1729 } /* end switch */
1730#ifdef HAVE_AGC 1718#ifdef HAVE_AGC
1731 if (vp[i].height < h * (2 + filename_offset[i] + 1719 hist_time++;
1732 PM_HEIGHT + line[i])) 1720#endif
1733 {
1734 line[i] -= 1;
1735 display_agc[i] = false;
1736 }
1737 else
1738 display_agc[i] = true;
1739
1740 if ((cursor==4) || (cursor==5))
1741 display_agc[i] = true;
1742 }
1743
1744 /************** AGC test info ******************
1745 snprintf(buf, sizeof(buf), "D:%d U:%d",
1746 (agc_droptime+2)/5, (agc_risetime+2)/5);
1747 lcd_putsxy(1, LCD_HEIGHT - 8, buf);
1748 snprintf(buf, sizeof(buf), "B:%d",
1749 (agc_baltime+2)/5);
1750 lcd_putsxy(LCD_WIDTH/2 + 3, LCD_HEIGHT - 8, buf);
1751 ***********************************************/
1752
1753 if (cursor == 5)
1754 snprintf(buf, sizeof(buf), "%s: %s",
1755 str(LANG_SYSFONT_RECORDING_AGC_MAXGAIN),
1756 fmt_gain(SOUND_LEFT_GAIN,
1757 agc_maxgain, buf2, sizeof(buf2)));
1758 else if (agc_preset == 0)
1759 snprintf(buf, sizeof(buf), "%s: %s",
1760 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1761 agc_preset_str[agc_preset]);
1762 else if (global_settings.rec_source == AUDIO_SRC_MIC)
1763 snprintf(buf, sizeof(buf), "%s: %s%s",
1764 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1765 agc_preset_str[agc_preset],
1766 fmt_gain(SOUND_LEFT_GAIN,
1767 agc_maxgain -
1768 global_settings.rec_mic_gain,
1769 buf2, sizeof(buf2)));
1770 else
1771 snprintf(buf, sizeof(buf), "%s: %s%s",
1772 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1773 agc_preset_str[agc_preset],
1774 fmt_gain(SOUND_LEFT_GAIN,
1775 agc_maxgain -
1776 (global_settings.rec_left_gain +
1777 global_settings.rec_right_gain)/2,
1778 buf2, sizeof(buf2)));
1779 1721
1780 if(global_settings.cursor_style && ((cursor==4) || (cursor==5))) 1722 /* draw the trigger status */
1781 { 1723 if (peak_meter_trigger_status() != TRIG_OFF)
1782 for(i = 0; i < screen_update; i++)
1783 screens[i].puts_style_offset(0, filename_offset[i] +
1784 PM_HEIGHT + line[i], buf, style,0);
1785 }
1786 else if (global_settings.rec_source == AUDIO_SRC_MIC
1787 HAVE_LINE_REC_(|| global_settings.rec_source ==
1788 AUDIO_SRC_LINEIN)
1789 HAVE_FMRADIO_REC_(|| global_settings.rec_source ==
1790 AUDIO_SRC_FMRADIO)
1791 )
1792 { 1724 {
1793 for(i = 0; i < screen_update; i++) { 1725 peak_meter_draw_trig(pm_x, trig_ypos, trig_width,
1794 if (display_agc[i]) { 1726 screen_update);
1795 screens[i].putsxy(ymargin, 1727 FOR_NB_ACTIVE_SCREENS(i)
1796 SYSFONT_HEIGHT*(filename_offset[i] + 1728 screens[i].update_viewport_rect(pm_x[i], trig_ypos[i],
1797 PM_HEIGHT + line[i]), buf); 1729 trig_width[i] + 2, TRIG_HEIGHT);
1798 }
1799 }
1800 } 1730 }
1801 1731
1732#ifdef HAVE_AGC
1802 if (global_settings.rec_source == AUDIO_SRC_MIC) 1733 if (global_settings.rec_source == AUDIO_SRC_MIC)
1803 { 1734 {
1804 if(agc_maxgain < (global_settings.rec_mic_gain)) 1735 if(agc_maxgain < (global_settings.rec_mic_gain))
@@ -1811,98 +1742,25 @@ bool recording_screen(bool no_source)
1811 if(agc_maxgain < (global_settings.rec_right_gain)) 1742 if(agc_maxgain < (global_settings.rec_right_gain))
1812 change_recording_gain(false, false, true); 1743 change_recording_gain(false, false, true);
1813 } 1744 }
1814#else /* !HAVE_AGC */
1815 }
1816#endif /* HAVE_AGC */ 1745#endif /* HAVE_AGC */
1817 1746
1818 if(!global_settings.cursor_style) { 1747 if(update_list)
1819 switch(cursor) 1748 {
1820 { 1749 /* update_list is set whenever content changes */
1821 case 1: 1750 update_list = false;
1822 for(i = 0; i < screen_update; i++) 1751 gui_synclist_draw(&lists);
1823 screen_put_cursorxy(&screens[i], 0,
1824 filename_offset[i] +
1825 PM_HEIGHT + 3, true);
1826
1827 if(global_settings.rec_source != AUDIO_SRC_MIC)
1828 {
1829 for(i = 0; i < screen_update; i++)
1830 screen_put_cursorxy(&screens[i], 0,
1831 filename_offset[i] +
1832 PM_HEIGHT + 4, true);
1833 }
1834 break;
1835 case 2:
1836 for(i = 0; i < screen_update; i++)
1837 screen_put_cursorxy(&screens[i], 0,
1838 filename_offset[i] +
1839 PM_HEIGHT + 3, true);
1840 break;
1841 case 3:
1842 for(i = 0; i < screen_update; i++)
1843 screen_put_cursorxy(&screens[i], 0,
1844 filename_offset[i] +
1845 PM_HEIGHT + 4, true);
1846 break;
1847#ifdef HAVE_AGC
1848 case 4:
1849 case 5:
1850 for(i = 0; i < screen_update; i++)
1851 screen_put_cursorxy(&screens[i], 0,
1852 filename_offset[i] +
1853 PM_HEIGHT + line[i], true);
1854 break;
1855#endif /* HAVE_AGC */
1856 default:
1857 for(i = 0; i < screen_update; i++)
1858 screen_put_cursorxy(&screens[i], 0,
1859 filename_offset[i] +
1860 PM_HEIGHT + 2, true);
1861 }
1862 } 1752 }
1863 1753
1864#ifdef HAVE_AGC 1754 /* draw peakmeter again (check if this can be removed) */
1865 hist_time++; 1755 FOR_NB_ACTIVE_SCREENS(i)
1866#endif
1867
1868 for(i = 0; i < screen_update; i++)
1869 { 1756 {
1870 screens[i].set_viewport(NULL); 1757 screens[i].set_viewport(NULL);
1871 gui_statusbar_draw(&(statusbars.statusbars[i]), true); 1758 gui_statusbar_draw(&(statusbars.statusbars[i]), true);
1872 screens[i].set_viewport(&vp[i]); 1759 screens[i].set_viewport(&vp_top[i]);
1873 peak_meter_screen(&screens[i], pm_x, pm_y[i], h*PM_HEIGHT); 1760 peak_meter_screen(&screens[i], pm_x[i], pm_y[i], pm_h[i]);
1874 screens[i].update(); 1761 screens[i].update();
1875 } 1762 }
1876 1763 } /* display update every second */
1877 /* draw the trigger status */
1878 FOR_NB_SCREENS(i)
1879 {
1880 /* NOTE: UGLY width setting based on height! To be fixed! */
1881 trig_width[i] = ((vp[i].height < 64) ||
1882 ((vp[i].height < 72) && (PM_HEIGHT > 1))) ?
1883 screens[i].getwidth() - 14 * w :
1884 screens[i].getwidth();
1885 trig_xpos[i] = screens[i].getwidth() - trig_width[i];
1886 trig_ypos[i] = ((vp[i].height < 72) && (PM_HEIGHT > 1)) ?
1887 h*2 :
1888 h*(1 + filename_offset[i] + PM_HEIGHT +
1889 line[i]
1890#ifdef HAVE_AGC
1891 + 1
1892#endif
1893 );
1894 }
1895
1896 if (peak_meter_trigger_status() != TRIG_OFF)
1897 {
1898 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width,
1899 screen_update);
1900 for(i = 0; i < screen_update; i++){
1901 screens[i].update_rect(trig_xpos[i], trig_ypos[i],
1902 trig_width[i] + 2, TRIG_HEIGHT);
1903 }
1904 }
1905 }
1906 1764
1907 if(audio_stat & AUDIO_STATUS_ERROR) 1765 if(audio_stat & AUDIO_STATUS_ERROR)
1908 { 1766 {
@@ -1913,7 +1771,7 @@ bool recording_screen(bool no_source)
1913 audio_stat = audio_status(); 1771 audio_stat = audio_status();
1914 if (audio_stat & AUDIO_STATUS_ERROR) 1772 if (audio_stat & AUDIO_STATUS_ERROR)
1915 { 1773 {
1916 gui_syncsplash(0, str(LANG_SYSFONT_DISK_FULL)); 1774 gui_syncsplash(0, str(LANG_DISK_FULL));
1917 gui_syncstatusbar_draw(&statusbars, true); 1775 gui_syncstatusbar_draw(&statusbars, true);
1918 1776
1919 FOR_NB_SCREENS(i) 1777 FOR_NB_SCREENS(i)
@@ -1977,6 +1835,11 @@ rec_abort:
1977 ata_set_led_enabled(true); 1835 ata_set_led_enabled(true);
1978#endif 1836#endif
1979 1837
1838#if CONFIG_TUNER
1839 global_settings.statusbar = statusbar;
1840 global_status.statusbar_forced = 0;
1841#endif
1842
1980 settings_save(); 1843 settings_save();
1981 1844
1982 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0; 1845 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
@@ -2056,10 +1919,10 @@ static bool f2_rec_screen(void)
2056 { 1919 {
2057 screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h); 1920 screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h);
2058 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, 1921 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
2059 str(LANG_SYSFONT_CHANNELS)); 1922 str(LANG_SYSFONT_CHANNELS));
2060 screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h); 1923 screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h);
2061 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, 1924 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h,
2062 str(LANG_SYSFONT_MODE)); 1925 str(LANG_SYSFONT_MODE));
2063 screens[i].getstringsize(ptr, &w, &h); 1926 screens[i].getstringsize(ptr, &w, &h);
2064 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr); 1927 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
2065 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward], 1928 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward],