summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c78
1 files changed, 1 insertions, 77 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 553f815e52..36331a72f3 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -31,17 +31,14 @@
31#include "lcd.h" 31#include "lcd.h"
32#include "led.h" 32#include "led.h"
33#include "audio.h" 33#include "audio.h"
34#if CONFIG_CODEC == SWCODEC
35#include "thread.h" 34#include "thread.h"
36#include "enc_config.h" 35#include "enc_config.h"
37#include "playback.h" 36#include "playback.h"
38#if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT) 37#if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT)
39#include "spdif.h" 38#include "spdif.h"
40#endif 39#endif
41#endif /* CONFIG_CODEC == SWCODEC */
42#include "pcm_record.h" 40#include "pcm_record.h"
43#include "recording.h" 41#include "recording.h"
44#include "mp3_playback.h"
45#include "button.h" 42#include "button.h"
46#include "kernel.h" 43#include "kernel.h"
47#include "settings.h" 44#include "settings.h"
@@ -166,19 +163,9 @@ static bool update_list = false; /* (GIU) list needs updating */
166static int file_number = -1; 163static int file_number = -1;
167#endif /* CONFIG_RTC */ 164#endif /* CONFIG_RTC */
168 165
169#if CONFIG_CODEC == SWCODEC
170
171#define REC_FILE_ENDING(rec_format) \ 166#define REC_FILE_ENDING(rec_format) \
172 (audio_formats[rec_format_afmt[rec_format]].ext_list) 167 (audio_formats[rec_format_afmt[rec_format]].ext_list)
173 168
174#else /* CONFIG_CODEC != SWCODEC */
175
176/* default record file extension for HWCODEC */
177#define REC_FILE_ENDING(rec_format) \
178 (audio_formats[AFMT_MPA_L3].ext_list)
179
180#endif /* CONFIG_CODEC == SWCODEC */
181
182/* path for current file */ 169/* path for current file */
183static char path_buffer[MAX_PATH]; 170static char path_buffer[MAX_PATH];
184 171
@@ -607,18 +594,12 @@ void rec_init_recording_options(struct audio_recording_options *options)
607 options->rec_frequency = global_settings.rec_frequency; 594 options->rec_frequency = global_settings.rec_frequency;
608 options->rec_channels = global_settings.rec_channels; 595 options->rec_channels = global_settings.rec_channels;
609 options->rec_prerecord_time = global_settings.rec_prerecord_time; 596 options->rec_prerecord_time = global_settings.rec_prerecord_time;
610#if CONFIG_CODEC == SWCODEC
611 options->rec_mono_mode = global_settings.rec_mono_mode; 597 options->rec_mono_mode = global_settings.rec_mono_mode;
612 options->rec_source_flags = 0; 598 options->rec_source_flags = 0;
613 options->enc_config.rec_format = global_settings.rec_format; 599 options->enc_config.rec_format = global_settings.rec_format;
614 global_to_encoder_config(&options->enc_config); 600 global_to_encoder_config(&options->enc_config);
615#else
616 options->rec_quality = global_settings.rec_quality;
617 options->rec_editable = global_settings.rec_editable;
618#endif
619} 601}
620 602
621#if CONFIG_CODEC == SWCODEC
622void rec_set_source(int source, unsigned flags) 603void rec_set_source(int source, unsigned flags)
623{ 604{
624 /* Set audio input source, power up/down devices */ 605 /* Set audio input source, power up/down devices */
@@ -628,14 +609,11 @@ void rec_set_source(int source, unsigned flags)
628 peak_meter_playback((flags & SRCF_RECORDING) == 0); 609 peak_meter_playback((flags & SRCF_RECORDING) == 0);
629 peak_meter_enable(true); 610 peak_meter_enable(true);
630} 611}
631#endif /* CONFIG_CODEC == SWCODEC */
632 612
633void rec_set_recording_options(struct audio_recording_options *options) 613void rec_set_recording_options(struct audio_recording_options *options)
634{ 614{
635#if CONFIG_CODEC == SWCODEC
636 rec_set_source(options->rec_source, 615 rec_set_source(options->rec_source,
637 options->rec_source_flags | SRCF_RECORDING); 616 options->rec_source_flags | SRCF_RECORDING);
638#endif
639 audio_set_recording_options(options); 617 audio_set_recording_options(options);
640} 618}
641 619
@@ -646,9 +624,7 @@ void rec_command(enum recording_command cmd)
646 case RECORDING_CMD_STOP_SHUTDOWN: 624 case RECORDING_CMD_STOP_SHUTDOWN:
647 pm_activate_clipcount(false); 625 pm_activate_clipcount(false);
648 audio_stop_recording(); 626 audio_stop_recording();
649#if CONFIG_CODEC == SWCODEC
650 audio_close_recording(); 627 audio_close_recording();
651#endif
652 sys_poweroff(); 628 sys_poweroff();
653 break; 629 break;
654 case RECORDING_CMD_STOP: 630 case RECORDING_CMD_STOP:
@@ -695,12 +671,6 @@ static void trigger_listener(int trigger_status)
695 if(!(audio_status() & AUDIO_STATUS_RECORD)) 671 if(!(audio_status() & AUDIO_STATUS_RECORD))
696 { 672 {
697 rec_status |= RCSTAT_HAVE_RECORDED; 673 rec_status |= RCSTAT_HAVE_RECORDED;
698 rec_command(RECORDING_CMD_START);
699#if CONFIG_CODEC != SWCODEC
700 /* give control to mpeg thread so that it can start
701 recording */
702 yield(); yield(); yield();
703#endif
704 } 674 }
705 675
706 /* if we're already recording this is a retrigger */ 676 /* if we're already recording this is a retrigger */
@@ -791,14 +761,9 @@ enum rec_list_items_mono {
791#ifdef HAVE_SPDIF_REC 761#ifdef HAVE_SPDIF_REC
792enum rec_list_items_spdif { 762enum rec_list_items_spdif {
793 ITEM_VOLUME_D = 0, 763 ITEM_VOLUME_D = 0,
794#if CONFIG_CODEC == SWCODEC
795 ITEM_SAMPLERATE_D = 6, 764 ITEM_SAMPLERATE_D = 6,
796 ITEM_FILENAME_D = 7, 765 ITEM_FILENAME_D = 7,
797 ITEM_COUNT_D = 3, 766 ITEM_COUNT_D = 3,
798#else
799 ITEM_FILENAME_D = 7,
800 ITEM_COUNT_D = 2,
801#endif
802}; 767};
803#endif 768#endif
804 769
@@ -892,14 +857,12 @@ static const char* reclist_get_name(int selected_item, void * data,
892 buf3, sizeof(buf3))); 857 buf3, sizeof(buf3)));
893 break; 858 break;
894#endif 859#endif
895#if CONFIG_CODEC == SWCODEC
896#ifdef HAVE_SPDIF_REC 860#ifdef HAVE_SPDIF_REC
897 case ITEM_SAMPLERATE_D: 861 case ITEM_SAMPLERATE_D:
898 snprintf(buffer, buffer_len, "%s: %lu", 862 snprintf(buffer, buffer_len, "%s: %lu",
899 str(LANG_FREQUENCY), pcm_rec_sample_rate()); 863 str(LANG_FREQUENCY), pcm_rec_sample_rate());
900 break; 864 break;
901#endif 865#endif
902#endif
903 case ITEM_FILENAME: 866 case ITEM_FILENAME:
904 { 867 {
905 if(audio_status() & AUDIO_STATUS_RECORD) 868 if(audio_status() & AUDIO_STATUS_RECORD)
@@ -973,16 +936,12 @@ bool recording_screen(bool no_source)
973 const unsigned long split_seconds = (unsigned) global_settings.rec_timesplit * 60; 936 const unsigned long split_seconds = (unsigned) global_settings.rec_timesplit * 60;
974 const unsigned long split_bytes = rec_sizesplit_bytes(); 937 const unsigned long split_bytes = rec_sizesplit_bytes();
975 938
976#if CONFIG_CODEC == SWCODEC
977 int warning_counter = 0; 939 int warning_counter = 0;
978 #define WARNING_PERIOD 7 940 #define WARNING_PERIOD 7
979#endif
980 941
981#if CONFIG_CODEC == SWCODEC
982#ifdef HAVE_SPDIF_REC 942#ifdef HAVE_SPDIF_REC
983 unsigned long prev_sample_rate = 0; 943 unsigned long prev_sample_rate = 0;
984#endif 944#endif
985#endif
986 945
987#ifdef HAVE_FMRADIO_REC 946#ifdef HAVE_FMRADIO_REC
988 /* Radio is left on if: 947 /* Radio is left on if:
@@ -1030,7 +989,6 @@ bool recording_screen(bool no_source)
1030 ata_set_led_enabled(false); 989 ata_set_led_enabled(false);
1031#endif 990#endif
1032 991
1033#if CONFIG_CODEC == SWCODEC
1034 /* hardware samplerate gets messed up so prevent mixer playing */ 992 /* hardware samplerate gets messed up so prevent mixer playing */
1035 int keyclick = global_settings.keyclick; 993 int keyclick = global_settings.keyclick;
1036 global_settings.keyclick = 0; 994 global_settings.keyclick = 0;
@@ -1039,11 +997,6 @@ bool recording_screen(bool no_source)
1039 talk_disable(true); 997 talk_disable(true);
1040 /* audio_init_recording stops anything playing when it takes the audio 998 /* audio_init_recording stops anything playing when it takes the audio
1041 buffer */ 999 buffer */
1042#else
1043 /* Yes, we use the D/A for monitoring */
1044 peak_meter_enable(true);
1045 peak_meter_playback(true);
1046#endif
1047 1000
1048#ifdef HAVE_AGC 1001#ifdef HAVE_AGC
1049 peak_meter_get_peakhold(&peak_l, &peak_r); 1002 peak_meter_get_peakhold(&peak_l, &peak_r);
@@ -1175,7 +1128,7 @@ bool recording_screen(bool no_source)
1175 goto rec_abort; 1128 goto rec_abort;
1176 } 1129 }
1177 1130
1178#if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0 1131#if CONFIG_RTC == 0
1179 /* If format changed, a new number is required */ 1132 /* If format changed, a new number is required */
1180 rec_init_filename(); 1133 rec_init_filename();
1181#endif 1134#endif
@@ -1202,12 +1155,8 @@ bool recording_screen(bool no_source)
1202 if(global_settings.rec_source == AUDIO_SRC_SPDIF) 1155 if(global_settings.rec_source == AUDIO_SRC_SPDIF)
1203 { 1156 {
1204 listid_to_enum[0] = ITEM_VOLUME_D; 1157 listid_to_enum[0] = ITEM_VOLUME_D;
1205#if CONFIG_CODEC == SWCODEC
1206 listid_to_enum[1] = ITEM_SAMPLERATE_D; 1158 listid_to_enum[1] = ITEM_SAMPLERATE_D;
1207 listid_to_enum[2] = ITEM_FILENAME_D; 1159 listid_to_enum[2] = ITEM_FILENAME_D;
1208#else
1209 listid_to_enum[1] = ITEM_FILENAME_D;
1210#endif
1211 1160
1212 gui_synclist_set_nb_items(&lists, ITEM_COUNT_D); /* spdif */ 1161 gui_synclist_set_nb_items(&lists, ITEM_COUNT_D); /* spdif */
1213 } 1162 }
@@ -1452,10 +1401,6 @@ bool recording_screen(bool no_source)
1452 } 1401 }
1453 else 1402 else
1454 { 1403 {
1455#if CONFIG_CODEC != SWCODEC
1456 peak_meter_playback(true);
1457 peak_meter_enable(false);
1458#endif
1459 done = 1; 1404 done = 1;
1460 } 1405 }
1461 update_countdown = 0; /* Update immediately */ 1406 update_countdown = 0; /* Update immediately */
@@ -1543,11 +1488,7 @@ bool recording_screen(bool no_source)
1543 update_countdown = 0; /* Update immediately */ 1488 update_countdown = 0; /* Update immediately */
1544 break; 1489 break;
1545 case ACTION_STD_MENU: 1490 case ACTION_STD_MENU:
1546#if CONFIG_CODEC == SWCODEC
1547 if(!(audio_stat & AUDIO_STATUS_RECORD)) 1491 if(!(audio_stat & AUDIO_STATUS_RECORD))
1548#else
1549 if(audio_stat != AUDIO_STATUS_RECORD)
1550#endif
1551 { 1492 {
1552#if (CONFIG_LED == LED_REAL) 1493#if (CONFIG_LED == LED_REAL)
1553 /* led is restored at begin of loop / end of function */ 1494 /* led is restored at begin of loop / end of function */
@@ -1622,7 +1563,6 @@ bool recording_screen(bool no_source)
1622 dsize = split_bytes; 1563 dsize = split_bytes;
1623 num_recorded_bytes = audio_num_recorded_bytes(); 1564 num_recorded_bytes = audio_num_recorded_bytes();
1624 1565
1625#if CONFIG_CODEC == SWCODEC
1626 if ((audio_stat & AUDIO_STATUS_WARNING) 1566 if ((audio_stat & AUDIO_STATUS_WARNING)
1627 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2) 1567 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
1628 { 1568 {
@@ -1635,7 +1575,6 @@ bool recording_screen(bool no_source)
1635 (unsigned long)pcm_rec_get_warnings()); 1575 (unsigned long)pcm_rec_get_warnings());
1636 } 1576 }
1637 else 1577 else
1638#endif /* CONFIG_CODEC == SWCODEC */
1639 if ((global_settings.rec_sizesplit) && 1578 if ((global_settings.rec_sizesplit) &&
1640 (global_settings.rec_split_method)) 1579 (global_settings.rec_split_method))
1641 { 1580 {
@@ -1657,16 +1596,11 @@ bool recording_screen(bool no_source)
1657 1596
1658 if(audio_stat & AUDIO_STATUS_PRERECORD) 1597 if(audio_stat & AUDIO_STATUS_PRERECORD)
1659 { 1598 {
1660#if CONFIG_CODEC == SWCODEC
1661 /* Tracks amount of prerecorded data in buffer */ 1599 /* Tracks amount of prerecorded data in buffer */
1662 snprintf(buf, sizeof(buf), "%s (%lu/%ds)...", 1600 snprintf(buf, sizeof(buf), "%s (%lu/%ds)...",
1663 str(LANG_RECORD_PRERECORD), 1601 str(LANG_RECORD_PRERECORD),
1664 audio_prerecorded_time() / HZ, 1602 audio_prerecorded_time() / HZ,
1665 global_settings.rec_prerecord_time); 1603 global_settings.rec_prerecord_time);
1666#else /* !SWCODEC */
1667 snprintf(buf, sizeof(buf), "%s...",
1668 str(LANG_RECORD_PRERECORD));
1669#endif /* CONFIG_CODEC == SWCODEC */
1670 } 1604 }
1671 else 1605 else
1672 { 1606 {
@@ -1782,7 +1716,6 @@ bool recording_screen(bool no_source)
1782 } 1716 }
1783#endif /* HAVE_AGC */ 1717#endif /* HAVE_AGC */
1784 1718
1785#if CONFIG_CODEC == SWCODEC
1786#ifdef HAVE_SPDIF_REC 1719#ifdef HAVE_SPDIF_REC
1787 if((global_settings.rec_source == AUDIO_SRC_SPDIF) && 1720 if((global_settings.rec_source == AUDIO_SRC_SPDIF) &&
1788 (prev_sample_rate != pcm_rec_sample_rate())) 1721 (prev_sample_rate != pcm_rec_sample_rate()))
@@ -1792,7 +1725,6 @@ bool recording_screen(bool no_source)
1792 update_list = true; 1725 update_list = true;
1793 } 1726 }
1794#endif 1727#endif
1795#endif
1796 1728
1797 if(update_list) 1729 if(update_list)
1798 { 1730 {
@@ -1824,11 +1756,9 @@ bool recording_screen(bool no_source)
1824 FOR_NB_SCREENS(i) 1756 FOR_NB_SCREENS(i)
1825 screens[i].update(); 1757 screens[i].update();
1826 1758
1827#if CONFIG_CODEC == SWCODEC
1828 /* stop recording first and try to finish saving whatever it can */ 1759 /* stop recording first and try to finish saving whatever it can */
1829 rec_command(RECORDING_CMD_STOP); 1760 rec_command(RECORDING_CMD_STOP);
1830 audio_close_recording(); 1761 audio_close_recording();
1831#endif
1832 1762
1833 audio_error_clear(); 1763 audio_error_clear();
1834 1764
@@ -1841,7 +1771,6 @@ bool recording_screen(bool no_source)
1841 1771
1842rec_abort: 1772rec_abort:
1843 1773
1844#if CONFIG_CODEC == SWCODEC
1845 rec_command(RECORDING_CMD_STOP); 1774 rec_command(RECORDING_CMD_STOP);
1846 audio_close_recording(); 1775 audio_close_recording();
1847 1776
@@ -1861,9 +1790,6 @@ rec_abort:
1861 1790
1862 /* restore keyclick */ 1791 /* restore keyclick */
1863 global_settings.keyclick = keyclick; 1792 global_settings.keyclick = keyclick;
1864#else /* !SWCODEC */
1865 audio_init_playback();
1866#endif /* CONFIG_CODEC == SWCODEC */
1867 1793
1868#ifdef HAVE_SPEAKER 1794#ifdef HAVE_SPEAKER
1869 /* Re-enable speaker */ 1795 /* Re-enable speaker */
@@ -1895,12 +1821,10 @@ rec_abort:
1895 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0; 1821 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
1896} /* recording_screen */ 1822} /* recording_screen */
1897 1823
1898#if CONFIG_CODEC == SWCODEC
1899void audio_beep(int duration) 1824void audio_beep(int duration)
1900{ 1825{
1901 /* dummy */ 1826 /* dummy */
1902 (void)duration; 1827 (void)duration;
1903} 1828}
1904#endif /* #ifdef CONFIG_CODEC == SWCODEC */
1905 1829
1906#endif /* HAVE_RECORDING */ 1830#endif /* HAVE_RECORDING */