diff --git a/apps/lang/english.lang b/apps/lang/english.lang index d05549a423..2b227831dc 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -2698,16 +2698,16 @@ id: LANG_RECORD_TIMESPLIT - desc: Prompt for record timer interval setting, in the record settings menu + desc: Record split menu user: - *: "Time Split" + *: "File Split Options" - *: "Time Split" + *: "File Split Options" - *: "Time Split" + *: "File Split Options" @@ -8669,4 +8669,111 @@ *: "Import modifications" - + + id: LANG_SPLIT_MEASURE + desc: in record timesplit options + + *: "Split Measure" + + + *: "Split Measure" + + + *: "Split Measure" + + + + id: LANG_SPLIT_TYPE + desc: in record timesplit options + + *: "What to do when Splitting" + + + *: "What to do when Splitting" + + + *: "What to do when Splitting" + + + + id: LANG_SPLIT_TIME + desc: in record timesplit options + + *: "Split Time" + + + *: "Split Time" + + + *: "Split Time" + + + + id: LANG_SPLIT_SIZE + desc: in record timesplit options + + *: "Split Filesize" + + + *: "Split Filesize" + + + *: "Split Filesize" + + + + id: LANG_REC_TIME + desc: in record timesplit options + user: + + *: "Time" + + + *: "Time" + + + *: "Time" + + + + id: LANG_REC_SIZE + desc: in record timesplit options + user: + + *: "Filesize" + + + *: "Filesize" + + + *: "Filesize" + + + + id: LANG_START_NEW_FILE + desc: in record timesplit options + user: + + *: "Start new file" + + + *: "Start new file" + + + *: "Start new file" + + + + id: LANG_STOP_RECORDING + desc: in record timesplit options + user: + + *: "Stop recording" + + + *: "Stop recording" + + + *: "Stop recording" + + diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 436212a1be..06a6fd9b94 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -830,27 +830,38 @@ bool recording_screen(void) if(update_countdown == 0 || seconds > last_seconds) { unsigned int dseconds, dhours, dminutes; - unsigned long num_recorded_bytes; + unsigned long num_recorded_bytes, dsize, dmb; int pos = 0; char spdif_sfreq[8]; update_countdown = 5; last_seconds = seconds; + dseconds = rec_timesplit_seconds(); + dsize = rec_sizesplit_bytes(); + num_recorded_bytes = audio_num_recorded_bytes(); + FOR_NB_SCREENS(i) screens[i].clear_display(); - hours = seconds / 3600; - minutes = (seconds - (hours * 3600)) / 60; - snprintf(buf, 32, "%s %02d:%02d:%02d", - str(LANG_RECORDING_TIME), - hours, minutes, seconds%60); + if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method)) + { + dmb = dsize/1024/1024; + snprintf(buf, 32, "%s %dMB", + str(LANG_SPLIT_SIZE), dmb); + } + else + { + hours = seconds / 3600; + minutes = (seconds - (hours * 3600)) / 60; + snprintf(buf, 32, "%s %02d:%02d:%02d", + str(LANG_RECORDING_TIME), + hours, minutes, seconds%60); + } + FOR_NB_SCREENS(i) screens[i].puts(0, 0, buf); - dseconds = rec_timesplit_seconds(); - num_recorded_bytes = audio_num_recorded_bytes(); - if(audio_stat & AUDIO_STATUS_PRERECORD) { snprintf(buf, 32, "%s...", str(LANG_RECORD_PRERECORD)); @@ -859,7 +870,7 @@ bool recording_screen(void) { /* Display the split interval if the record timesplit is active */ - if (global_settings.rec_timesplit) + if ((global_settings.rec_timesplit) && !(global_settings.rec_split_method)) { /* Display the record timesplit interval rather than the file size if the record timer is @@ -903,13 +914,25 @@ bool recording_screen(void) /* We will do file splitting regardless, either at the end of a split interval, or when the filesize approaches the 2GB FAT file size (compatibility) limit. */ - if (audio_stat && - ((global_settings.rec_timesplit && (seconds >= dseconds)) - || (num_recorded_bytes >= MAX_FILE_SIZE))) + if ((audio_stat && !(global_settings.rec_split_method) + && global_settings.rec_timesplit && (seconds >= dseconds)) + || (audio_stat && global_settings.rec_split_method + && global_settings.rec_sizesplit && (num_recorded_bytes >= dsize)) + || (num_recorded_bytes >= MAX_FILE_SIZE)) { - audio_new_file(rec_create_filename(path_buffer)); + if (!(global_settings.rec_split_type) + || (num_recorded_bytes >= MAX_FILE_SIZE)) + { + audio_new_file(rec_create_filename(path_buffer)); + last_seconds = 0; + } + else + { + peak_meter_trigger(false); + peak_meter_set_trigger_listener(NULL); + audio_stop_recording(); + } update_countdown = 1; - last_seconds = 0; } snprintf(buf, 32, "%s: %s", str(LANG_VOLUME), diff --git a/apps/settings.c b/apps/settings.c index e065e78c81..8846fa4bcf 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -94,7 +94,7 @@ const char rec_base_directory[] = REC_BASE_DIR; #include "dsp.h" #endif -#define CONFIG_BLOCK_VERSION 46 +#define CONFIG_BLOCK_VERSION 47 #define CONFIG_BLOCK_SIZE 512 #define RTC_BLOCK_SIZE 44 @@ -466,7 +466,12 @@ static const struct bit_entry hd_bits[] = {1, S_O(rec_startup), false, "rec screen on startup", off_on }, {4, S_O(rec_timesplit), 0, "rec timesplit", /* 0...15 */ "off,00:05,00:10,00:15,00:30,01:00,01:14,01:20,02:00,04:00,06:00,08:00,10:00,12:00,18:00,24:00" }, + {4, S_O(rec_sizesplit), 0, "rec sizesplit", /* 0...15 */ + "off,5MB,10MB,15MB,32MB,64MB,75MB,100MB,128MB,256MB,512MB,650MB,700MB,1GB,1.5GB,1.75GB" }, {1, S_O(rec_channels), 0, "rec channels", "stereo,mono" }, + {1, S_O(rec_split_type), 0, "rec split type", "Split, Stop" }, + {1, S_O(rec_split_method), 0, "rec split method", "Time,Filesize" }, + #ifdef HAVE_SPDIF_IN {2, S_O(rec_source), 0 /* 0=mic */, "rec source", "mic,line,spdif" }, #else @@ -1929,6 +1934,31 @@ unsigned int rec_timesplit_seconds(void) return rec_timer_seconds[global_settings.rec_timesplit]; } +/* This array holds the record size interval lengths, in bytes */ +static const unsigned long rec_size_bytes[] = +{ + 0, /* 0 means OFF */ + 5*1024*1024, /* 5MB */ + 10*1024*1024, /* 10MB */ + 15*1024*1024, /* 15MB */ + 32*1024*1024, /* 32MB */ + 64*1024*1024, /* 64MB */ + 75*1024*1024, /* 75MB */ + 100*1024*1024, /* 100MB */ + 128*1024*1024, /* 128MB */ + 256*1024*1024, /* 256MB */ + 512*1024*1024, /* 512MB */ + 650*1024*1024, /* 650MB */ + 700*1024*1024, /* 700MB */ + 1024*1024*1024, /* 1GB */ + 1536*1024*1024, /* 1.5GB */ + 1792*1024*1024, /* 1.75GB */ +}; + +unsigned long rec_sizesplit_bytes(void) +{ + return rec_size_bytes[global_settings.rec_sizesplit]; +} /* * Time strings used for the trigger durations. * Keep synchronous to trigger_times in settings_apply_trigger diff --git a/apps/settings.h b/apps/settings.h index 4809c18575..8c47c9253e 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -249,6 +249,13 @@ struct user_settings 5 = 01:00, 6 = 02:00, 7 = 04:00, 8 = 06:00 9 = 08:00, 10= 10:00, 11= 12:00, 12= 18:00, 13= 24:00 */ + int rec_sizesplit; /* 0 = off, + 1 = 5MB, 2 = 10MB, 3 = 15MB, 4 = 32MB + 5 = 64MB, 6 = 75MB, 7 = 100MB, 8 = 128MB + 9 = 256MB, 10= 512MB, 11= 650MB, 12= 700MB, + 13= 1GB, 14 = 1.5GB 15 = 1.75MB*/ + int rec_split_type; /* split/stop */ + int rec_split_method; /* time/filesize */ int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */ int rec_directory; /* 0=base dir, 1=current dir */ @@ -549,6 +556,7 @@ int read_line(int fd, char* buffer, int buffer_size); void set_file(char* filename, char* setting, int maxlen); unsigned int rec_timesplit_seconds(void); +unsigned long rec_sizesplit_bytes(void); void settings_apply_trigger(void); /* global settings */ diff --git a/apps/sound_menu.c b/apps/sound_menu.c index d8d5d4ef75..0d65bd8b9e 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -366,11 +366,77 @@ static bool rectimesplit(void) { "18:00" , TALK_ID(18, UNIT_HOUR) }, { "24:00" , TALK_ID(24, UNIT_HOUR) } }; - return set_option(str(LANG_RECORD_TIMESPLIT), + return set_option(str(LANG_SPLIT_TIME), &global_settings.rec_timesplit, INT, names, 16, NULL ); } +static bool recsizesplit(void) +{ + static const struct opt_items names[] = { + { STR(LANG_OFF) }, + { "5MB" , TALK_ID(5, UNIT_MB) }, + { "10MB" , TALK_ID(10, UNIT_MB) }, + { "15MB" , TALK_ID(15, UNIT_MB) }, + { "32MB" , TALK_ID(32, UNIT_MB) }, + { "64MB" , TALK_ID(64, UNIT_MB) }, + { "75MB" , TALK_ID(75, UNIT_MB) }, + { "100MB" , TALK_ID(100, UNIT_MB) }, + { "128MB" , TALK_ID(128, UNIT_MB) }, + { "256MB" , TALK_ID(256, UNIT_MB) }, + { "512MB" , TALK_ID(512, UNIT_MB) }, + { "650MB" , TALK_ID(650, UNIT_MB) }, + { "700MB" , TALK_ID(700, UNIT_MB) }, + { "1GB" , TALK_ID(1024, UNIT_MB) }, + { "1.5GB" , TALK_ID(1536, UNIT_MB) }, + { "1.75GB" , TALK_ID(1792, UNIT_MB) } + }; + return set_option(str(LANG_SPLIT_SIZE), + &global_settings.rec_sizesplit, INT, + names, 16, NULL ); +} + +static bool splitmethod(void) +{ + static const struct opt_items names[] = { + { STR(LANG_REC_TIME) }, + { STR(LANG_REC_SIZE) }, + }; + bool ret; + ret=set_option( str(LANG_SPLIT_MEASURE), + &global_settings.rec_split_method, INT, names, 2, NULL); + return ret; +} + +static bool splittype(void) +{ + static const struct opt_items names[] = { + { STR(LANG_START_NEW_FILE) }, + { STR(LANG_STOP_RECORDING) }, + }; + bool ret; + ret=set_option( str(LANG_SPLIT_TYPE), + &global_settings.rec_split_type, INT, names, 2, NULL); + return ret; +} + +static bool filesplitoptionsmenu(void) +{ + int m; + bool result; + + static const struct menu_item items[] = { + { ID2P(LANG_SPLIT_MEASURE), splitmethod }, + { ID2P(LANG_SPLIT_TYPE), splittype }, + { ID2P(LANG_SPLIT_TIME), rectimesplit }, + { ID2P(LANG_SPLIT_SIZE), recsizesplit } + }; + m=menu_init( items, sizeof(items) / sizeof(*items), NULL, + NULL, NULL, NULL); + result = menu_run(m); + menu_exit(m); + return result; +} static bool recprerecord(void) { static const struct opt_items names[] = { @@ -931,7 +997,7 @@ bool recording_menu(bool no_source) items[i++].function = receditable; #endif items[i].desc = ID2P(LANG_RECORD_TIMESPLIT); - items[i++].function = rectimesplit; + items[i++].function = filesplitoptionsmenu; items[i].desc = ID2P(LANG_RECORD_PRERECORD_TIME); items[i++].function = recprerecord; items[i].desc = ID2P(LANG_RECORD_DIRECTORY); diff --git a/apps/talk.h b/apps/talk.h index 8bc86c329a..58ab0ef37a 100644 --- a/apps/talk.h +++ b/apps/talk.h @@ -40,6 +40,7 @@ enum { UNIT_PIXEL, /* pixels */ UNIT_PER_SEC, /* per second */ UNIT_HERTZ, /* hertz */ + UNIT_MB, /* Megabytes */ UNIT_LAST /* END MARKER */ };