summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-09-18 12:41:12 +0000
committerJens Arnold <amiconn@rockbox.org>2006-09-18 12:41:12 +0000
commitfa9dee01bc70a56cb602f66776a43939c8293f6f (patch)
treecde60a608aa0f16f51c28099f784d85b832dc862 /apps/recorder/recording.c
parent7ef47ed87614d6100b491b2c0eb9f75d1fdc1f01 (diff)
downloadrockbox-fa9dee01bc70a56cb602f66776a43939c8293f6f.tar.gz
rockbox-fa9dee01bc70a56cb602f66776a43939c8293f6f.zip
Reverted the recording timer commit, as it has at least 2 major problems. (1) It uses the user timer, which interferes e.g. with backlight fading on H1x0 (and potentially other targets). Using the user timer here is a waste, as the required timing lies in the range of seconds to days. A tick task would be sufficient. (2) It draws to the LCD from within an ISR. This must not be done unless there's a mechanism to ensure it doesn't interfere with the main thread's drawing, otherwise garbage might be displayed and LCD updates might stop working.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10991 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c173
1 files changed, 5 insertions, 168 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 4d0e226254..6ee71d2eee 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -69,18 +69,8 @@
69#include "screen_access.h" 69#include "screen_access.h"
70#include "action.h" 70#include "action.h"
71#include "radio.h" 71#include "radio.h"
72#include "timer.h"
73#ifdef HAVE_RECORDING 72#ifdef HAVE_RECORDING
74 73
75#ifdef SIMULATOR
76bool timer_register(int reg_prio, void (*unregister_callback)(void),
77 long cycles, int int_prio, void (*timer_callback)(void));
78void timer_unregister(void);
79#define TIMER_FREQ 0
80#endif
81#define TIMER_ICON_WIDTH 7
82#define TIMER_ICON_HEIGHT 7
83
84#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1) 74#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
85 75
86bool f2_rec_screen(void); 76bool f2_rec_screen(void);
@@ -88,9 +78,6 @@ bool f3_rec_screen(void);
88 78
89#define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */ 79#define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */
90 80
91int days, hrs, mins, secs;
92bool timer_icon; /* timer icon displayed? */
93
94int screen_update = NB_SCREENS; 81int screen_update = NB_SCREENS;
95bool remote_display_on = true; 82bool remote_display_on = true;
96const char* const freq_str[6] = 83const char* const freq_str[6] =
@@ -792,52 +779,6 @@ static void trigger_listener(int trigger_status)
792 } 779 }
793} 780}
794 781
795/* countdown timer callback function */
796void timer_callback(void)
797{
798 static int mini_tick = 0;
799 /* print icon at bottom right of main screen */
800 if (timer_icon)
801 screens[0].mono_bitmap(bitmap_icons_7x7[Icon_Timer],
802 screens[0].width - TIMER_ICON_WIDTH,
803 screens[0].height - TIMER_ICON_HEIGHT,
804 TIMER_ICON_WIDTH, TIMER_ICON_HEIGHT);
805 else
806 screens[0].mono_bitmap(bitmap_icons_7x7[Icon_Blank],
807 screens[0].width - TIMER_ICON_WIDTH,
808 screens[0].height - TIMER_ICON_HEIGHT,
809 TIMER_ICON_WIDTH, TIMER_ICON_HEIGHT);
810
811 screens[0].update_rect(screens[0].width - TIMER_ICON_WIDTH,
812 screens[0].height - TIMER_ICON_HEIGHT,
813 TIMER_ICON_WIDTH, TIMER_ICON_HEIGHT);
814
815 mini_tick ++;
816 /* the countdown */
817 if (mini_tick > 10)
818 {
819 secs -= 1;
820 if (secs < 0){
821 mins -= 1;
822 secs = 59;
823 if (mins < 0){
824 hrs -= 1;
825 mins = 59;
826 if (hrs < 0){
827 days -= 1;
828 hrs = 23;
829 if (days < 0)
830 {
831 days = hrs = mins = secs = 0;
832 timer_icon = !timer_icon; /* flash icon when */
833 } /* countdown finished */
834 }
835 }
836 }
837 mini_tick = 0;
838 }
839}
840
841bool recording_screen(bool no_source) 782bool recording_screen(bool no_source)
842{ 783{
843 long button; 784 long button;
@@ -877,8 +818,6 @@ bool recording_screen(bool no_source)
877 int i; 818 int i;
878 int filename_offset[NB_SCREENS]; 819 int filename_offset[NB_SCREENS];
879 int pm_y[NB_SCREENS]; 820 int pm_y[NB_SCREENS];
880 static bool countdown; /* countdown in progress indicator */
881 int countdown_offset = 0;
882 821
883 static const unsigned char *byte_units[] = { 822 static const unsigned char *byte_units[] = {
884 ID2P(LANG_BYTE), 823 ID2P(LANG_BYTE),
@@ -888,20 +827,6 @@ bool recording_screen(bool no_source)
888 }; 827 };
889 828
890 global_settings.recscreen_on = true; 829 global_settings.recscreen_on = true;
891
892 /* Stop countdown if countdown settings changed */
893 if ((mins != global_settings.ctdn_mins)||
894 (hrs != global_settings.ctdn_hrs) ||
895 (days != global_settings.ctdn_days))
896 {
897 mins = global_settings.ctdn_mins;
898 hrs = global_settings.ctdn_hrs;
899 days = global_settings.ctdn_days;
900 secs = global_settings.ctdn_secs;
901 countdown = false;
902 timer_unregister();
903 }
904
905 cursor = 0; 830 cursor = 0;
906#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 831#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
907 ata_set_led_enabled(false); 832 ata_set_led_enabled(false);
@@ -1044,17 +969,6 @@ bool recording_screen(bool no_source)
1044 last_audio_stat = audio_stat; 969 last_audio_stat = audio_stat;
1045 } 970 }
1046 971
1047 /* When countdown timer reaches zero fake a new file button press */
1048 if (countdown && !days && !hrs && !mins && !secs)
1049 {
1050 timer_unregister();
1051 button = ACTION_REC_NEWFILE;
1052 countdown = false;
1053 global_settings.ctdn_days = days;
1054 global_settings.ctdn_hrs = hrs;
1055 global_settings.ctdn_mins = mins;
1056 }
1057
1058 switch(button) 972 switch(button)
1059 { 973 {
1060 case ACTION_REC_LCD: 974 case ACTION_REC_LCD:
@@ -1090,12 +1004,7 @@ bool recording_screen(bool no_source)
1090#if CONFIG_CODEC != SWCODEC 1004#if CONFIG_CODEC != SWCODEC
1091 peak_meter_playback(true); 1005 peak_meter_playback(true);
1092 peak_meter_enabled = false; 1006 peak_meter_enabled = false;
1093#endif 1007#endif
1094 /* keeps settings the same as the countdown values */
1095 global_settings.ctdn_days = days;
1096 global_settings.ctdn_hrs = hrs;
1097 global_settings.ctdn_mins = mins;
1098 global_settings.ctdn_secs = secs;
1099 done = true; 1008 done = true;
1100 } 1009 }
1101 update_countdown = 1; /* Update immediately */ 1010 update_countdown = 1; /* Update immediately */
@@ -1105,27 +1014,7 @@ bool recording_screen(bool no_source)
1105 case ACTION_REC_NEWFILE: 1014 case ACTION_REC_NEWFILE:
1106 /* Only act if the mpeg is stopped */ 1015 /* Only act if the mpeg is stopped */
1107 if(!(audio_stat & AUDIO_STATUS_RECORD)) 1016 if(!(audio_stat & AUDIO_STATUS_RECORD))
1108 { /* if countdown timer is set, start countdown */ 1017 {
1109 if (days || hrs || mins || secs)
1110 {
1111 if (button == ACTION_REC_PAUSE)
1112 {
1113 countdown = !countdown;
1114 if (countdown)
1115 timer_register(1, NULL, TIMER_FREQ/10, 1, timer_callback);
1116 else
1117 timer_unregister();
1118 break;
1119 }
1120 else
1121 {
1122 /* if newfile button pressed and countdown timer is on,
1123 start new file and reset timer */
1124 timer_unregister();
1125 days = hrs = mins = secs = 0;
1126 countdown = false;
1127 }
1128 }
1129 /* is this manual or triggered recording? */ 1018 /* is this manual or triggered recording? */
1130 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) || 1019 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1131 (peak_meter_trigger_status() != TRIG_OFF)) 1020 (peak_meter_trigger_status() != TRIG_OFF))
@@ -1332,11 +1221,7 @@ bool recording_screen(bool no_source)
1332#ifdef HAVE_FMRADIO_IN 1221#ifdef HAVE_FMRADIO_IN
1333 const int prev_rec_source = global_settings.rec_source; 1222 const int prev_rec_source = global_settings.rec_source;
1334#endif 1223#endif
1335 /* maintain countdown values when entering menu */ 1224
1336 global_settings.ctdn_days = days;
1337 global_settings.ctdn_hrs = hrs;
1338 global_settings.ctdn_mins = mins;
1339 global_settings.ctdn_secs = secs;
1340#if CONFIG_LED == LED_REAL 1225#if CONFIG_LED == LED_REAL
1341 /* led is restored at begin of loop / end of function */ 1226 /* led is restored at begin of loop / end of function */
1342 led(false); 1227 led(false);
@@ -1360,19 +1245,6 @@ bool recording_screen(bool no_source)
1360 && prev_rec_source == AUDIO_SRC_FMRADIO) 1245 && prev_rec_source == AUDIO_SRC_FMRADIO)
1361 radio_status = FMRADIO_OFF; 1246 radio_status = FMRADIO_OFF;
1362#endif 1247#endif
1363 /* if countdown timer settings changed in menu,
1364 stop counting and reset */
1365 if ((hrs != global_settings.ctdn_hrs) ||
1366 (mins != global_settings.ctdn_mins) ||
1367 (days != global_settings.ctdn_days))
1368 {
1369 days = global_settings.ctdn_days;
1370 hrs = global_settings.ctdn_hrs;
1371 mins = global_settings.ctdn_mins;
1372 secs = global_settings.ctdn_secs;
1373 countdown = false;
1374 timer_unregister();
1375 }
1376 1248
1377#if CONFIG_CODEC == SWCODEC 1249#if CONFIG_CODEC == SWCODEC
1378 /* reinit after submenu exit */ 1250 /* reinit after submenu exit */
@@ -1475,8 +1347,6 @@ bool recording_screen(bool no_source)
1475 break; 1347 break;
1476 } 1348 }
1477 1349
1478 timer_icon = countdown; /* display timer icon if countdown enabled */
1479
1480#ifdef HAVE_AGC 1350#ifdef HAVE_AGC
1481 peak_read = !peak_read; 1351 peak_read = !peak_read;
1482 if (peak_read) { /* every 2nd run of loop */ 1352 if (peak_read) { /* every 2nd run of loop */
@@ -1513,13 +1383,11 @@ bool recording_screen(bool no_source)
1513 1383
1514 if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method)) 1384 if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method))
1515 { 1385 {
1516 countdown_offset = 1;
1517 dmb = dsize/1024/1024; 1386 dmb = dsize/1024/1024;
1518 snprintf(buf, sizeof(buf), "%s %dMB", 1387 snprintf(buf, sizeof(buf), "%s %dMB",
1519 str(LANG_SYSFONT_SPLIT_SIZE), dmb); 1388 str(LANG_SYSFONT_SPLIT_SIZE), dmb);
1520 } 1389 }
1521 /* only display recording time if countdown timer is off */ 1390 else
1522 else if (!days && !hrs && !mins && !secs)
1523 { 1391 {
1524 hours = seconds / 3600; 1392 hours = seconds / 3600;
1525 minutes = (seconds - (hours * 3600)) / 60; 1393 minutes = (seconds - (hours * 3600)) / 60;
@@ -1527,11 +1395,6 @@ bool recording_screen(bool no_source)
1527 str(LANG_SYSFONT_RECORDING_TIME), 1395 str(LANG_SYSFONT_RECORDING_TIME),
1528 hours, minutes, seconds%60); 1396 hours, minutes, seconds%60);
1529 } 1397 }
1530 else
1531 {
1532 countdown_offset = 0;
1533 snprintf(buf, 32, "");
1534 }
1535 1398
1536 for(i = 0; i < screen_update; i++) 1399 for(i = 0; i < screen_update; i++)
1537 screens[i].puts(0, 0, buf); 1400 screens[i].puts(0, 0, buf);
@@ -1555,8 +1418,7 @@ bool recording_screen(bool no_source)
1555 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC), 1418 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC),
1556 dhours, dminutes); 1419 dhours, dminutes);
1557 } 1420 }
1558 /* only display recording size if countdown timer is off */ 1421 else
1559 else if (!days && !hrs && !mins && !secs)
1560 { 1422 {
1561 output_dyn_value(buf2, sizeof buf2, 1423 output_dyn_value(buf2, sizeof buf2,
1562 num_recorded_bytes, 1424 num_recorded_bytes,
@@ -1568,16 +1430,6 @@ bool recording_screen(bool no_source)
1568 for(i = 0; i < screen_update; i++) 1430 for(i = 0; i < screen_update; i++)
1569 screens[i].puts(0, 1, buf); 1431 screens[i].puts(0, 1, buf);
1570 1432
1571 /* display countdown timer if set */
1572 if (days || hrs || mins || secs)
1573 {
1574 snprintf(buf, 32, "%s %d:%02d:%02d:%02d", str(LANG_REC_TIMER),
1575 days, hrs, mins, secs);
1576
1577 for(i = 0; i < screen_update; i++)
1578 screens[i].puts(0, countdown_offset, buf);
1579 }
1580
1581 for(i = 0; i < screen_update; i++) 1433 for(i = 0; i < screen_update; i++)
1582 { 1434 {
1583 if (filename_offset[i] > 0) 1435 if (filename_offset[i] > 0)
@@ -2271,21 +2123,6 @@ unsigned long pcm_rec_status(void)
2271 2123
2272#endif /* #ifdef SIMULATOR */ 2124#endif /* #ifdef SIMULATOR */
2273#endif /* #ifdef CONFIG_CODEC == SWCODEC */ 2125#endif /* #ifdef CONFIG_CODEC == SWCODEC */
2274#ifdef SIMULATOR
2275bool timer_register(int reg_prio, void (*unregister_callback)(void),
2276 long cycles, int int_prio, void (*timer_callback)(void))
2277{
2278 reg_prio = reg_prio;
2279 unregister_callback = unregister_callback;
2280 cycles = cycles;
2281 int_prio = int_prio;
2282 timer_callback = timer_callback;
2283 return false;
2284}
2285 2126
2286void timer_unregister(void)
2287{
2288}
2289#endif
2290 2127
2291#endif /* HAVE_RECORDING */ 2128#endif /* HAVE_RECORDING */