summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-06-22 09:34:57 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-06-22 09:34:57 +0000
commitea255fbc3a5842d200e943522cea9bd2cb701dd6 (patch)
treecb730c3b060dc3c253d64695d49a4f14a0da65d0
parent6e21c146f80b17e158f3f13f84afab2978367917 (diff)
downloadrockbox-ea255fbc3a5842d200e943522cea9bd2cb701dd6.tar.gz
rockbox-ea255fbc3a5842d200e943522cea9bd2cb701dd6.zip
Prevent initial spinup when starting first file when in a stopped state on non-RTC targets. Fix some states that are dangerous on SWCODEC and could result in data loss. Had to make plugin API incopatible since specified numbered filename creation is enabled now on all non-RTC targets with recording; increase version and sort the items that looked like they had a place to go.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13683 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/misc.h6
-rw-r--r--apps/plugin.c24
-rw-r--r--apps/plugin.h40
-rw-r--r--apps/recorder/recording.c127
4 files changed, 110 insertions, 87 deletions
diff --git a/apps/misc.h b/apps/misc.h
index b0adb92a0e..25937fae29 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -38,9 +38,9 @@ char *output_dyn_value(char *buf, int buf_size, int value,
38 * less than zero to number automatically. The final number used will also 38 * less than zero to number automatically. The final number used will also
39 * be returned in *num. If *num is >= 0 then *num will be incremented by 39 * be returned in *num. If *num is >= 0 then *num will be incremented by
40 * one. */ 40 * one. */
41#if CONFIG_CODEC == SWCODEC && defined(HAVE_RECORDING) && (CONFIG_RTC == 0) 41#if defined(HAVE_RECORDING) && (CONFIG_RTC == 0)
42/* this feature is needed by SWCODEC recording without a RTC to prevent 42/* this feature is needed by recording without a RTC to prevent disk access
43 disk access when changing files */ 43 when changing files */
44#define IF_CNFN_NUM_(...) __VA_ARGS__ 44#define IF_CNFN_NUM_(...) __VA_ARGS__
45#define IF_CNFN_NUM 45#define IF_CNFN_NUM
46#else 46#else
diff --git a/apps/plugin.c b/apps/plugin.c
index ca0b8a2ba6..e81ae25ed1 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -104,6 +104,7 @@ static const struct plugin_api rockbox_api = {
104 lcd_get_background, 104 lcd_get_background,
105 lcd_bitmap_part, 105 lcd_bitmap_part,
106 lcd_bitmap, 106 lcd_bitmap,
107 lcd_get_backdrop,
107 lcd_set_backdrop, 108 lcd_set_backdrop,
108#endif 109#endif
109#if LCD_DEPTH == 16 110#if LCD_DEPTH == 16
@@ -217,6 +218,7 @@ static const struct plugin_api rockbox_api = {
217#endif 218#endif
218 ata_spindown, 219 ata_spindown,
219 reload_directory, 220 reload_directory,
221 create_numbered_filename,
220 222
221 /* dir */ 223 /* dir */
222 PREFIX(opendir), 224 PREFIX(opendir),
@@ -241,6 +243,7 @@ static const struct plugin_api rockbox_api = {
241 &current_tick, 243 &current_tick,
242 default_event_handler, 244 default_event_handler,
243 default_event_handler_ex, 245 default_event_handler_ex,
246 threads,
244 create_thread, 247 create_thread,
245 remove_thread, 248 remove_thread,
246 reset_poweroff_timer, 249 reset_poweroff_timer,
@@ -403,8 +406,12 @@ static const struct plugin_api rockbox_api = {
403 gui_syncstatusbar_draw, 406 gui_syncstatusbar_draw,
404 /* options */ 407 /* options */
405 set_option, 408 set_option,
409 set_bool_options,
406 set_int, 410 set_int,
407 set_bool, 411 set_bool,
412#ifdef HAVE_LCD_COLOR
413 set_color,
414#endif
408 415
409 /* action handling */ 416 /* action handling */
410 get_custom_action, 417 get_custom_action,
@@ -470,12 +477,6 @@ static const struct plugin_api rockbox_api = {
470 wheel_status, 477 wheel_status,
471 wheel_send_events, 478 wheel_send_events,
472#endif 479#endif
473#if LCD_DEPTH > 1
474 lcd_get_backdrop,
475#endif
476
477 /* new stuff at the end, sort into place next time
478 the API gets incompatible */
479 480
480#ifdef IRIVER_H100_SERIES 481#ifdef IRIVER_H100_SERIES
481 /* Routines for the iriver_flash -plugin. */ 482 /* Routines for the iriver_flash -plugin. */
@@ -483,7 +484,8 @@ static const struct plugin_api rockbox_api = {
483 detect_flashed_ramimage, 484 detect_flashed_ramimage,
484 detect_flashed_romimage, 485 detect_flashed_romimage,
485#endif 486#endif
486 487 /* new stuff at the end, sort into place next time
488 the API gets incompatible */
487#if NUM_CORES > 1 489#if NUM_CORES > 1
488 spinlock_init, 490 spinlock_init,
489 spinlock_lock, 491 spinlock_lock,
@@ -492,14 +494,8 @@ static const struct plugin_api rockbox_api = {
492 494
493#if (CONFIG_CODEC == SWCODEC) 495#if (CONFIG_CODEC == SWCODEC)
494 codec_load_file, 496 codec_load_file,
495 get_metadata,
496 get_codec_filename, 497 get_codec_filename,
497#endif 498 get_metadata,
498 threads,
499 create_numbered_filename,
500 set_bool_options,
501#ifdef HAVE_LCD_COLOR
502 set_color,
503#endif 499#endif
504}; 500};
505 501
diff --git a/apps/plugin.h b/apps/plugin.h
index 29e7f5d318..a95d80b7aa 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -115,12 +115,12 @@
115#define PLUGIN_MAGIC 0x526F634B /* RocK */ 115#define PLUGIN_MAGIC 0x526F634B /* RocK */
116 116
117/* increase this every time the api struct changes */ 117/* increase this every time the api struct changes */
118#define PLUGIN_API_VERSION 59 118#define PLUGIN_API_VERSION 60
119 119
120/* update this to latest version if a change to the api struct breaks 120/* update this to latest version if a change to the api struct breaks
121 backwards compatibility (and please take the opportunity to sort in any 121 backwards compatibility (and please take the opportunity to sort in any
122 new function which are "waiting" at the end of the function table) */ 122 new function which are "waiting" at the end of the function table) */
123#define PLUGIN_MIN_API_VERSION 58 123#define PLUGIN_MIN_API_VERSION 60
124 124
125/* plugin return codes */ 125/* plugin return codes */
126enum plugin_status { 126enum plugin_status {
@@ -179,6 +179,7 @@ struct plugin_api {
179 int stride, int x, int y, int width, int height); 179 int stride, int x, int y, int width, int height);
180 void (*lcd_bitmap)(const fb_data *src, int x, int y, int width, 180 void (*lcd_bitmap)(const fb_data *src, int x, int y, int width,
181 int height); 181 int height);
182 fb_data* (*lcd_get_backdrop)(void);
182 void (*lcd_set_backdrop)(fb_data* backdrop); 183 void (*lcd_set_backdrop)(fb_data* backdrop);
183#endif 184#endif
184#if LCD_DEPTH == 16 185#if LCD_DEPTH == 16
@@ -310,6 +311,9 @@ struct plugin_api {
310#endif 311#endif
311 void (*ata_spindown)(int seconds); 312 void (*ata_spindown)(int seconds);
312 void (*reload_directory)(void); 313 void (*reload_directory)(void);
314 char *(*create_numbered_filename)(char *buffer, const char *path,
315 const char *prefix, const char *suffix,
316 int numberlen IF_CNFN_NUM_(, int *num));
313 317
314 /* dir */ 318 /* dir */
315 DIR* (*PREFIX(opendir))(const char* name); 319 DIR* (*PREFIX(opendir))(const char* name);
@@ -333,6 +337,7 @@ struct plugin_api {
333 long* current_tick; 337 long* current_tick;
334 long (*default_event_handler)(long event); 338 long (*default_event_handler)(long event);
335 long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter); 339 long (*default_event_handler_ex)(long event, void (*callback)(void *), void *parameter);
340 struct thread_entry* threads;
336 struct thread_entry* (*create_thread)(void (*function)(void), void* stack, 341 struct thread_entry* (*create_thread)(void (*function)(void), void* stack,
337 int stack_size, const char *name 342 int stack_size, const char *name
338 IF_PRIO(, int priority) 343 IF_PRIO(, int priority)
@@ -507,11 +512,19 @@ struct plugin_api {
507 bool (*set_option)(const char* string, void* variable, 512 bool (*set_option)(const char* string, void* variable,
508 enum optiontype type, const struct opt_items* options, 513 enum optiontype type, const struct opt_items* options,
509 int numoptions, void (*function)(int)); 514 int numoptions, void (*function)(int));
515 bool (*set_bool_options)(const char* string, bool* variable,
516 const char* yes_str, int yes_voice,
517 const char* no_str, int no_voice,
518 void (*function)(bool));
510 bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit, 519 bool (*set_int)(const unsigned char* string, const char* unit, int voice_unit,
511 int* variable, void (*function)(int), int step, int min, 520 int* variable, void (*function)(int), int step, int min,
512 int max, void (*formatter)(char*, int, int, const char*) ); 521 int max, void (*formatter)(char*, int, int, const char*) );
513 bool (*set_bool)(const char* string, bool* variable ); 522 bool (*set_bool)(const char* string, bool* variable );
514 523
524#ifdef HAVE_LCD_COLOR
525 bool (*set_color)(struct screen *display, char *title, unsigned *color,
526 unsigned banned_color);
527#endif
515 /* action handling */ 528 /* action handling */
516 int (*get_custom_action)(int context,int timeout, 529 int (*get_custom_action)(int context,int timeout,
517 const struct button_mapping* (*get_context_map)(int)); 530 const struct button_mapping* (*get_context_map)(int));
@@ -587,11 +600,6 @@ struct plugin_api {
587 int (*wheel_status)(void); 600 int (*wheel_status)(void);
588 void (*wheel_send_events)(bool send); 601 void (*wheel_send_events)(bool send);
589#endif 602#endif
590#if LCD_DEPTH > 1
591 fb_data* (*lcd_get_backdrop)(void);
592#endif
593 /* new stuff at the end, sort into place next time
594 the API gets incompatible */
595 603
596#ifdef IRIVER_H100_SERIES 604#ifdef IRIVER_H100_SERIES
597 /* Routines for the iriver_flash -plugin. */ 605 /* Routines for the iriver_flash -plugin. */
@@ -599,6 +607,8 @@ struct plugin_api {
599 bool (*detect_flashed_ramimage)(void); 607 bool (*detect_flashed_ramimage)(void);
600 bool (*detect_flashed_romimage)(void); 608 bool (*detect_flashed_romimage)(void);
601#endif 609#endif
610 /* new stuff at the end, sort into place next time
611 the API gets incompatible */
602 612
603#if NUM_CORES > 1 613#if NUM_CORES > 1
604 void (*spinlock_init)(struct mutex *m); 614 void (*spinlock_init)(struct mutex *m);
@@ -608,23 +618,9 @@ struct plugin_api {
608 618
609#if (CONFIG_CODEC == SWCODEC) 619#if (CONFIG_CODEC == SWCODEC)
610 int (*codec_load_file)(const char* codec, struct codec_api *api); 620 int (*codec_load_file)(const char* codec, struct codec_api *api);
621 const char *(*get_codec_filename)(int cod_spec);
611 bool (*get_metadata)(struct track_info* track, int fd, const char* trackname, 622 bool (*get_metadata)(struct track_info* track, int fd, const char* trackname,
612 bool v1first); 623 bool v1first);
613 const char *(*get_codec_filename)(int cod_spec);
614#endif
615 struct thread_entry* threads;
616
617 char *(*create_numbered_filename)(char *buffer, const char *path,
618 const char *prefix, const char *suffix,
619 int numberlen IF_CNFN_NUM_(, int *num));
620
621 bool (*set_bool_options)(const char* string, bool* variable,
622 const char* yes_str, int yes_voice,
623 const char* no_str, int no_voice,
624 void (*function)(bool));
625#ifdef HAVE_LCD_COLOR
626 bool (*set_color)(struct screen *display, char *title, unsigned *color,
627 unsigned banned_color);
628#endif 624#endif
629}; 625};
630 626
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index f7ceb508d5..17ed1052cb 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -70,11 +70,20 @@
70#include "radio.h" 70#include "radio.h"
71#ifdef HAVE_RECORDING 71#ifdef HAVE_RECORDING
72 72
73static bool in_screen = false; 73/* recording screen status flags */
74 74enum rec_status_flags
75{
76 RCSTAT_IN_RECSCREEN = 0x00000001,
77 RCSTAT_BEEN_IN_USB_MODE = 0x00000002,
78 RCSTAT_CREATED_DIRECTORY = 0x00000004,
79 RCSTAT_HAVE_RECORDED = 0x00000008,
80};
81
82static int rec_status = 0;
83
75bool in_recording_screen(void) 84bool in_recording_screen(void)
76{ 85{
77 return in_screen; 86 return (rec_status & RCSTAT_IN_RECSCREEN) != 0;
78} 87}
79 88
80#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1) 89#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
@@ -92,13 +101,13 @@ static bool remote_display_on = true;
92#endif 101#endif
93 102
94/** File name creation **/ 103/** File name creation **/
95#if CONFIG_CODEC == SWCODEC 104#if CONFIG_RTC == 0
96
97#ifdef IF_CNFN_NUM
98/* current file number to assist in creating unique numbered filenames 105/* current file number to assist in creating unique numbered filenames
99 without actually having to create the file on disk */ 106 without actually having to create the file on disk */
100static int file_number = -1; 107static int file_number = -1;
101#endif /* IF_CNFN_NUM */ 108#endif /* CONFIG_RTC */
109
110#if CONFIG_CODEC == SWCODEC
102 111
103#define REC_FILE_ENDING(rec_format) \ 112#define REC_FILE_ENDING(rec_format) \
104 (audio_formats[rec_format_afmt[rec_format]].ext_list) 113 (audio_formats[rec_format_afmt[rec_format]].ext_list)
@@ -511,16 +520,26 @@ char *rec_create_filename(char *buffer)
511 snprintf(ext, sizeof(ext), ".%s", 520 snprintf(ext, sizeof(ext), ".%s",
512 REC_FILE_ENDING(global_settings.rec_format)); 521 REC_FILE_ENDING(global_settings.rec_format));
513 522
514#if CONFIG_RTC 523#if CONFIG_RTC == 0
524 return create_numbered_filename(buffer, buffer, "rec_", ext, 4,
525 &file_number);
526#else
515 /* We'll wait at least up to the start of the next second so no duplicate 527 /* We'll wait at least up to the start of the next second so no duplicate
516 names are created */ 528 names are created */
517 return create_datetime_filename(buffer, buffer, "R", ext, true); 529 return create_datetime_filename(buffer, buffer, "R", ext, true);
518#else
519 return create_numbered_filename(buffer, buffer, "rec_", ext, 4
520 IF_CNFN_NUM_(, &file_number));
521#endif 530#endif
522} 531}
523 532
533#if CONFIG_RTC == 0
534/* Hit disk to get a starting filename for the type */
535void rec_init_filename(void)
536{
537 file_number = -1;
538 rec_create_filename(path_buffer);
539 file_number--;
540}
541#endif
542
524int rec_create_directory(void) 543int rec_create_directory(void)
525{ 544{
526 int rc; 545 int rc;
@@ -594,7 +613,6 @@ void rec_record(void)
594#if CONFIG_CODEC != SWCODEC 613#if CONFIG_CODEC != SWCODEC
595 talk_buffer_steal(); /* we use the mp3 buffer */ 614 talk_buffer_steal(); /* we use the mp3 buffer */
596#endif 615#endif
597 IF_CNFN_NUM_(file_number = -1;) /* Hit disk for number */
598 audio_record(rec_create_filename(path_buffer)); 616 audio_record(rec_create_filename(path_buffer));
599} 617}
600 618
@@ -617,12 +635,15 @@ static void trigger_listener(int trigger_status)
617 switch (trigger_status) 635 switch (trigger_status)
618 { 636 {
619 case TRIG_GO: 637 case TRIG_GO:
620 if((audio_status() & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD) 638 if(!(audio_status() & AUDIO_STATUS_RECORD))
621 { 639 {
640 rec_status |= RCSTAT_HAVE_RECORDED;
622 rec_record(); 641 rec_record();
642#if CONFIG_CODEC != SWCODEC
623 /* give control to mpeg thread so that it can start 643 /* give control to mpeg thread so that it can start
624 recording */ 644 recording */
625 yield(); yield(); yield(); 645 yield(); yield(); yield();
646#endif
626 } 647 }
627 648
628 /* if we're already recording this is a retrigger */ 649 /* if we're already recording this is a retrigger */
@@ -648,11 +669,7 @@ static void trigger_listener(int trigger_status)
648 switch(global_settings.rec_trigger_type) 669 switch(global_settings.rec_trigger_type)
649 { 670 {
650 case 0: /* Stop */ 671 case 0: /* Stop */
651#if CONFIG_CODEC == SWCODEC
652 audio_stop_recording(); 672 audio_stop_recording();
653#else
654 audio_stop();
655#endif
656 break; 673 break;
657 674
658 case 1: /* Pause */ 675 case 1: /* Pause */
@@ -686,11 +703,9 @@ bool recording_screen(bool no_source)
686 char buf2[32]; 703 char buf2[32];
687 int w, h; 704 int w, h;
688 int update_countdown = 1; 705 int update_countdown = 1;
689 bool have_recorded = false;
690 unsigned int seconds; 706 unsigned int seconds;
691 int hours, minutes; 707 int hours, minutes;
692 char filename[13]; 708 char filename[13];
693 bool been_in_usb_mode = false;
694 int last_audio_stat = -1; 709 int last_audio_stat = -1;
695 int audio_stat; 710 int audio_stat;
696#if CONFIG_CODEC == SWCODEC 711#if CONFIG_CODEC == SWCODEC
@@ -733,7 +748,7 @@ bool recording_screen(bool no_source)
733 748
734 struct audio_recording_options rec_options; 749 struct audio_recording_options rec_options;
735 750
736 in_screen = true; 751 rec_status = RCSTAT_IN_RECSCREEN;
737 cursor = 0; 752 cursor = 0;
738#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 753#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
739 ata_set_led_enabled(false); 754 ata_set_led_enabled(false);
@@ -761,6 +776,15 @@ bool recording_screen(bool no_source)
761 rec_set_recording_options(&rec_options); 776 rec_set_recording_options(&rec_options);
762 777
763 set_gain(); 778 set_gain();
779
780 if(rec_create_directory() > 0)
781 rec_status |= RCSTAT_CREATED_DIRECTORY;
782
783#if CONFIG_RTC == 0
784 /* Create new filename for recording start */
785 rec_init_filename();
786#endif
787
764 settings_apply_trigger(); 788 settings_apply_trigger();
765 789
766#ifdef HAVE_AGC 790#ifdef HAVE_AGC
@@ -788,9 +812,7 @@ bool recording_screen(bool no_source)
788 filename_offset[i] = ((screens[i].height >= 80) ? 1 : 0); 812 filename_offset[i] = ((screens[i].height >= 80) ? 1 : 0);
789 pm_y[i] = 8 + h * (2 + filename_offset[i]); 813 pm_y[i] = 8 + h * (2 + filename_offset[i]);
790 } 814 }
791 815
792 if(rec_create_directory() > 0)
793 have_recorded = true;
794#ifdef HAVE_REMOTE_LCD 816#ifdef HAVE_REMOTE_LCD
795 if (!remote_display_on) 817 if (!remote_display_on)
796 { 818 {
@@ -859,9 +881,9 @@ bool recording_screen(bool no_source)
859 881
860 if (last_audio_stat != audio_stat) 882 if (last_audio_stat != audio_stat)
861 { 883 {
862 if (audio_stat == AUDIO_STATUS_RECORD) 884 if (audio_stat & AUDIO_STATUS_RECORD)
863 { 885 {
864 have_recorded = true; 886 rec_status |= RCSTAT_HAVE_RECORDED;
865 } 887 }
866 last_audio_stat = audio_stat; 888 last_audio_stat = audio_stat;
867 } 889 }
@@ -926,7 +948,7 @@ bool recording_screen(bool no_source)
926 (peak_meter_trigger_status() != TRIG_OFF)) 948 (peak_meter_trigger_status() != TRIG_OFF))
927 { 949 {
928 /* manual recording */ 950 /* manual recording */
929 have_recorded = true; 951 rec_status |= RCSTAT_HAVE_RECORDED;
930 rec_record(); 952 rec_record();
931 last_seconds = 0; 953 last_seconds = 0;
932 if (global_settings.talk_menu) 954 if (global_settings.talk_menu)
@@ -1119,7 +1141,11 @@ bool recording_screen(bool no_source)
1119 break; 1141 break;
1120 1142
1121 case ACTION_STD_MENU: 1143 case ACTION_STD_MENU:
1144#if CONFIG_CODEC == SWCODEC
1145 if(!(audio_stat & AUDIO_STATUS_RECORD))
1146#else
1122 if(audio_stat != AUDIO_STATUS_RECORD) 1147 if(audio_stat != AUDIO_STATUS_RECORD)
1148#endif
1123 { 1149 {
1124#ifdef HAVE_FMRADIO_REC 1150#ifdef HAVE_FMRADIO_REC
1125 const int prev_rec_source = global_settings.rec_source; 1151 const int prev_rec_source = global_settings.rec_source;
@@ -1132,7 +1158,7 @@ bool recording_screen(bool no_source)
1132 if (recording_menu(no_source)) 1158 if (recording_menu(no_source))
1133 { 1159 {
1134 done = true; 1160 done = true;
1135 been_in_usb_mode = true; 1161 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1136#ifdef HAVE_FMRADIO_REC 1162#ifdef HAVE_FMRADIO_REC
1137 radio_status = FMRADIO_OFF; 1163 radio_status = FMRADIO_OFF;
1138#endif 1164#endif
@@ -1152,11 +1178,18 @@ bool recording_screen(bool no_source)
1152 audio_close_recording(); 1178 audio_close_recording();
1153 audio_init_recording(0); 1179 audio_init_recording(0);
1154#endif 1180#endif
1181
1155 rec_init_recording_options(&rec_options); 1182 rec_init_recording_options(&rec_options);
1156 rec_set_recording_options(&rec_options); 1183 rec_set_recording_options(&rec_options);
1157 1184
1158 if(rec_create_directory() > 0) 1185 if(rec_create_directory() > 0)
1159 have_recorded = true; 1186 rec_status |= RCSTAT_CREATED_DIRECTORY;
1187
1188#if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
1189 /* If format changed, a new number is required */
1190 rec_init_filename();
1191#endif
1192
1160#ifdef HAVE_AGC 1193#ifdef HAVE_AGC
1161 if (global_settings.rec_source == AUDIO_SRC_MIC) { 1194 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1162 agc_preset = global_settings.rec_agc_preset_mic; 1195 agc_preset = global_settings.rec_agc_preset_mic;
@@ -1192,7 +1225,7 @@ bool recording_screen(bool no_source)
1192#endif 1225#endif
1193 if (f2_rec_screen()) 1226 if (f2_rec_screen())
1194 { 1227 {
1195 have_recorded = true; 1228 rec_status |= RCSTAT_HAVE_RECORDED;
1196 done = true; 1229 done = true;
1197 } 1230 }
1198 else 1231 else
@@ -1208,31 +1241,28 @@ bool recording_screen(bool no_source)
1208 } 1241 }
1209 else 1242 else
1210 { 1243 {
1211 if(audio_stat != AUDIO_STATUS_RECORD)
1212 {
1213#if (CONFIG_LED == LED_REAL) 1244#if (CONFIG_LED == LED_REAL)
1214 /* led is restored at begin of loop / end of function */ 1245 /* led is restored at begin of loop / end of function */
1215 led(false); 1246 led(false);
1216#endif 1247#endif
1217 if (f3_rec_screen()) 1248 if (f3_rec_screen())
1218 { 1249 {
1219 have_recorded = true; 1250 rec_status |= RCSTAT_HAVE_RECORDED;
1220 done = true; 1251 done = true;
1221 }
1222 else
1223 update_countdown = 1; /* Update immediately */
1224 } 1252 }
1253 else
1254 update_countdown = 1; /* Update immediately */
1225 } 1255 }
1226 break; 1256 break;
1227#endif /* CONFIG_KEYPAD == RECORDER_PAD */ 1257#endif /* CONFIG_KEYPAD == RECORDER_PAD */
1228 1258
1229 case SYS_USB_CONNECTED: 1259 case SYS_USB_CONNECTED:
1230 /* Only accept USB connection when not recording */ 1260 /* Only accept USB connection when not recording */
1231 if(audio_stat != AUDIO_STATUS_RECORD) 1261 if(!(audio_stat & AUDIO_STATUS_RECORD))
1232 { 1262 {
1233 default_event_handler(SYS_USB_CONNECTED); 1263 default_event_handler(SYS_USB_CONNECTED);
1234 done = true; 1264 done = true;
1235 been_in_usb_mode = true; 1265 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1236#ifdef HAVE_FMRADIO_REC 1266#ifdef HAVE_FMRADIO_REC
1237 radio_status = FMRADIO_OFF; 1267 radio_status = FMRADIO_OFF;
1238#endif 1268#endif
@@ -1467,12 +1497,11 @@ bool recording_screen(bool no_source)
1467 { 1497 {
1468 switch (global_settings.rec_source) 1498 switch (global_settings.rec_source)
1469 { 1499 {
1470#if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
1471 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:) 1500 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
1472 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:) 1501 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
1473 line[i] = 5; 1502 line[i] = 5;
1474 break; 1503 break;
1475#endif 1504
1476 case AUDIO_SRC_MIC: 1505 case AUDIO_SRC_MIC:
1477 line[i] = 4; 1506 line[i] = 4;
1478 break; 1507 break;
@@ -1678,7 +1707,7 @@ bool recording_screen(bool no_source)
1678 break; 1707 break;
1679 } 1708 }
1680 } 1709 }
1681 1710
1682#if CONFIG_CODEC == SWCODEC 1711#if CONFIG_CODEC == SWCODEC
1683 audio_stop_recording(); 1712 audio_stop_recording();
1684 audio_close_recording(); 1713 audio_close_recording();
@@ -1704,13 +1733,15 @@ bool recording_screen(bool no_source)
1704 peak_meter_trigger(false); 1733 peak_meter_trigger(false);
1705 peak_meter_set_trigger_listener(NULL); 1734 peak_meter_set_trigger_listener(NULL);
1706 1735
1707 in_screen = false; 1736 rec_status &= ~RCSTAT_IN_RECSCREEN;
1708 sound_settings_apply(); 1737 sound_settings_apply();
1709 1738
1710 FOR_NB_SCREENS(i) 1739 FOR_NB_SCREENS(i)
1711 screens[i].setfont(FONT_UI); 1740 screens[i].setfont(FONT_UI);
1712 1741
1713 if (have_recorded) 1742 /* if the directory was created or recording happened, make sure the
1743 browser is updated */
1744 if (rec_status & (RCSTAT_CREATED_DIRECTORY | RCSTAT_HAVE_RECORDED))
1714 reload_directory(); 1745 reload_directory();
1715 1746
1716#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 1747#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
@@ -1719,7 +1750,7 @@ bool recording_screen(bool no_source)
1719 1750
1720 settings_save(); 1751 settings_save();
1721 1752
1722 return been_in_usb_mode; 1753 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
1723} /* recording_screen */ 1754} /* recording_screen */
1724 1755
1725#if CONFIG_KEYPAD == RECORDER_PAD 1756#if CONFIG_KEYPAD == RECORDER_PAD