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.c114
1 files changed, 85 insertions, 29 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index b70e7b64ed..ebd92178c5 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -28,6 +28,13 @@
28#include "led.h" 28#include "led.h"
29#include "mpeg.h" 29#include "mpeg.h"
30#include "audio.h" 30#include "audio.h"
31#if CONFIG_CODEC == SWCODEC
32#include "pcm_record.h"
33#endif
34#ifdef HAVE_UDA1380
35#include "uda1380.h"
36#endif
37
31#include "mp3_playback.h" 38#include "mp3_playback.h"
32#include "mas.h" 39#include "mas.h"
33#include "button.h" 40#include "button.h"
@@ -79,9 +86,12 @@
79 86
80#elif CONFIG_KEYPAD == IRIVER_H100_PAD 87#elif CONFIG_KEYPAD == IRIVER_H100_PAD
81#define REC_STOPEXIT BUTTON_OFF 88#define REC_STOPEXIT BUTTON_OFF
82#define REC_RECPAUSE BUTTON_ON 89#define REC_RECPAUSE BUTTON_REC
83#define REC_INC BUTTON_RIGHT 90#define REC_INC BUTTON_RIGHT
84#define REC_DEC BUTTON_LEFT 91#define REC_DEC BUTTON_LEFT
92#define REC_NEXT BUTTON_DOWN
93#define REC_PREV BUTTON_UP
94#define REC_SETTINGS BUTTON_MODE
85 95
86#elif CONFIG_KEYPAD == GMINI100_PAD 96#elif CONFIG_KEYPAD == GMINI100_PAD
87#define REC_STOPEXIT BUTTON_OFF 97#define REC_STOPEXIT BUTTON_OFF
@@ -102,6 +112,12 @@ bool f3_rec_screen(void);
102#define MAX_SOURCE SOURCE_LINE 112#define MAX_SOURCE SOURCE_LINE
103#endif 113#endif
104 114
115#if CONFIG_CODEC == SWCODEC
116#define REC_FILE_ENDING ".wav"
117#else
118#define REC_FILE_ENDING ".mp3"
119#endif
120
105#define MAX_FILE_SIZE 0x7FF00000 /* 2 GB - 1 MB */ 121#define MAX_FILE_SIZE 0x7FF00000 /* 2 GB - 1 MB */
106 122
107const char* const freq_str[6] = 123const char* const freq_str[6] =
@@ -118,13 +134,18 @@ static void set_gain(void)
118{ 134{
119 if(global_settings.rec_source == SOURCE_MIC) 135 if(global_settings.rec_source == SOURCE_MIC)
120 { 136 {
121 mpeg_set_recording_gain(global_settings.rec_mic_gain, 0, true); 137 audio_set_recording_gain(global_settings.rec_mic_gain, 0, AUDIO_GAIN_MIC);
122 } 138 }
123 else 139 else
124 { 140 {
125 mpeg_set_recording_gain(global_settings.rec_left_gain, 141 audio_set_recording_gain(global_settings.rec_left_gain,
126 global_settings.rec_right_gain, false); 142 global_settings.rec_right_gain, AUDIO_GAIN_LINEIN);
127 } 143 }
144#ifdef HAVE_UDA1380
145 audio_set_recording_gain(global_settings.rec_adc_left_gain,
146 global_settings.rec_adc_right_gain,
147 AUDIO_GAIN_ADC);
148#endif
128} 149}
129 150
130static const char* const fmtstr[] = 151static const char* const fmtstr[] =
@@ -176,9 +197,9 @@ char *rec_create_filename(char *buffer)
176 strncpy(buffer, rec_base_directory, MAX_PATH); 197 strncpy(buffer, rec_base_directory, MAX_PATH);
177 198
178#ifdef HAVE_RTC 199#ifdef HAVE_RTC
179 create_datetime_filename(buffer, buffer, "R", ".mp3"); 200 create_datetime_filename(buffer, buffer, "R", REC_FILE_ENDING);
180#else 201#else
181 create_numbered_filename(buffer, buffer, "rec_", ".mp3", 4); 202 create_numbered_filename(buffer, buffer, "rec_", REC_FILE_ENDING, 4);
182#endif 203#endif
183 return buffer; 204 return buffer;
184} 205}
@@ -227,7 +248,7 @@ static void trigger_listener(int trigger_status)
227 if((audio_status() & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD) 248 if((audio_status() & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD)
228 { 249 {
229 talk_buffer_steal(); /* we use the mp3 buffer */ 250 talk_buffer_steal(); /* we use the mp3 buffer */
230 mpeg_record(rec_create_filename(path_buffer)); 251 audio_record(rec_create_filename(path_buffer));
231 252
232 /* give control to mpeg thread so that it can start recording */ 253 /* give control to mpeg thread so that it can start recording */
233 yield(); yield(); yield(); 254 yield(); yield(); yield();
@@ -236,7 +257,7 @@ static void trigger_listener(int trigger_status)
236 /* if we're already recording this is a retrigger */ 257 /* if we're already recording this is a retrigger */
237 else 258 else
238 { 259 {
239 mpeg_new_file(rec_create_filename(path_buffer)); 260 audio_new_file(rec_create_filename(path_buffer));
240 /* tell recording_screen to reset the time */ 261 /* tell recording_screen to reset the time */
241 last_seconds = 0; 262 last_seconds = 0;
242 } 263 }
@@ -273,6 +294,7 @@ bool recording_screen(void)
273 char path_buffer[MAX_PATH]; 294 char path_buffer[MAX_PATH];
274 bool been_in_usb_mode = false; 295 bool been_in_usb_mode = false;
275 int last_audio_stat = -1; 296 int last_audio_stat = -1;
297 int audio_stat;
276#if CONFIG_LED == LED_REAL 298#if CONFIG_LED == LED_REAL
277 bool led_state = false; 299 bool led_state = false;
278 int led_countdown = 2; 300 int led_countdown = 2;
@@ -289,7 +311,7 @@ bool recording_screen(void)
289#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 311#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
290 ata_set_led_enabled(false); 312 ata_set_led_enabled(false);
291#endif 313#endif
292 mpeg_init_recording(); 314 audio_init_recording();
293 315
294 sound_set_volume(global_settings.volume); 316 sound_set_volume(global_settings.volume);
295 317
@@ -298,15 +320,20 @@ bool recording_screen(void)
298 320
299 peak_meter_enabled = true; 321 peak_meter_enabled = true;
300 322
323#if CONFIG_CODEC == SWCODEC
324 audio_stop();
325#endif
326
301 if (global_settings.rec_prerecord_time) 327 if (global_settings.rec_prerecord_time)
302 talk_buffer_steal(); /* will use the mp3 buffer */ 328 talk_buffer_steal(); /* will use the mp3 buffer */
303 329
304 mpeg_set_recording_options(global_settings.rec_frequency, 330 audio_set_recording_options(global_settings.rec_frequency,
305 global_settings.rec_quality, 331 global_settings.rec_quality,
306 global_settings.rec_source, 332 global_settings.rec_source,
307 global_settings.rec_channels, 333 global_settings.rec_channels,
308 global_settings.rec_editable, 334 global_settings.rec_editable,
309 global_settings.rec_prerecord_time); 335 global_settings.rec_prerecord_time,
336 global_settings.rec_monitor);
310 337
311 set_gain(); 338 set_gain();
312 339
@@ -321,7 +348,12 @@ bool recording_screen(void)
321 348
322 while(!done) 349 while(!done)
323 { 350 {
324 int audio_stat = audio_status(); 351#if CONFIG_CODEC == SWCODEC
352 audio_stat = pcm_rec_status();
353#else
354 audio_stat = audio_status();
355#endif
356
325#if CONFIG_LED == LED_REAL 357#if CONFIG_LED == LED_REAL
326 358
327 /* 359 /*
@@ -390,7 +422,7 @@ bool recording_screen(void)
390 422
391 if(audio_stat & AUDIO_STATUS_RECORD) 423 if(audio_stat & AUDIO_STATUS_RECORD)
392 { 424 {
393 audio_stop(); 425 audio_stop_recording();
394 } 426 }
395 else 427 else
396 { 428 {
@@ -416,7 +448,7 @@ bool recording_screen(void)
416 /* manual recording */ 448 /* manual recording */
417 have_recorded = true; 449 have_recorded = true;
418 talk_buffer_steal(); /* we use the mp3 buffer */ 450 talk_buffer_steal(); /* we use the mp3 buffer */
419 mpeg_record(rec_create_filename(path_buffer)); 451 audio_record(rec_create_filename(path_buffer));
420 last_seconds = 0; 452 last_seconds = 0;
421 if (global_settings.talk_menu) 453 if (global_settings.talk_menu)
422 { /* no voice possible here, but a beep */ 454 { /* no voice possible here, but a beep */
@@ -438,7 +470,7 @@ bool recording_screen(void)
438 { 470 {
439 if(audio_stat & AUDIO_STATUS_PAUSE) 471 if(audio_stat & AUDIO_STATUS_PAUSE)
440 { 472 {
441 mpeg_resume_recording(); 473 audio_resume_recording();
442 if (global_settings.talk_menu) 474 if (global_settings.talk_menu)
443 { /* no voice possible here, but a beep */ 475 { /* no voice possible here, but a beep */
444 audio_beep(HZ/4); /* short beep on resume */ 476 audio_beep(HZ/4); /* short beep on resume */
@@ -446,7 +478,7 @@ bool recording_screen(void)
446 } 478 }
447 else 479 else
448 { 480 {
449 mpeg_pause_recording(); 481 audio_pause_recording();
450 } 482 }
451 } 483 }
452 update_countdown = 1; /* Update immediately */ 484 update_countdown = 1; /* Update immediately */
@@ -535,7 +567,7 @@ bool recording_screen(void)
535 sound_min(SOUND_RIGHT_GAIN)) 567 sound_min(SOUND_RIGHT_GAIN))
536 global_settings.rec_right_gain--; 568 global_settings.rec_right_gain--;
537 break; 569 break;
538 } 570 }
539 set_gain(); 571 set_gain();
540 update_countdown = 1; /* Update immediately */ 572 update_countdown = 1; /* Update immediately */
541 break; 573 break;
@@ -557,12 +589,13 @@ bool recording_screen(void)
557 if (global_settings.rec_prerecord_time) 589 if (global_settings.rec_prerecord_time)
558 talk_buffer_steal(); /* will use the mp3 buffer */ 590 talk_buffer_steal(); /* will use the mp3 buffer */
559 591
560 mpeg_set_recording_options(global_settings.rec_frequency, 592 audio_set_recording_options(global_settings.rec_frequency,
561 global_settings.rec_quality, 593 global_settings.rec_quality,
562 global_settings.rec_source, 594 global_settings.rec_source,
563 global_settings.rec_channels, 595 global_settings.rec_channels,
564 global_settings.rec_editable, 596 global_settings.rec_editable,
565 global_settings.rec_prerecord_time); 597 global_settings.rec_prerecord_time,
598 global_settings.rec_monitor);
566 599
567 set_gain(); 600 set_gain();
568 update_countdown = 1; /* Update immediately */ 601 update_countdown = 1; /* Update immediately */
@@ -596,7 +629,7 @@ bool recording_screen(void)
596 case REC_F3: 629 case REC_F3:
597 if(audio_stat & AUDIO_STATUS_RECORD) 630 if(audio_stat & AUDIO_STATUS_RECORD)
598 { 631 {
599 mpeg_new_file(rec_create_filename(path_buffer)); 632 audio_new_file(rec_create_filename(path_buffer));
600 last_seconds = 0; 633 last_seconds = 0;
601 } 634 }
602 else 635 else
@@ -638,8 +671,8 @@ bool recording_screen(void)
638 671
639 lcd_setfont(FONT_SYSFIXED); 672 lcd_setfont(FONT_SYSFIXED);
640 673
641 seconds = mpeg_recorded_time() / HZ; 674 seconds = audio_recorded_time() / HZ;
642 675
643 update_countdown--; 676 update_countdown--;
644 if(update_countdown == 0 || seconds > last_seconds) 677 if(update_countdown == 0 || seconds > last_seconds)
645 { 678 {
@@ -660,7 +693,7 @@ bool recording_screen(void)
660 lcd_puts(0, 0, buf); 693 lcd_puts(0, 0, buf);
661 694
662 dseconds = rec_timesplit_seconds(); 695 dseconds = rec_timesplit_seconds();
663 num_recorded_bytes = mpeg_num_recorded_bytes(); 696 num_recorded_bytes = audio_num_recorded_bytes();
664 697
665 if(audio_stat & AUDIO_STATUS_PRERECORD) 698 if(audio_stat & AUDIO_STATUS_PRERECORD)
666 { 699 {
@@ -699,7 +732,7 @@ bool recording_screen(void)
699 ((global_settings.rec_timesplit && (seconds >= dseconds)) 732 ((global_settings.rec_timesplit && (seconds >= dseconds))
700 || (num_recorded_bytes >= MAX_FILE_SIZE))) 733 || (num_recorded_bytes >= MAX_FILE_SIZE)))
701 { 734 {
702 mpeg_new_file(rec_create_filename(path_buffer)); 735 audio_new_file(rec_create_filename(path_buffer));
703 update_countdown = 1; 736 update_countdown = 1;
704 last_seconds = 0; 737 last_seconds = 0;
705 } 738 }
@@ -784,7 +817,13 @@ bool recording_screen(void)
784 } 817 }
785 } 818 }
786 819
787 if(audio_status() & AUDIO_STATUS_ERROR) 820
821#if CONFIG_CODEC == SWCODEC
822 audio_stat = pcm_rec_status();
823#else
824 audio_stat = audio_status();
825#endif
826 if (audio_stat & AUDIO_STATUS_ERROR)
788 { 827 {
789 splash(0, true, str(LANG_DISK_FULL)); 828 splash(0, true, str(LANG_DISK_FULL));
790 status_draw(true); 829 status_draw(true);
@@ -799,7 +838,12 @@ bool recording_screen(void)
799 } 838 }
800 } 839 }
801 840
841#if CONFIG_CODEC == SWCODEC
842 audio_stop_recording();
843 audio_close_recording();
844#else
802 audio_init_playback(); 845 audio_init_playback();
846#endif
803 847
804 /* make sure the trigger is really turned off */ 848 /* make sure the trigger is really turned off */
805 peak_meter_trigger(false); 849 peak_meter_trigger(false);
@@ -924,12 +968,13 @@ bool f2_rec_screen(void)
924 if (global_settings.rec_prerecord_time) 968 if (global_settings.rec_prerecord_time)
925 talk_buffer_steal(); /* will use the mp3 buffer */ 969 talk_buffer_steal(); /* will use the mp3 buffer */
926 970
927 mpeg_set_recording_options(global_settings.rec_frequency, 971 audio_set_recording_options(global_settings.rec_frequency,
928 global_settings.rec_quality, 972 global_settings.rec_quality,
929 global_settings.rec_source, 973 global_settings.rec_source,
930 global_settings.rec_channels, 974 global_settings.rec_channels,
931 global_settings.rec_editable, 975 global_settings.rec_editable,
932 global_settings.rec_prerecord_time); 976 global_settings.rec_prerecord_time,
977 global_settings.rec_monitor);
933 978
934 set_gain(); 979 set_gain();
935 980
@@ -1018,12 +1063,14 @@ bool f3_rec_screen(void)
1018 if (global_settings.rec_prerecord_time) 1063 if (global_settings.rec_prerecord_time)
1019 talk_buffer_steal(); /* will use the mp3 buffer */ 1064 talk_buffer_steal(); /* will use the mp3 buffer */
1020 1065
1021 mpeg_set_recording_options(global_settings.rec_frequency, 1066 audio_set_recording_options(global_settings.rec_frequency,
1022 global_settings.rec_quality, 1067 global_settings.rec_quality,
1023 global_settings.rec_source, 1068 global_settings.rec_source,
1024 global_settings.rec_channels, 1069 global_settings.rec_channels,
1025 global_settings.rec_editable, 1070 global_settings.rec_editable,
1026 global_settings.rec_prerecord_time); 1071 global_settings.rec_prerecord_time,
1072 global_settings.rec_monitor);
1073
1027 1074
1028 set_gain(); 1075 set_gain();
1029 1076
@@ -1034,4 +1081,13 @@ bool f3_rec_screen(void)
1034} 1081}
1035#endif /* #ifdef REC_F3 */ 1082#endif /* #ifdef REC_F3 */
1036 1083
1084#if CONFIG_CODEC == SWCODEC
1085void audio_beep(int duration)
1086{
1087 /* dummy */
1088 (void)duration;
1089}
1090#endif
1091
1092
1037#endif /* HAVE_RECORDING */ 1093#endif /* HAVE_RECORDING */