summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-12-31 03:13:29 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-12-31 03:13:29 +0000
commit74976c1484d7c8a89a290ffc7e4a7525874278b4 (patch)
tree23f6f2e53f5f8ab6e9476b412cc56e15801914dd /apps
parent1c4ea83bba9ce7ec7ede6141c1ee66c12c20f1d6 (diff)
downloadrockbox-74976c1484d7c8a89a290ffc7e4a7525874278b4.tar.gz
rockbox-74976c1484d7c8a89a290ffc7e4a7525874278b4.zip
New recording feature: Prerecord up to 30 seconds before you press the Play key. Especially useful for FM radio recording. Also fixed a bug which didn't apply the recording settings correctly in the Radio screen.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4183 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang10
-rw-r--r--apps/recorder/radio.c47
-rw-r--r--apps/recorder/recording.c75
-rw-r--r--apps/settings.c30
-rw-r--r--apps/settings.h2
-rw-r--r--apps/sound_menu.c18
6 files changed, 121 insertions, 61 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index ffdc12b306..5cad562a7f 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1847,3 +1847,13 @@ id: LANG_FLIP_DISPLAY
desc: in settings_menu, option to turn display+buttos by 180 degreed
eng: "Upside Down"
new:
+
+id: LANG_RECORD_PRERECORD
+desc: in recording and radio screen
+eng: "Prerecording"
+new:
+
+id: LANG_RECORD_PRERECORD_TIME
+desc: in recording settings_menu
+eng: "Prerecord time"
+new:
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index ab0c1eb004..519e919964 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -172,9 +172,10 @@ bool radio_screen(void)
mpeg_set_recording_options(global_settings.rec_frequency,
global_settings.rec_quality,
- 1 /* Line In */,
+ 1, /* Line In */
global_settings.rec_channels,
- global_settings.rec_editable);
+ global_settings.rec_editable,
+ global_settings.rec_prerecord_time);
mpeg_set_recording_gain(mpeg_sound_default(SOUND_LEFT_GAIN),
@@ -230,7 +231,7 @@ bool radio_screen(void)
switch(button)
{
case BUTTON_OFF:
- if(mpeg_status())
+ if(mpeg_status() == MPEG_STATUS_RECORD)
{
mpeg_stop();
status_set_playmode(STATUS_STOP);
@@ -244,17 +245,16 @@ bool radio_screen(void)
break;
case BUTTON_F3:
- /* Only act if the mpeg is stopped */
- if(!mpeg_status())
+ if(mpeg_status() == MPEG_STATUS_RECORD)
{
- have_recorded = true;
- mpeg_record(rec_create_filename());
- status_set_playmode(STATUS_RECORD);
+ mpeg_new_file(rec_create_filename());
update_screen = true;
}
else
{
- mpeg_new_file(rec_create_filename());
+ have_recorded = true;
+ mpeg_record(rec_create_filename());
+ status_set_playmode(STATUS_RECORD);
update_screen = true;
}
last_seconds = 0;
@@ -353,11 +353,12 @@ bool radio_screen(void)
case SYS_USB_CONNECTED:
/* Only accept USB connection when not recording */
- if(!mpeg_status())
+ if(mpeg_status() != MPEG_STATUS_RECORD)
{
usb_screen();
fmradio_set_status(0);
- have_recorded = true; /* Refreshes the browser later on */
+ screen_freeze = true; /* Cosmetic: makes sure the
+ radio screen doesn't redraw */
done = true;
}
break;
@@ -368,6 +369,8 @@ bool radio_screen(void)
if(!screen_freeze)
{
lcd_setmargins(0, 8);
+
+ /* Only display the peak meter when not recording */
if(!mpeg_status())
{
lcd_clearrect(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh);
@@ -415,7 +418,7 @@ bool radio_screen(void)
str(LANG_CHANNEL_MONO));
lcd_puts(0, top_of_screen + 2, buf);
- if(mpeg_status())
+ if(mpeg_status() == MPEG_STATUS_RECORD)
{
hours = seconds / 3600;
minutes = (seconds - (hours * 3600)) / 60;
@@ -424,6 +427,12 @@ bool radio_screen(void)
hours, minutes, seconds%60);
lcd_puts(0, top_of_screen + 3, buf);
}
+ else
+ {
+ snprintf(buf, 32, "%s %02d",
+ str(LANG_RECORD_PRERECORD), seconds%60);
+ lcd_puts(0, top_of_screen + 3, buf);
+ }
/* Only force the redraw if update_screen is true */
status_draw(update_screen);
@@ -687,7 +696,19 @@ bool radio_delete_preset(void)
static bool fm_recording_settings(void)
{
- return recording_menu(true);
+ bool ret;
+
+ ret = recording_menu(true);
+ if(!ret)
+ {
+ mpeg_set_recording_options(global_settings.rec_frequency,
+ global_settings.rec_quality,
+ 1, /* Line In */
+ global_settings.rec_channels,
+ global_settings.rec_editable,
+ global_settings.rec_prerecord_time);
+ }
+ return ret;
}
bool radio_menu(void)
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index d94508e547..bc26ff8495 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -160,7 +160,8 @@ bool recording_screen(void)
global_settings.rec_quality,
global_settings.rec_source,
global_settings.rec_channels,
- global_settings.rec_editable);
+ global_settings.rec_editable,
+ global_settings.rec_prerecord_time);
set_gain();
@@ -174,7 +175,7 @@ bool recording_screen(void)
switch(button)
{
case BUTTON_OFF:
- if(mpeg_status())
+ if(mpeg_status() & MPEG_STATUS_RECORD)
{
mpeg_stop();
status_set_playmode(STATUS_STOP);
@@ -190,7 +191,7 @@ bool recording_screen(void)
case BUTTON_PLAY:
/* Only act if the mpeg is stopped */
- if(!mpeg_status())
+ if(!(mpeg_status() & MPEG_STATUS_RECORD))
{
have_recorded = true;
mpeg_record(rec_create_filename());
@@ -305,13 +306,16 @@ bool recording_screen(void)
if (recording_menu(false))
return SYS_USB_CONNECTED;
settings_save();
+
mpeg_set_recording_options(global_settings.rec_frequency,
global_settings.rec_quality,
global_settings.rec_source,
global_settings.rec_channels,
- global_settings.rec_editable);
+ global_settings.rec_editable,
+ global_settings.rec_prerecord_time);
set_gain();
+
update_countdown = 1; /* Update immediately */
lcd_setfont(FONT_SYSFIXED);
@@ -319,7 +323,7 @@ bool recording_screen(void)
break;
case BUTTON_F2:
- if(!mpeg_status())
+ if(mpeg_status() != MPEG_STATUS_RECORD)
{
if (f2_rec_screen())
{
@@ -332,7 +336,7 @@ bool recording_screen(void)
break;
case BUTTON_F3:
- if(!mpeg_status())
+ if(mpeg_status() != MPEG_STATUS_RECORD)
{
if (f3_rec_screen())
{
@@ -346,14 +350,12 @@ bool recording_screen(void)
case SYS_USB_CONNECTED:
/* Only accept USB connection when not recording */
- if(!mpeg_status())
+ if(mpeg_status() != MPEG_STATUS_RECORD)
{
usb_screen();
have_recorded = true; /* Refreshes the browser later on */
done = true;
}
- lcd_setfont(FONT_SYSFIXED);
- lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
break;
}
@@ -387,21 +389,28 @@ bool recording_screen(void)
dseconds = rec_timesplit_seconds();
- /* Display the split interval if the record timesplit
- is active */
- if (global_settings.rec_timesplit)
+ if(mpeg_status() & MPEG_STATUS_PRERECORD)
{
- /* Display the record timesplit interval rather than
- the file size if the record timer is active */
- dhours = dseconds / 3600;
- dminutes = (dseconds - (dhours * 3600)) / 60;
- snprintf(buf, 32, "%s %02d:%02d",
- str(LANG_RECORD_TIMESPLIT_REC),
- dhours, dminutes);
+ snprintf(buf, 32, "%s...", str(LANG_RECORD_PRERECORD));
}
else
- snprintf(buf, 32, "%s %s", str(LANG_RECORDING_SIZE),
- num2max5(mpeg_num_recorded_bytes(), buf2));
+ {
+ /* Display the split interval if the record timesplit
+ is active */
+ if (global_settings.rec_timesplit)
+ {
+ /* Display the record timesplit interval rather than
+ the file size if the record timer is active */
+ dhours = dseconds / 3600;
+ dminutes = (dseconds - (dhours * 3600)) / 60;
+ snprintf(buf, 32, "%s %02d:%02d",
+ str(LANG_RECORD_TIMESPLIT_REC),
+ dhours, dminutes);
+ }
+ else
+ snprintf(buf, 32, "%s %s", str(LANG_RECORDING_SIZE),
+ num2max5(mpeg_num_recorded_bytes(), buf2));
+ }
lcd_puts(0, 1, buf);
/* We will do file splitting regardless, since the OFF
@@ -622,7 +631,8 @@ bool f2_rec_screen(void)
global_settings.rec_quality,
global_settings.rec_source,
global_settings.rec_channels,
- global_settings.rec_editable);
+ global_settings.rec_editable,
+ global_settings.rec_prerecord_time);
set_gain();
@@ -671,22 +681,6 @@ bool f3_rec_screen(void)
used = true;
break;
- case BUTTON_DOWN:
- case BUTTON_F3 | BUTTON_DOWN:
- global_settings.rec_frequency++;
- if(global_settings.rec_frequency > 5)
- global_settings.rec_frequency = 0;
- used = true;
- break;
-
- case BUTTON_RIGHT:
- case BUTTON_F3 | BUTTON_RIGHT:
- global_settings.rec_channels++;
- if(global_settings.rec_channels > 1)
- global_settings.rec_channels = 0;
- used = true;
- break;
-
case BUTTON_F3 | BUTTON_REL:
if ( used )
exit = true;
@@ -707,10 +701,11 @@ bool f3_rec_screen(void)
global_settings.rec_quality,
global_settings.rec_source,
global_settings.rec_channels,
- global_settings.rec_editable);
+ global_settings.rec_editable,
+ global_settings.rec_prerecord_time);
set_gain();
-
+
settings_save();
lcd_setfont(FONT_UI);
diff --git a/apps/settings.c b/apps/settings.c
index b2fa22170b..35e75d12ca 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -129,6 +129,9 @@ location used, and reset the setting in question with a factory default if
needed. Memory locations not used by a given version should not be
modified unless the header & checksum test fails.
+Because 0xff mean that the byte is unused, care must be taken so that
+a used byte can't have the value 0xff. Either use only 7 bits, or make sure
+that the value will never be 0xff.
Rest of config block, only saved to disk:
0xA8 (char)jump scroll mode (only for player)
@@ -151,9 +154,8 @@ Rest of config block, only saved to disk:
0xB8 (char[20]) WPS file
0xCC (char[20]) Lang file
0xE0 (char[20]) Font file
-0xF4 <unused>
-0xF8 <unused>
-0xFC <unused>
+0xF4 Prerecording time (bit 0-4)
+0xF5-0xFF <unused>
*************************************/
@@ -432,6 +434,8 @@ int settings_save( void )
strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME);
strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME);
+ config_block[0xf4]=(unsigned char)global_settings.rec_prerecord_time;
+
if(save_config_buffer())
{
lcd_clear_display();
@@ -756,6 +760,10 @@ void settings_load(void)
strncpy(global_settings.wps_file, &config_block[0xb8], MAX_FILENAME);
strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME);
strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME);
+
+ if (config_block[0xf4] != 0xff)
+ global_settings.rec_prerecord_time = config_block[0xf4];
+
#ifdef HAVE_LCD_CHARCELLS
if (config_block[0xa8] != 0xff)
global_settings.jump_scroll = config_block[0xa8];
@@ -1079,6 +1087,9 @@ bool settings_load_config(char* file)
else if (!strcasecmp(name, "editable recordings")) {
set_cfg_bool(&global_settings.rec_editable, value);
}
+ else if (!strcasecmp(name, "prerecording time")) {
+ set_cfg_int(&global_settings.rec_prerecord_time, value, 0, 30);
+ }
#endif
else if (!strcasecmp(name, "idle poweroff")) {
static char* options[] = {"off","1","2","3","4","5","6","7","8",
@@ -1379,6 +1390,10 @@ bool settings_save_config(void)
fprintf(fd, "line in: %s\r\n", boolopt[global_settings.line_in]);
#endif
+ fprintf(fd, "max files in dir: %d\r\n", global_settings.max_files_in_dir);
+ fprintf(fd, "max files in playlist: %d\r\n",
+ global_settings.max_files_in_playlist);
+
#ifdef HAVE_MAS3587F
fprintf(fd, "#\r\n# Recording\r\n#\r\n");
fprintf(fd, "rec quality: %d\r\n", global_settings.rec_quality);
@@ -1409,12 +1424,12 @@ bool settings_save_config(void)
fprintf(fd, "editable recordings: %s\r\n",
boolopt[global_settings.rec_editable]);
+ fprintf(fd, "prerecording time: %d\r\n",
+ global_settings.rec_prerecord_time);
+
#endif
- fprintf(fd, "max files in dir: %d\r\n", global_settings.max_files_in_dir);
- fprintf(fd, "max files in playlist: %d\r\n",
- global_settings.max_files_in_playlist);
-
+ fprintf(fd, "#\r\n# Playlists\r\n#\r\n");
{
static char* options[] = {"off", "on", "ask"};
fprintf(fd, "recursive directory insert: %s\r\n",
@@ -1454,6 +1469,7 @@ void settings_reset(void) {
global_settings.rec_left_gain = 2; /* 0dB */
global_settings.rec_right_gain = 2; /* 0dB */
global_settings.rec_editable = false;
+ global_settings.rec_prerecord_time = 0;
global_settings.resume = RESUME_ASK;
global_settings.contrast = lcd_default_contrast();
global_settings.invert = DEFAULT_INVERT_SETTING;
diff --git a/apps/settings.h b/apps/settings.h
index 074be0690a..49327b2f80 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -85,6 +85,8 @@ 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_prerecord_time; /* In seconds, 0-30, 0 means OFF */
/* device settings */
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index c5e254794e..557013df8a 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -241,6 +241,20 @@ static bool rectimesplit(void)
names, 14, NULL );
}
+static bool recprerecord(void)
+{
+ char *names[] = {
+ str(LANG_OFF),"1s","2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s",
+ "10s", "11s", "12s", "13s", "14s", "15s", "16s", "17s", "18s", "19s",
+ "20s", "21s", "22s", "23s", "24s", "25s", "26s", "27s", "28s", "29s",
+ "30s"
+ };
+
+ return set_option(str(LANG_RECORD_PRERECORD_TIME),
+ &global_settings.rec_prerecord_time, INT,
+ names, 31, NULL );
+}
+
#endif /* HAVE_MAS3587F */
static void set_chanconf(int val)
@@ -294,7 +308,7 @@ bool recording_menu(bool no_source)
{
int m;
int i = 0;
- struct menu_items menu[6];
+ struct menu_items menu[7];
bool result;
menu[i].desc = str(LANG_RECORDING_QUALITY);
@@ -311,6 +325,8 @@ bool recording_menu(bool no_source)
menu[i++].function = receditable;
menu[i].desc = str(LANG_RECORD_TIMESPLIT);
menu[i++].function = rectimesplit;
+ menu[i].desc = str(LANG_RECORD_PRERECORD_TIME);
+ menu[i++].function = recprerecord;
m=menu_init( menu, i );
result = menu_run(m);