summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-04-15 22:16:28 +0000
committerJens Arnold <amiconn@rockbox.org>2007-04-15 22:16:28 +0000
commitce05addf52ed784026d9ca8397f3c2e239ff9ed4 (patch)
tree2371e53a613848849ed7ada266b92c26fb3542d2 /apps/recorder/recording.c
parent49cf05cb91c9160b79323bb8c798604b3cd8e2f2 (diff)
downloadrockbox-ce05addf52ed784026d9ca8397f3c2e239ff9ed4.tar.gz
rockbox-ce05addf52ed784026d9ca8397f3c2e239ff9ed4.zip
Revert recording/repeat timer for now. It is useful as a feature, but didn't receive enough testing on multiple targets, and fixing it is non-trivial. Later reversal would be complicated because of .lng spreading. * The patch should probably redone in a different way, as it's huge for what it does... * Issues: (1) The repeat timer setting has NULL pointer hits. (2) The multi-int setting screen breaks with proportional fonts, and with somewhat larger fonts. (3) On some targets, all values except the leftmost one are unreachable. * Hint: The timer itself would be much simpler if it'd just store & compare ticks (497 days before it wraps).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13172 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c152
1 files changed, 6 insertions, 146 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 7a332228e5..025480cf91 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -70,8 +70,6 @@
70#include "radio.h" 70#include "radio.h"
71#ifdef HAVE_RECORDING 71#ifdef HAVE_RECORDING
72 72
73static struct timer timer;
74
75static bool in_screen = false; 73static bool in_screen = false;
76 74
77bool in_recording_screen(void) 75bool in_recording_screen(void)
@@ -747,37 +745,6 @@ static void trigger_listener(int trigger_status)
747 } 745 }
748} 746}
749 747
750/* countdown timer tick task */
751void timer_tick_task(void)
752{
753 static int mini_tick = 0;
754
755 mini_tick ++;
756 /* the countdown */
757 if ((mini_tick >= HZ) && (timer.countdown))
758 {
759 mini_tick = 0;
760 if (timer.secs) timer.secs -= 1;
761 else{
762 timer.secs = 59;
763 if (timer.mins) timer.mins -= 1;
764 else{
765 timer.mins = 59;
766 if (timer.hrs) timer.hrs -= 1;
767 else{
768 timer.hrs = 23;
769 if (timer.days) timer.days -= 1;
770 else{
771 timer.days = timer.hrs = timer.mins = timer.secs = 0;
772 /* switch timer display on/off when countdown finished */
773 timer.timer_display = !timer.timer_display;
774 }
775 }
776 }
777 }
778 }
779}
780
781bool recording_start_automatic = false; 748bool recording_start_automatic = false;
782 749
783bool recording_screen(bool no_source) 750bool recording_screen(bool no_source)
@@ -789,7 +756,7 @@ bool recording_screen(bool no_source)
789 int w, h; 756 int w, h;
790 int update_countdown = 1; 757 int update_countdown = 1;
791 bool have_recorded = false; 758 bool have_recorded = false;
792 unsigned int seconds, prerec = 0; 759 unsigned int seconds;
793 int hours, minutes; 760 int hours, minutes;
794 char filename[13]; 761 char filename[13];
795 bool been_in_usb_mode = false; 762 bool been_in_usb_mode = false;
@@ -826,9 +793,6 @@ bool recording_screen(bool no_source)
826 int trig_xpos[NB_SCREENS]; 793 int trig_xpos[NB_SCREENS];
827 int trig_ypos[NB_SCREENS]; 794 int trig_ypos[NB_SCREENS];
828 int trig_width[NB_SCREENS]; 795 int trig_width[NB_SCREENS];
829 int countdown_offset = 0;
830 bool repeat_timer_start = false;
831 unsigned int repeat_timer;
832 796
833 static const unsigned char *byte_units[] = { 797 static const unsigned char *byte_units[] = {
834 ID2P(LANG_BYTE), 798 ID2P(LANG_BYTE),
@@ -840,11 +804,6 @@ bool recording_screen(bool no_source)
840 struct audio_recording_options rec_options; 804 struct audio_recording_options rec_options;
841 805
842 in_screen = true; 806 in_screen = true;
843
844 /* Stop countdown if countdown settings changed */
845 if (!timer.countdown)
846 tick_remove_task(timer_tick_task);
847
848 cursor = 0; 807 cursor = 0;
849#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 808#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
850 ata_set_led_enabled(false); 809 ata_set_led_enabled(false);
@@ -978,25 +937,6 @@ bool recording_screen(bool no_source)
978 last_audio_stat = audio_stat; 937 last_audio_stat = audio_stat;
979 } 938 }
980 939
981 /* repeat_timer is the repeat time in seconds */
982 repeat_timer = (timer.mins_rpt * 60 + timer.hrs_rpt *
983 3600 + timer.days_rpt * 3600 * 24);
984
985 /* decide on repeat timer status */
986 if ((repeat_timer > rec_timesplit_seconds()) &&
987 global_settings.rec_timesplit)
988 timer.repeater = true;
989 else
990 timer.repeater = false;
991
992 /* When countdown timer reaches zero fake a new file button press */
993 if (timer.countdown && !timer.days && !timer.hrs && !timer.mins &&
994 !timer.secs)
995 {
996 tick_remove_task(timer_tick_task);
997 button = ACTION_REC_NEWFILE;
998 timer.countdown = false;
999 }
1000 940
1001 if (recording_start_automatic) 941 if (recording_start_automatic)
1002 { 942 {
@@ -1051,27 +991,7 @@ bool recording_screen(bool no_source)
1051 case ACTION_REC_NEWFILE: 991 case ACTION_REC_NEWFILE:
1052 /* Only act if the mpeg is stopped */ 992 /* Only act if the mpeg is stopped */
1053 if(!(audio_stat & AUDIO_STATUS_RECORD)) 993 if(!(audio_stat & AUDIO_STATUS_RECORD))
1054 { /* if countdown timer is set, start countdown */ 994 {
1055 if (timer.days || timer.hrs || timer.mins || timer.secs)
1056 {
1057 if (button == ACTION_REC_PAUSE)
1058 {
1059 timer.countdown = !timer.countdown;
1060 if (timer.countdown)
1061 tick_add_task(timer_tick_task);
1062 else
1063 tick_remove_task(timer_tick_task);
1064 break;
1065 }
1066 else
1067 {
1068 /* if newfile button pressed and countdown timer is on,
1069 start new file and reset timer */
1070 tick_remove_task(timer_tick_task);
1071 timer.days = timer.hrs = timer.mins = timer.secs = 0;
1072 timer.countdown = false;
1073 }
1074 }
1075 /* is this manual or triggered recording? */ 995 /* is this manual or triggered recording? */
1076 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) || 996 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1077 (peak_meter_trigger_status() != TRIG_OFF)) 997 (peak_meter_trigger_status() != TRIG_OFF))
@@ -1079,11 +999,6 @@ bool recording_screen(bool no_source)
1079 /* manual recording */ 999 /* manual recording */
1080 have_recorded = true; 1000 have_recorded = true;
1081 rec_record(); 1001 rec_record();
1082 repeat_timer_start = true; /* allow access to repeat timer
1083 code */
1084 /* amount of file that has been prerecorded - needed for
1085 syncing repeat timer */
1086 prerec = audio_recorded_time() / HZ;
1087 last_seconds = 0; 1002 last_seconds = 0;
1088 if (talk_menu) 1003 if (talk_menu)
1089 { /* no voice possible here, but a beep */ 1004 { /* no voice possible here, but a beep */
@@ -1282,6 +1197,7 @@ bool recording_screen(bool no_source)
1282#ifdef HAVE_FMRADIO_IN 1197#ifdef HAVE_FMRADIO_IN
1283 const int prev_rec_source = global_settings.rec_source; 1198 const int prev_rec_source = global_settings.rec_source;
1284#endif 1199#endif
1200
1285#if (CONFIG_LED == LED_REAL) 1201#if (CONFIG_LED == LED_REAL)
1286 /* led is restored at begin of loop / end of function */ 1202 /* led is restored at begin of loop / end of function */
1287 led(false); 1203 led(false);
@@ -1305,10 +1221,6 @@ bool recording_screen(bool no_source)
1305 && prev_rec_source == AUDIO_SRC_FMRADIO) 1221 && prev_rec_source == AUDIO_SRC_FMRADIO)
1306 radio_status = FMRADIO_OFF; 1222 radio_status = FMRADIO_OFF;
1307#endif 1223#endif
1308 /* if countdown timer settings changed in menu,
1309 stop counting and reset */
1310 if (!timer.countdown)
1311 tick_remove_task(timer_tick_task);
1312 1224
1313#if CONFIG_CODEC == SWCODEC 1225#if CONFIG_CODEC == SWCODEC
1314 /* reinit after submenu exit */ 1226 /* reinit after submenu exit */
@@ -1407,9 +1319,6 @@ bool recording_screen(bool no_source)
1407 break; 1319 break;
1408 } /* end switch */ 1320 } /* end switch */
1409 1321
1410 /* display timer status in status bar if countdown enabled */
1411 timer.timer_display = timer.countdown;
1412
1413#ifdef HAVE_AGC 1322#ifdef HAVE_AGC
1414 peak_read = !peak_read; 1323 peak_read = !peak_read;
1415 if (peak_read) { /* every 2nd run of loop */ 1324 if (peak_read) { /* every 2nd run of loop */
@@ -1460,13 +1369,11 @@ bool recording_screen(bool no_source)
1460#endif /* CONFIG_CODEC == SWCODEC */ 1369#endif /* CONFIG_CODEC == SWCODEC */
1461 if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method)) 1370 if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method))
1462 { 1371 {
1463 countdown_offset = 1;
1464 dmb = dsize/1024/1024; 1372 dmb = dsize/1024/1024;
1465 snprintf(buf, sizeof(buf), "%s %dMB", 1373 snprintf(buf, sizeof(buf), "%s %dMB",
1466 str(LANG_SYSFONT_SPLIT_SIZE), dmb); 1374 str(LANG_SYSFONT_SPLIT_SIZE), dmb);
1467 } 1375 }
1468 /* only display recording time if countdown timer is off */ 1376 else
1469 else if (!timer.days && !timer.hrs && !timer.mins && !timer.secs)
1470 { 1377 {
1471 hours = seconds / 3600; 1378 hours = seconds / 3600;
1472 minutes = (seconds - (hours * 3600)) / 60; 1379 minutes = (seconds - (hours * 3600)) / 60;
@@ -1474,11 +1381,6 @@ bool recording_screen(bool no_source)
1474 str(LANG_SYSFONT_RECORDING_TIME), 1381 str(LANG_SYSFONT_RECORDING_TIME),
1475 hours, minutes, seconds%60); 1382 hours, minutes, seconds%60);
1476 } 1383 }
1477 else
1478 {
1479 countdown_offset = 0;
1480 snprintf(buf, 32, "");
1481 }
1482 1384
1483 for(i = 0; i < screen_update; i++) 1385 for(i = 0; i < screen_update; i++)
1484 screens[i].puts(0, 0, buf); 1386 screens[i].puts(0, 0, buf);
@@ -1502,8 +1404,7 @@ bool recording_screen(bool no_source)
1502 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC), 1404 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC),
1503 dhours, dminutes); 1405 dhours, dminutes);
1504 } 1406 }
1505 /* only display recording size if countdown timer is off */ 1407 else
1506 else if (!timer.days && !timer.hrs && !timer.mins && !timer.secs)
1507 { 1408 {
1508 output_dyn_value(buf2, sizeof buf2, 1409 output_dyn_value(buf2, sizeof buf2,
1509 num_recorded_bytes, 1410 num_recorded_bytes,
@@ -1515,16 +1416,6 @@ bool recording_screen(bool no_source)
1515 for(i = 0; i < screen_update; i++) 1416 for(i = 0; i < screen_update; i++)
1516 screens[i].puts(0, 1, buf); 1417 screens[i].puts(0, 1, buf);
1517 1418
1518 /* display countdown timer if set */
1519 if (timer.days || timer.hrs || timer.mins || timer.secs)
1520 {
1521 snprintf(buf, 32, "%s %d:%02d:%02d:%02d", str(LANG_REC_TIMER),
1522 timer.days, timer.hrs, timer.mins, timer.secs);
1523
1524 for(i = 0; i < screen_update; i++)
1525 screens[i].puts(0, countdown_offset, buf);
1526 }
1527
1528 for(i = 0; i < screen_update; i++) 1419 for(i = 0; i < screen_update; i++)
1529 { 1420 {
1530 if (filename_offset[i] > 0) 1421 if (filename_offset[i] > 0)
@@ -1558,36 +1449,11 @@ bool recording_screen(bool no_source)
1558 rec_new_file(); 1449 rec_new_file();
1559 last_seconds = 0; 1450 last_seconds = 0;
1560 } 1451 }
1561 else if (repeat_timer_start) 1452 else
1562 { 1453 {
1563 peak_meter_trigger(false); 1454 peak_meter_trigger(false);
1564 peak_meter_set_trigger_listener(NULL); 1455 peak_meter_set_trigger_listener(NULL);
1565 audio_stop_recording(); 1456 audio_stop_recording();
1566
1567 /* stop any more attempts to access this code until a new
1568 recording is started */
1569 repeat_timer_start = false;
1570
1571 /* start repeat countdown if set and only if
1572 stop time < repeat time */
1573 if (timer.repeater)
1574 {
1575 repeat_timer -= dseconds;
1576 timer.days = repeat_timer / (3600 * 24);
1577 timer.hrs = (repeat_timer - (timer.days * 3600 * 24)) /
1578 3600;
1579 timer.mins = (repeat_timer - (timer.hrs * 3600)) / 60;
1580 timer.secs = prerec; /* add prerecorded time to timer */
1581
1582 /* This is not really a toggle so much as a safety feature
1583 so that it is impossible to start the timer more than
1584 once */
1585 timer.countdown = !timer.countdown;
1586 if (timer.countdown)
1587 tick_add_task(timer_tick_task);
1588 else
1589 tick_remove_task(timer_tick_task);
1590 }
1591 } 1457 }
1592 update_countdown = 1; 1458 update_countdown = 1;
1593 } 1459 }
@@ -2169,12 +2035,6 @@ static bool f3_rec_screen(void)
2169} 2035}
2170#endif /* CONFIG_KEYPAD == RECORDER_PAD */ 2036#endif /* CONFIG_KEYPAD == RECORDER_PAD */
2171 2037
2172struct timer *get_timerstat(void)
2173{
2174 return &timer;
2175}
2176
2177
2178#if CONFIG_CODEC == SWCODEC 2038#if CONFIG_CODEC == SWCODEC
2179void audio_beep(int duration) 2039void audio_beep(int duration)
2180{ 2040{