From 74976c1484d7c8a89a290ffc7e4a7525874278b4 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Wed, 31 Dec 2003 03:13:29 +0000 Subject: 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 --- apps/recorder/radio.c | 47 +++++++++++++++++++++-------- apps/recorder/recording.c | 75 ++++++++++++++++++++++------------------------- 2 files changed, 69 insertions(+), 53 deletions(-) (limited to 'apps/recorder') 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); -- cgit v1.2.3