diff options
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r-- | apps/recorder/recording.c | 95 |
1 files changed, 68 insertions, 27 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 68528c71c0..053eecd844 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -694,19 +694,38 @@ void rec_set_recording_options(struct audio_recording_options *options) | |||
694 | audio_set_recording_options(options); | 694 | audio_set_recording_options(options); |
695 | } | 695 | } |
696 | 696 | ||
697 | /* steals mp3 buffer, creates unique filename and starts recording */ | 697 | void rec_command(enum recording_command cmd) |
698 | void rec_record(void) | ||
699 | { | 698 | { |
699 | switch(cmd) | ||
700 | { | ||
701 | case RECORDING_CMD_STOP: | ||
702 | pm_activate_clipcount(false); | ||
703 | audio_stop_recording(); | ||
704 | break; | ||
705 | case RECORDING_CMD_START: | ||
706 | /* steal mp3 buffer, create unique filename and start recording */ | ||
707 | pm_reset_clipcount(); | ||
708 | pm_activate_clipcount(true); | ||
700 | #if CONFIG_CODEC != SWCODEC | 709 | #if CONFIG_CODEC != SWCODEC |
701 | talk_buffer_steal(); /* we use the mp3 buffer */ | 710 | talk_buffer_steal(); /* we use the mp3 buffer */ |
702 | #endif | 711 | #endif |
703 | audio_record(rec_create_filename(path_buffer)); | 712 | audio_record(rec_create_filename(path_buffer)); |
704 | } | 713 | break; |
705 | 714 | case RECORDING_CMD_START_NEWFILE: | |
706 | /* creates unique filename and starts recording */ | 715 | /* create unique filename and start recording*/ |
707 | void rec_new_file(void) | 716 | pm_reset_clipcount(); |
708 | { | 717 | pm_activate_clipcount(true); /* just to be sure */ |
709 | audio_new_file(rec_create_filename(path_buffer)); | 718 | audio_new_file(rec_create_filename(path_buffer)); |
719 | break; | ||
720 | case RECORDING_CMD_PAUSE: | ||
721 | pm_activate_clipcount(false); | ||
722 | audio_pause_recording(); | ||
723 | break; | ||
724 | case RECORDING_CMD_RESUME: | ||
725 | pm_activate_clipcount(true); | ||
726 | audio_resume_recording(); | ||
727 | break; | ||
728 | } | ||
710 | } | 729 | } |
711 | 730 | ||
712 | /* used in trigger_listerner and recording_screen */ | 731 | /* used in trigger_listerner and recording_screen */ |
@@ -725,7 +744,7 @@ static void trigger_listener(int trigger_status) | |||
725 | if(!(audio_status() & AUDIO_STATUS_RECORD)) | 744 | if(!(audio_status() & AUDIO_STATUS_RECORD)) |
726 | { | 745 | { |
727 | rec_status |= RCSTAT_HAVE_RECORDED; | 746 | rec_status |= RCSTAT_HAVE_RECORDED; |
728 | rec_record(); | 747 | rec_command(RECORDING_CMD_START); |
729 | #if CONFIG_CODEC != SWCODEC | 748 | #if CONFIG_CODEC != SWCODEC |
730 | /* give control to mpeg thread so that it can start | 749 | /* give control to mpeg thread so that it can start |
731 | recording */ | 750 | recording */ |
@@ -738,11 +757,13 @@ static void trigger_listener(int trigger_status) | |||
738 | { | 757 | { |
739 | if((audio_status() & AUDIO_STATUS_PAUSE) && | 758 | if((audio_status() & AUDIO_STATUS_PAUSE) && |
740 | (global_settings.rec_trigger_type == 1)) | 759 | (global_settings.rec_trigger_type == 1)) |
741 | audio_resume_recording(); | 760 | { |
761 | rec_command(RECORDING_CMD_RESUME); | ||
762 | } | ||
742 | /* New file on trig start*/ | 763 | /* New file on trig start*/ |
743 | else if (global_settings.rec_trigger_type != 2) | 764 | else if (global_settings.rec_trigger_type != 2) |
744 | { | 765 | { |
745 | rec_new_file(); | 766 | rec_command(RECORDING_CMD_START_NEWFILE); |
746 | /* tell recording_screen to reset the time */ | 767 | /* tell recording_screen to reset the time */ |
747 | last_seconds = 0; | 768 | last_seconds = 0; |
748 | } | 769 | } |
@@ -756,15 +777,15 @@ static void trigger_listener(int trigger_status) | |||
756 | switch(global_settings.rec_trigger_type) | 777 | switch(global_settings.rec_trigger_type) |
757 | { | 778 | { |
758 | case 0: /* Stop */ | 779 | case 0: /* Stop */ |
759 | audio_stop_recording(); | 780 | rec_command(RECORDING_CMD_STOP); |
760 | break; | 781 | break; |
761 | 782 | ||
762 | case 1: /* Pause */ | 783 | case 1: /* Pause */ |
763 | audio_pause_recording(); | 784 | rec_command(RECORDING_CMD_PAUSE); |
764 | break; | 785 | break; |
765 | 786 | ||
766 | case 2: /* New file on trig stop*/ | 787 | case 2: /* New file on trig stop*/ |
767 | rec_new_file(); | 788 | rec_command(RECORDING_CMD_START_NEWFILE); |
768 | /* tell recording_screen to reset the time */ | 789 | /* tell recording_screen to reset the time */ |
769 | last_seconds = 0; | 790 | last_seconds = 0; |
770 | break; | 791 | break; |
@@ -825,6 +846,9 @@ bool recording_screen(bool no_source) | |||
825 | int trig_xpos[NB_SCREENS]; | 846 | int trig_xpos[NB_SCREENS]; |
826 | int trig_ypos[NB_SCREENS]; | 847 | int trig_ypos[NB_SCREENS]; |
827 | int trig_width[NB_SCREENS]; | 848 | int trig_width[NB_SCREENS]; |
849 | /* pm_x = offset pm to put clipcount in front. | ||
850 | Use lcd_getstringsize() when not using SYSFONT */ | ||
851 | int pm_x = global_settings.peak_meter_clipcounter ? 30 : 0; | ||
828 | 852 | ||
829 | static const unsigned char *byte_units[] = { | 853 | static const unsigned char *byte_units[] = { |
830 | ID2P(LANG_BYTE), | 854 | ID2P(LANG_BYTE), |
@@ -881,6 +905,8 @@ bool recording_screen(bool no_source) | |||
881 | rec_init_filename(); | 905 | rec_init_filename(); |
882 | #endif | 906 | #endif |
883 | 907 | ||
908 | pm_reset_clipcount(); | ||
909 | pm_activate_clipcount(false); | ||
884 | settings_apply_trigger(); | 910 | settings_apply_trigger(); |
885 | 911 | ||
886 | #ifdef HAVE_AGC | 912 | #ifdef HAVE_AGC |
@@ -973,7 +999,7 @@ bool recording_screen(bool no_source) | |||
973 | #endif /* CONFIG_LED */ | 999 | #endif /* CONFIG_LED */ |
974 | 1000 | ||
975 | /* Wait for a button a while (HZ/10) drawing the peak meter */ | 1001 | /* Wait for a button a while (HZ/10) drawing the peak meter */ |
976 | button = peak_meter_draw_get_btn(0, pm_y, h * PM_HEIGHT, screen_update); | 1002 | button = peak_meter_draw_get_btn(pm_x, pm_y, h * PM_HEIGHT, screen_update); |
977 | 1003 | ||
978 | if (last_audio_stat != audio_stat) | 1004 | if (last_audio_stat != audio_stat) |
979 | { | 1005 | { |
@@ -1021,7 +1047,7 @@ bool recording_screen(bool no_source) | |||
1021 | 1047 | ||
1022 | if(audio_stat & AUDIO_STATUS_RECORD) | 1048 | if(audio_stat & AUDIO_STATUS_RECORD) |
1023 | { | 1049 | { |
1024 | audio_stop_recording(); | 1050 | rec_command(RECORDING_CMD_STOP); |
1025 | } | 1051 | } |
1026 | else | 1052 | else |
1027 | { | 1053 | { |
@@ -1045,7 +1071,7 @@ bool recording_screen(bool no_source) | |||
1045 | { | 1071 | { |
1046 | /* manual recording */ | 1072 | /* manual recording */ |
1047 | rec_status |= RCSTAT_HAVE_RECORDED; | 1073 | rec_status |= RCSTAT_HAVE_RECORDED; |
1048 | rec_record(); | 1074 | rec_command(RECORDING_CMD_START); |
1049 | last_seconds = 0; | 1075 | last_seconds = 0; |
1050 | if (global_settings.talk_menu) | 1076 | if (global_settings.talk_menu) |
1051 | { | 1077 | { |
@@ -1068,7 +1094,7 @@ bool recording_screen(bool no_source) | |||
1068 | /*if new file button pressed, start new file */ | 1094 | /*if new file button pressed, start new file */ |
1069 | if (button == ACTION_REC_NEWFILE) | 1095 | if (button == ACTION_REC_NEWFILE) |
1070 | { | 1096 | { |
1071 | rec_new_file(); | 1097 | rec_command(RECORDING_CMD_START_NEWFILE); |
1072 | last_seconds = 0; | 1098 | last_seconds = 0; |
1073 | } | 1099 | } |
1074 | else | 1100 | else |
@@ -1076,7 +1102,7 @@ bool recording_screen(bool no_source) | |||
1076 | { | 1102 | { |
1077 | if(audio_stat & AUDIO_STATUS_PAUSE) | 1103 | if(audio_stat & AUDIO_STATUS_PAUSE) |
1078 | { | 1104 | { |
1079 | audio_resume_recording(); | 1105 | rec_command(RECORDING_CMD_RESUME); |
1080 | if (global_settings.talk_menu) | 1106 | if (global_settings.talk_menu) |
1081 | { | 1107 | { |
1082 | /* no voice possible here, but a beep */ | 1108 | /* no voice possible here, but a beep */ |
@@ -1085,7 +1111,7 @@ bool recording_screen(bool no_source) | |||
1085 | } | 1111 | } |
1086 | else | 1112 | else |
1087 | { | 1113 | { |
1088 | audio_pause_recording(); | 1114 | rec_command(RECORDING_CMD_PAUSE); |
1089 | } | 1115 | } |
1090 | } | 1116 | } |
1091 | } | 1117 | } |
@@ -1332,7 +1358,7 @@ bool recording_screen(bool no_source) | |||
1332 | case ACTION_REC_F3: | 1358 | case ACTION_REC_F3: |
1333 | if(audio_stat & AUDIO_STATUS_RECORD) | 1359 | if(audio_stat & AUDIO_STATUS_RECORD) |
1334 | { | 1360 | { |
1335 | rec_new_file(); | 1361 | rec_command(RECORDING_CMD_START_NEWFILE); |
1336 | last_seconds = 0; | 1362 | last_seconds = 0; |
1337 | } | 1363 | } |
1338 | else | 1364 | else |
@@ -1497,18 +1523,33 @@ bool recording_screen(bool no_source) | |||
1497 | if (!(global_settings.rec_split_type) | 1523 | if (!(global_settings.rec_split_type) |
1498 | || (num_recorded_bytes >= MAX_FILE_SIZE)) | 1524 | || (num_recorded_bytes >= MAX_FILE_SIZE)) |
1499 | { | 1525 | { |
1500 | rec_new_file(); | 1526 | rec_command(RECORDING_CMD_START_NEWFILE); |
1501 | last_seconds = 0; | 1527 | last_seconds = 0; |
1502 | } | 1528 | } |
1503 | else | 1529 | else |
1504 | { | 1530 | { |
1505 | peak_meter_trigger(false); | 1531 | peak_meter_trigger(false); |
1506 | peak_meter_set_trigger_listener(NULL); | 1532 | peak_meter_set_trigger_listener(NULL); |
1507 | audio_stop_recording(); | 1533 | rec_command(RECORDING_CMD_STOP); |
1508 | } | 1534 | } |
1509 | update_countdown = 1; | 1535 | update_countdown = 1; |
1510 | } | 1536 | } |
1511 | 1537 | ||
1538 | /* draw the clipcounter just in front of the peakmeter */ | ||
1539 | if(global_settings.peak_meter_clipcounter) | ||
1540 | { | ||
1541 | char clpstr[32]; | ||
1542 | snprintf(clpstr, 32, "%4d", pm_get_clipcount()); | ||
1543 | for(i = 0; i < screen_update; i++) | ||
1544 | { | ||
1545 | if(PM_HEIGHT > 1) | ||
1546 | screens[i].puts(0, 2 + filename_offset[i], | ||
1547 | str(LANG_PM_CLIPCOUNT)); | ||
1548 | screens[i].puts(0, 1 + PM_HEIGHT + filename_offset[i], | ||
1549 | clpstr); | ||
1550 | } | ||
1551 | } | ||
1552 | |||
1512 | snprintf(buf, sizeof(buf), "%s: %s", str(LANG_SYSFONT_VOLUME), | 1553 | snprintf(buf, sizeof(buf), "%s: %s", str(LANG_SYSFONT_VOLUME), |
1513 | fmt_gain(SOUND_VOLUME, | 1554 | fmt_gain(SOUND_VOLUME, |
1514 | global_settings.volume, | 1555 | global_settings.volume, |
@@ -1749,7 +1790,7 @@ bool recording_screen(bool no_source) | |||
1749 | for(i = 0; i < screen_update; i++) | 1790 | for(i = 0; i < screen_update; i++) |
1750 | { | 1791 | { |
1751 | gui_statusbar_draw(&(statusbars.statusbars[i]), true); | 1792 | gui_statusbar_draw(&(statusbars.statusbars[i]), true); |
1752 | peak_meter_screen(&screens[i], 0, pm_y[i], h*PM_HEIGHT); | 1793 | peak_meter_screen(&screens[i], pm_x, pm_y[i], h*PM_HEIGHT); |
1753 | screens[i].update(); | 1794 | screens[i].update(); |
1754 | } | 1795 | } |
1755 | 1796 | ||
@@ -1805,7 +1846,7 @@ bool recording_screen(bool no_source) | |||
1805 | } | 1846 | } |
1806 | 1847 | ||
1807 | #if CONFIG_CODEC == SWCODEC | 1848 | #if CONFIG_CODEC == SWCODEC |
1808 | audio_stop_recording(); | 1849 | rec_command(RECORDING_CMD_STOP); |
1809 | audio_close_recording(); | 1850 | audio_close_recording(); |
1810 | 1851 | ||
1811 | #ifdef HAVE_FMRADIO_REC | 1852 | #ifdef HAVE_FMRADIO_REC |