diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-01-14 00:53:44 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-01-17 00:37:12 +0000 |
commit | f68c6c14d9523b45d67d39cd97e40a44e9932c95 (patch) | |
tree | cf2675d23c79f5c26ce31e9af0d45e77411bedf3 | |
parent | acc7d16e3b5ffcd50e9c5832c43eacb673386830 (diff) | |
download | rockbox-f68c6c14d9523b45d67d39cd97e40a44e9932c95.tar.gz rockbox-f68c6c14d9523b45d67d39cd97e40a44e9932c95.zip |
recscreen: clean up menu building code
Remove the use of constants and ifdefs in favor of a
single enum and build the menu with a counter. This
simplifies the source and optimizes to the same code.
Change-Id: Ib07f0634ac8f663452c3e6e3c3d92fb6da1a1b4c
-rw-r--r-- | apps/recorder/recording.c | 92 |
1 files changed, 31 insertions, 61 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index d4320122f6..7215812f49 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -739,43 +739,22 @@ static void trigger_listener(int trigger_status) | |||
739 | /* Stuff for drawing the screen */ | 739 | /* Stuff for drawing the screen */ |
740 | 740 | ||
741 | enum rec_list_items_stereo { | 741 | enum rec_list_items_stereo { |
742 | ITEM_VOLUME = 0, | 742 | ITEM_VOLUME, |
743 | ITEM_GAIN = 1, | 743 | ITEM_GAIN, |
744 | ITEM_GAIN_L = 2, | 744 | #if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC) |
745 | ITEM_GAIN_R = 3, | 745 | ITEM_GAIN_L, |
746 | #ifdef HAVE_AGC | 746 | ITEM_GAIN_R, |
747 | ITEM_AGC_MODE = 4, | ||
748 | ITEM_AGC_MAXDB = 5, | ||
749 | ITEM_FILENAME = 7, | ||
750 | ITEM_COUNT = 7, | ||
751 | #else | ||
752 | ITEM_FILENAME = 7, | ||
753 | ITEM_COUNT = 5, | ||
754 | #endif | 747 | #endif |
755 | }; | ||
756 | |||
757 | enum rec_list_items_mono { | ||
758 | ITEM_VOLUME_M = 0, | ||
759 | ITEM_GAIN_M = 1, | ||
760 | #ifdef HAVE_AGC | 748 | #ifdef HAVE_AGC |
761 | ITEM_AGC_MODE_M = 4, | 749 | ITEM_AGC_MODE, |
762 | ITEM_AGC_MAXDB_M = 5, | 750 | ITEM_AGC_MAXDB, |
763 | ITEM_FILENAME_M = 7, | ||
764 | ITEM_COUNT_M = 5, | ||
765 | #else | ||
766 | ITEM_FILENAME_M = 7, | ||
767 | ITEM_COUNT_M = 3, | ||
768 | #endif | 751 | #endif |
769 | }; | ||
770 | |||
771 | #ifdef HAVE_SPDIF_REC | 752 | #ifdef HAVE_SPDIF_REC |
772 | enum rec_list_items_spdif { | 753 | ITEM_SAMPLERATE, |
773 | ITEM_VOLUME_D = 0, | ||
774 | ITEM_SAMPLERATE_D = 6, | ||
775 | ITEM_FILENAME_D = 7, | ||
776 | ITEM_COUNT_D = 3, | ||
777 | }; | ||
778 | #endif | 754 | #endif |
755 | ITEM_FILENAME, | ||
756 | ITEM_COUNT, | ||
757 | }; | ||
779 | 758 | ||
780 | static int listid_to_enum[ITEM_COUNT]; | 759 | static int listid_to_enum[ITEM_COUNT]; |
781 | 760 | ||
@@ -876,7 +855,7 @@ static const char* reclist_get_name(int selected_item, void * data, | |||
876 | } break; | 855 | } break; |
877 | #endif | 856 | #endif |
878 | #ifdef HAVE_SPDIF_REC | 857 | #ifdef HAVE_SPDIF_REC |
879 | case ITEM_SAMPLERATE_D: | 858 | case ITEM_SAMPLERATE: |
880 | snprintf(buffer, buffer_len, "%s: %lu", | 859 | snprintf(buffer, buffer_len, "%s: %lu", |
881 | str(LANG_FREQUENCY), pcm_rec_sample_rate()); | 860 | str(LANG_FREQUENCY), pcm_rec_sample_rate()); |
882 | break; | 861 | break; |
@@ -1170,46 +1149,37 @@ bool recording_screen(bool no_source) | |||
1170 | set_gain(); | 1149 | set_gain(); |
1171 | update_countdown = 0; /* Update immediately */ | 1150 | update_countdown = 0; /* Update immediately */ |
1172 | 1151 | ||
1152 | int listi = 0; | ||
1153 | |||
1173 | /* populate translation table for list id -> enum */ | 1154 | /* populate translation table for list id -> enum */ |
1174 | #ifdef HAVE_SPDIF_REC | 1155 | #ifdef HAVE_SPDIF_REC |
1175 | if(global_settings.rec_source == AUDIO_SRC_SPDIF) | 1156 | if(global_settings.rec_source == AUDIO_SRC_SPDIF) |
1176 | { | 1157 | { |
1177 | listid_to_enum[0] = ITEM_VOLUME_D; | 1158 | listid_to_enum[listi++] = ITEM_VOLUME; |
1178 | listid_to_enum[1] = ITEM_SAMPLERATE_D; | 1159 | listid_to_enum[listi++] = ITEM_SAMPLERATE; |
1179 | listid_to_enum[2] = ITEM_FILENAME_D; | 1160 | listid_to_enum[listi++] = ITEM_FILENAME; |
1180 | 1161 | ||
1181 | gui_synclist_set_nb_items(&lists, ITEM_COUNT_D); /* spdif */ | 1162 | gui_synclist_set_nb_items(&lists, listi); /* spdif */ |
1182 | } | 1163 | } |
1183 | else | 1164 | else |
1184 | #endif | 1165 | #endif |
1185 | if(HAVE_MIC_REC_((global_settings.rec_source == AUDIO_SRC_MIC) || ) | ||
1186 | (global_settings.rec_channels == 1)) | ||
1187 | { | 1166 | { |
1188 | listid_to_enum[0] = ITEM_VOLUME_M; | 1167 | listid_to_enum[listi++] = ITEM_VOLUME; |
1189 | listid_to_enum[1] = ITEM_GAIN_M; | 1168 | listid_to_enum[listi++] = ITEM_GAIN; |
1190 | #ifdef HAVE_AGC | 1169 | #if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC) |
1191 | listid_to_enum[2] = ITEM_AGC_MODE_M; | 1170 | if(HAVE_MIC_REC_((global_settings.rec_source != AUDIO_SRC_MIC) || ) |
1192 | listid_to_enum[3] = ITEM_AGC_MAXDB_M; | 1171 | (global_settings.rec_channels != 1)) { |
1193 | listid_to_enum[4] = ITEM_FILENAME_M; | 1172 | listid_to_enum[listi++] = ITEM_GAIN_L; |
1194 | #else | 1173 | listid_to_enum[listi++] = ITEM_GAIN_R; |
1195 | listid_to_enum[2] = ITEM_FILENAME_M; | 1174 | } |
1196 | #endif | 1175 | #endif |
1197 | gui_synclist_set_nb_items(&lists, ITEM_COUNT_M); /* mono */ | ||
1198 | } | ||
1199 | else | ||
1200 | { | ||
1201 | listid_to_enum[0] = ITEM_VOLUME; | ||
1202 | listid_to_enum[1] = ITEM_GAIN; | ||
1203 | listid_to_enum[2] = ITEM_GAIN_L; | ||
1204 | listid_to_enum[3] = ITEM_GAIN_R; | ||
1205 | #ifdef HAVE_AGC | 1176 | #ifdef HAVE_AGC |
1206 | listid_to_enum[4] = ITEM_AGC_MODE; | 1177 | listid_to_enum[listi++] = ITEM_AGC_MODE; |
1207 | listid_to_enum[5] = ITEM_AGC_MAXDB; | 1178 | listid_to_enum[listi++] = ITEM_AGC_MAXDB; |
1208 | listid_to_enum[6] = ITEM_FILENAME; | ||
1209 | #else | ||
1210 | listid_to_enum[4] = ITEM_FILENAME; | ||
1211 | #endif | 1179 | #endif |
1212 | gui_synclist_set_nb_items(&lists, ITEM_COUNT); /* stereo */ | 1180 | listid_to_enum[listi++] = ITEM_FILENAME; |
1181 | |||
1182 | gui_synclist_set_nb_items(&lists, listi); /* stereo */ | ||
1213 | } | 1183 | } |
1214 | 1184 | ||
1215 | gui_synclist_draw(&lists); | 1185 | gui_synclist_draw(&lists); |