Redo my previous segfault fix in a better way.
[Rockbox.git] / apps / recorder / recording.c
blob2f41d8f1f2b4d5216b8c8c66f7e93cddcdb3cd8d
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
22 #include <stdio.h>
23 #include <stdbool.h>
24 #include <stdlib.h>
26 #include "system.h"
27 #include "power.h"
28 #include "lcd.h"
29 #include "led.h"
30 #include "mpeg.h"
31 #include "audio.h"
32 #if CONFIG_CODEC == SWCODEC
33 #include "thread.h"
34 #include "playback.h"
35 #include "enc_config.h"
36 #if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT)
37 #include "spdif.h"
38 #endif
39 #endif /* CONFIG_CODEC == SWCODEC */
40 #include "recording.h"
41 #include "mp3_playback.h"
42 #include "mas.h"
43 #include "button.h"
44 #include "kernel.h"
45 #include "settings.h"
46 #include "lang.h"
47 #include "font.h"
48 #include "icons.h"
49 #include "icon.h"
50 #include "screens.h"
51 #include "peakmeter.h"
52 #include "statusbar.h"
53 #include "menu.h"
54 #include "sound_menu.h"
55 #include "timefuncs.h"
56 #include "debug.h"
57 #include "misc.h"
58 #include "tree.h"
59 #include "string.h"
60 #include "dir.h"
61 #include "errno.h"
62 #include "talk.h"
63 #include "atoi.h"
64 #include "sound.h"
65 #include "ata.h"
66 #include "splash.h"
67 #include "screen_access.h"
68 #include "action.h"
69 #include "radio.h"
70 #ifdef HAVE_RECORDING
71 /* This array holds the record timer interval lengths, in seconds */
72 static const unsigned long rec_timer_seconds[] =
74 0, /* 0 means OFF */
75 5*60, /* 00:05 */
76 10*60, /* 00:10 */
77 15*60, /* 00:15 */
78 30*60, /* 00:30 */
79 60*60, /* 01:00 */
80 74*60, /* 74:00 */
81 80*60, /* 80:00 */
82 2*60*60, /* 02:00 */
83 4*60*60, /* 04:00 */
84 6*60*60, /* 06:00 */
85 8*60*60, /* 08:00 */
86 10L*60*60, /* 10:00 */
87 12L*60*60, /* 12:00 */
88 18L*60*60, /* 18:00 */
89 24L*60*60 /* 24:00 */
92 static unsigned int rec_timesplit_seconds(void)
94 return rec_timer_seconds[global_settings.rec_timesplit];
97 /* This array holds the record size interval lengths, in bytes */
98 static const unsigned long rec_size_bytes[] =
100 0, /* 0 means OFF */
101 5*1024*1024, /* 5MB */
102 10*1024*1024, /* 10MB */
103 15*1024*1024, /* 15MB */
104 32*1024*1024, /* 32MB */
105 64*1024*1024, /* 64MB */
106 75*1024*1024, /* 75MB */
107 100*1024*1024, /* 100MB */
108 128*1024*1024, /* 128MB */
109 256*1024*1024, /* 256MB */
110 512*1024*1024, /* 512MB */
111 650*1024*1024, /* 650MB */
112 700*1024*1024, /* 700MB */
113 1024*1024*1024, /* 1GB */
114 1536*1024*1024, /* 1.5GB */
115 1792*1024*1024, /* 1.75GB */
118 static unsigned long rec_sizesplit_bytes(void)
120 return rec_size_bytes[global_settings.rec_sizesplit];
123 * Time strings used for the trigger durations.
124 * Keep synchronous to trigger_times in settings_apply_trigger
126 const struct opt_items trig_durations[TRIG_DURATION_COUNT] =
128 #define TS(x) { (unsigned char *)(#x "s"), TALK_ID(x, UNIT_SEC) }
129 #define TM(x) { (unsigned char *)(#x "min"), TALK_ID(x, UNIT_MIN) }
130 TS(0), TS(1), TS(2), TS(5),
131 TS(10), TS(15), TS(20), TS(25), TS(30),
132 TM(1), TM(2), TM(5), TM(10)
133 #undef TS
134 #undef TM
137 void settings_apply_trigger(void)
139 /* Keep synchronous to trig_durations and trig_durations_conf*/
140 static const long trigger_times[TRIG_DURATION_COUNT] = {
141 0, HZ, 2*HZ, 5*HZ,
142 10*HZ, 15*HZ, 20*HZ, 25*HZ, 30*HZ,
143 60*HZ, 2*60*HZ, 5*60*HZ, 10*60*HZ
146 peak_meter_define_trigger(
147 global_settings.rec_start_thres,
148 trigger_times[global_settings.rec_start_duration],
149 MIN(trigger_times[global_settings.rec_start_duration] / 2, 2*HZ),
150 global_settings.rec_stop_thres,
151 trigger_times[global_settings.rec_stop_postrec],
152 trigger_times[global_settings.rec_stop_gap]
155 /* recording screen status flags */
156 enum rec_status_flags
158 RCSTAT_IN_RECSCREEN = 0x00000001,
159 RCSTAT_BEEN_IN_USB_MODE = 0x00000002,
160 RCSTAT_CREATED_DIRECTORY = 0x00000004,
161 RCSTAT_HAVE_RECORDED = 0x00000008,
164 static int rec_status = 0;
166 bool in_recording_screen(void)
168 return (rec_status & RCSTAT_IN_RECSCREEN) != 0;
171 #define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
173 #if CONFIG_KEYPAD == RECORDER_PAD
174 static bool f2_rec_screen(void);
175 static bool f3_rec_screen(void);
176 #endif
178 #define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */
180 #ifndef HAVE_REMOTE_LCD
181 static const int screen_update = NB_SCREENS;
182 #else
183 static int screen_update = NB_SCREENS;
184 static bool remote_display_on = true;
185 #endif
187 /** File name creation **/
188 #if CONFIG_RTC == 0
189 /* current file number to assist in creating unique numbered filenames
190 without actually having to create the file on disk */
191 static int file_number = -1;
192 #endif /* CONFIG_RTC */
194 #if CONFIG_CODEC == SWCODEC
196 #define REC_FILE_ENDING(rec_format) \
197 (audio_formats[rec_format_afmt[rec_format]].ext_list)
199 #else /* CONFIG_CODEC != SWCODEC */
201 /* default record file extension for HWCODEC */
202 #define REC_FILE_ENDING(rec_format) \
203 (audio_formats[AFMT_MPA_L3].ext_list)
205 #endif /* CONFIG_CODEC == SWCODEC */
207 /* path for current file */
208 static char path_buffer[MAX_PATH];
210 /** Automatic Gain Control (AGC) **/
211 #ifdef HAVE_AGC
212 /* Timing counters:
213 * peak_time is incremented every 0.2s, every 2nd run of record screen loop.
214 * hist_time is incremented every 0.5s, display update.
215 * peak_time is the counter of the peak hold read and agc process,
216 * overflow every 13 years 8-)
218 static long peak_time = 0;
219 static long hist_time = 0;
221 static short peak_valid_mem[4];
222 #define BAL_MEM_SIZE 24
223 static short balance_mem[BAL_MEM_SIZE];
225 /* Automatic Gain Control */
226 #define AGC_MODE_SIZE 5
227 #define AGC_SAFETY_MODE 0
229 static const char* agc_preset_str[] =
230 { "Off", "S", "L", "D", "M", "V" };
231 /* "Off",
232 "Safety (clip)",
233 "Live (slow)",
234 "DJ-Set (slow)",
235 "Medium",
236 "Voice (fast)" */
237 #define AGC_CLIP 32766
238 #define AGC_PEAK 29883 /* fast gain reduction threshold -0.8dB */
239 #define AGC_HIGH 27254 /* accelerated gain reduction threshold -1.6dB */
240 #define AGC_IMG 823 /* threshold for balance control -32dB */
241 /* autogain high level thresholds (-3dB, -7dB, -4dB, -5dB, -5dB) */
242 static const short agc_th_hi[AGC_MODE_SIZE] =
243 { 23197, 14637, 21156, 18428, 18426 };
244 /* autogain low level thresholds (-14dB, -11dB, -6dB, -7dB, -8dB) */
245 static const short agc_th_lo[AGC_MODE_SIZE] =
246 { 6538, 9235, 16422, 14636, 13045 };
247 /* autogain threshold times [1/5s] or [200ms] */
248 static const short agc_tdrop[AGC_MODE_SIZE] =
249 { 900, 225, 150, 60, 8 };
250 static const short agc_trise[AGC_MODE_SIZE] =
251 { 9000, 750, 400, 150, 20 };
252 static const short agc_tbal[AGC_MODE_SIZE] =
253 { 4500, 500, 300, 100, 15 };
254 /* AGC operation */
255 static bool agc_enable = true;
256 static short agc_preset;
257 /* AGC levels */
258 static int agc_left = 0;
259 static int agc_right = 0;
260 /* AGC time since high target volume was exceeded */
261 static short agc_droptime = 0;
262 /* AGC time since volume fallen below low target */
263 static short agc_risetime = 0;
264 /* AGC balance time exceeding +/- 0.7dB */
265 static short agc_baltime = 0;
266 /* AGC maximum gain */
267 static short agc_maxgain;
268 #endif /* HAVE_AGC */
270 static void set_gain(void)
272 if(global_settings.rec_source == AUDIO_SRC_MIC)
274 audio_set_recording_gain(global_settings.rec_mic_gain,
275 0, AUDIO_GAIN_MIC);
277 else
279 /* AUDIO_SRC_LINEIN, AUDIO_SRC_FMRADIO, AUDIO_SRC_SPDIF */
280 audio_set_recording_gain(global_settings.rec_left_gain,
281 global_settings.rec_right_gain,
282 AUDIO_GAIN_LINEIN);
286 #ifdef HAVE_AGC
287 /* Read peak meter values & calculate balance.
288 * Returns validity of peak values.
289 * Used for automatic gain control and history diagram.
291 static bool read_peak_levels(int *peak_l, int *peak_r, int *balance)
293 peak_meter_get_peakhold(peak_l, peak_r);
294 peak_valid_mem[peak_time % 3] = *peak_l;
295 if (((peak_valid_mem[0] == peak_valid_mem[1]) &&
296 (peak_valid_mem[1] == peak_valid_mem[2])) &&
297 ((*peak_l < 32767)
298 #ifndef SIMULATOR
299 || ata_disk_is_active()
300 #endif
302 return false;
304 if (*peak_r > *peak_l)
305 balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_l ?
306 MIN((10000 * *peak_r) / *peak_l - 10000, 15118) : 15118);
307 else
308 balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_r ?
309 MAX(10000 - (10000 * *peak_l) / *peak_r, -15118) : -15118);
310 *balance = 0;
311 int i;
312 for (i = 0; i < BAL_MEM_SIZE; i++)
313 *balance += balance_mem[i];
314 *balance = *balance / BAL_MEM_SIZE;
316 return true;
319 /* AGC helper function to check if maximum gain is reached */
320 static bool agc_gain_is_max(bool left, bool right)
322 /* range -128...+108 [0.5dB] */
323 short gain_current_l;
324 short gain_current_r;
326 if (agc_preset == 0)
327 return false;
329 switch (global_settings.rec_source)
331 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
332 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
333 gain_current_l = global_settings.rec_left_gain;
334 gain_current_r = global_settings.rec_right_gain;
335 break;
336 case AUDIO_SRC_MIC:
337 default:
338 gain_current_l = global_settings.rec_mic_gain;
339 gain_current_r = global_settings.rec_mic_gain;
342 return ((left && (gain_current_l >= agc_maxgain)) ||
343 (right && (gain_current_r >= agc_maxgain)));
346 static void change_recording_gain(bool increment, bool left, bool right)
348 int factor = (increment ? 1 : -1);
350 switch (global_settings.rec_source)
352 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
353 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
354 if (left) global_settings.rec_left_gain += factor;
355 if (right) global_settings.rec_right_gain += factor;
356 break;
357 case AUDIO_SRC_MIC:
358 global_settings.rec_mic_gain += factor;
363 * Handle automatic gain control (AGC).
364 * Change recording gain if peak_x levels are above or below
365 * target volume for specified timeouts.
367 static void auto_gain_control(int *peak_l, int *peak_r, int *balance)
369 int agc_mono;
370 short agc_mode;
371 bool increment;
373 if (*peak_l > agc_left)
374 agc_left = *peak_l;
375 else
376 agc_left -= (agc_left - *peak_l + 3) >> 2;
377 if (*peak_r > agc_right)
378 agc_right = *peak_r;
379 else
380 agc_right -= (agc_right - *peak_r + 3) >> 2;
381 agc_mono = (agc_left + agc_right) / 2;
383 agc_mode = abs(agc_preset) - 1;
384 if (agc_mode < 0) {
385 agc_enable = false;
386 return;
389 if (agc_mode != AGC_SAFETY_MODE) {
390 /* Automatic balance control - only if not in safety mode */
391 if ((agc_left > AGC_IMG) && (agc_right > AGC_IMG))
393 if (*balance < -556)
395 if (*balance > -900)
396 agc_baltime -= !(peak_time % 4); /* 0.47 - 0.75dB */
397 else if (*balance > -4125)
398 agc_baltime--; /* 0.75 - 3.00dB */
399 else if (*balance > -7579)
400 agc_baltime -= 2; /* 3.00 - 4.90dB */
401 else
402 agc_baltime -= !(peak_time % 8); /* 4.90 - inf dB */
403 if (agc_baltime > 0)
404 agc_baltime -= (peak_time % 2);
406 else if (*balance > 556)
408 if (*balance < 900)
409 agc_baltime += !(peak_time % 4);
410 else if (*balance < 4125)
411 agc_baltime++;
412 else if (*balance < 7579)
413 agc_baltime += 2;
414 else
415 agc_baltime += !(peak_time % 8);
416 if (agc_baltime < 0)
417 agc_baltime += (peak_time % 2);
420 if ((*balance * agc_baltime) < 0)
422 if (*balance < 0)
423 agc_baltime -= peak_time % 2;
424 else
425 agc_baltime += peak_time % 2;
428 increment = ((agc_risetime / 2) > agc_droptime);
430 if (agc_baltime < -agc_tbal[agc_mode])
432 if (!increment || !agc_gain_is_max(!increment, increment)) {
433 change_recording_gain(increment, !increment, increment);
434 set_gain();
436 agc_baltime = 0;
438 else if (agc_baltime > +agc_tbal[agc_mode])
440 if (!increment || !agc_gain_is_max(increment, !increment)) {
441 change_recording_gain(increment, increment, !increment);
442 set_gain();
444 agc_baltime = 0;
447 else if (!(hist_time % 4))
449 if (agc_baltime < 0)
450 agc_baltime++;
451 else
452 agc_baltime--;
456 /* Automatic gain control */
457 if ((agc_left > agc_th_hi[agc_mode]) || (agc_right > agc_th_hi[agc_mode]))
459 if ((agc_left > AGC_CLIP) || (agc_right > AGC_CLIP))
460 agc_droptime += agc_tdrop[agc_mode] /
461 (global_settings.rec_agc_cliptime + 1);
462 if (agc_left > AGC_HIGH) {
463 agc_droptime++;
464 agc_risetime=0;
465 if (agc_left > AGC_PEAK)
466 agc_droptime += 2;
468 if (agc_right > AGC_HIGH) {
469 agc_droptime++;
470 agc_risetime=0;
471 if (agc_right > AGC_PEAK)
472 agc_droptime += 2;
474 if (agc_mono > agc_th_hi[agc_mode])
475 agc_droptime++;
476 else
477 agc_droptime += !(peak_time % 2);
479 if (agc_droptime >= agc_tdrop[agc_mode])
481 change_recording_gain(false, true, true);
482 agc_droptime = 0;
483 agc_risetime = 0;
484 set_gain();
486 agc_risetime = MAX(agc_risetime - 1, 0);
488 else if (agc_mono < agc_th_lo[agc_mode])
490 if (agc_mono < (agc_th_lo[agc_mode] / 8))
491 agc_risetime += !(peak_time % 5);
492 else if (agc_mono < (agc_th_lo[agc_mode] / 2))
493 agc_risetime += 2;
494 else
495 agc_risetime++;
497 if (agc_risetime >= agc_trise[agc_mode]) {
498 if ((agc_mode != AGC_SAFETY_MODE) &&
499 (!agc_gain_is_max(true, true))) {
500 change_recording_gain(true, true, true);
501 set_gain();
503 agc_risetime = 0;
504 agc_droptime = 0;
506 agc_droptime = MAX(agc_droptime - 1, 0);
508 else if (!(peak_time % 6)) /* on target level every 1.2 sec */
510 agc_risetime = MAX(agc_risetime - 1, 0);
511 agc_droptime = MAX(agc_droptime - 1, 0);
514 #endif /* HAVE_AGC */
516 static const char* const fmtstr[] =
518 "%c%d %s", /* no decimals */
519 "%c%d.%d %s ", /* 1 decimal */
520 "%c%d.%02d %s " /* 2 decimals */
523 static char *fmt_gain(int snd, int val, char *str, int len)
525 int i, d, numdec;
526 const char *unit;
527 char sign = ' ';
529 val = sound_val2phys(snd, val);
530 if(val < 0)
532 sign = '-';
533 val = -val;
535 numdec = sound_numdecimals(snd);
536 unit = sound_unit(snd);
538 if(numdec)
540 i = val / (10*numdec);
541 d = val % (10*numdec);
542 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
544 else
545 snprintf(str, len, fmtstr[numdec], sign, val, unit);
547 return str;
550 static int cursor;
552 static void adjust_cursor(void)
554 int max_cursor;
556 if(cursor < 0)
557 cursor = 0;
559 #ifdef HAVE_AGC
560 switch(global_settings.rec_source)
562 case REC_SRC_MIC:
563 if(cursor == 2)
564 cursor = 4;
565 else if(cursor == 3)
566 cursor = 1;
567 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
568 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
569 max_cursor = 5;
570 break;
571 default:
572 max_cursor = 0;
573 break;
575 #else /* !HAVE_AGC */
576 switch(global_settings.rec_source)
578 case AUDIO_SRC_MIC:
579 max_cursor = 1;
580 break;
581 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
582 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
583 max_cursor = 3;
584 break;
585 default:
586 max_cursor = 0;
587 break;
589 #endif /* HAVE_AGC */
591 if(cursor > max_cursor)
592 cursor = max_cursor;
595 /* the list below must match enum audio_sources in audio.h */
596 static const char* const prestr[] =
598 HAVE_MIC_IN_([AUDIO_SRC_MIC] = "R_MIC_",)
599 HAVE_LINE_REC_([AUDIO_SRC_LINEIN] = "R_LINE_",)
600 HAVE_SPDIF_IN_([AUDIO_SRC_SPDIF] = "R_SPDIF_",)
601 HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO] = "R_FM_",)
604 char *rec_create_filename(char *buffer)
606 char ext[16];
607 const char *pref = "R_";
609 /* Directory existence and writeablility should have already been
610 * verified - do not pass NULL pointers to pcmrec */
612 if((unsigned)global_settings.rec_source < AUDIO_NUM_SOURCES)
614 pref = prestr[global_settings.rec_source];
617 strcpy(buffer, global_settings.rec_directory);
619 snprintf(ext, sizeof(ext), ".%s",
620 REC_FILE_ENDING(global_settings.rec_format));
622 #if CONFIG_RTC == 0
623 return create_numbered_filename(buffer, buffer, pref, ext, 4,
624 &file_number);
625 #else
626 /* We'll wait at least up to the start of the next second so no duplicate
627 names are created */
628 return create_datetime_filename(buffer, buffer, pref, ext, true);
629 #endif
632 #if CONFIG_RTC == 0
633 /* Hit disk to get a starting filename for the type */
634 static void rec_init_filename(void)
636 file_number = -1;
637 rec_create_filename(path_buffer);
638 file_number--;
640 #endif
642 int rec_create_directory(void)
644 int rc = 0;
645 const char * const folder = global_settings.rec_directory;
647 if (strcmp(folder, "/") && !dir_exists(folder))
649 rc = mkdir(folder);
651 if(rc < 0)
653 while (action_userabort(HZ) == false)
655 gui_syncsplash(0, "%s %s",
656 str(LANG_REC_DIR_NOT_WRITABLE),
657 str(LANG_OFF_ABORT));
660 else
662 rec_status |= RCSTAT_CREATED_DIRECTORY;
663 rc = 1;
667 return rc;
670 void rec_init_recording_options(struct audio_recording_options *options)
672 options->rec_source = global_settings.rec_source;
673 options->rec_frequency = global_settings.rec_frequency;
674 options->rec_channels = global_settings.rec_channels;
675 options->rec_prerecord_time = global_settings.rec_prerecord_time;
676 #if CONFIG_CODEC == SWCODEC
677 options->rec_source_flags = 0;
678 options->enc_config.rec_format = global_settings.rec_format;
679 global_to_encoder_config(&options->enc_config);
680 #else
681 options->rec_quality = global_settings.rec_quality;
682 options->rec_editable = global_settings.rec_editable;
683 #endif
686 #if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
687 void rec_set_source(int source, unsigned flags)
689 /* Set audio input source, power up/down devices */
690 audio_set_input_source(source, flags);
692 /* Set peakmeters for recording or reset to playback */
693 peak_meter_playback((flags & SRCF_RECORDING) == 0);
694 peak_meter_enabled = true;
696 #endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
698 void rec_set_recording_options(struct audio_recording_options *options)
700 #if CONFIG_CODEC != SWCODEC
701 if (global_settings.rec_prerecord_time)
703 talk_buffer_steal(); /* will use the mp3 buffer */
705 #else /* == SWCODEC */
706 rec_set_source(options->rec_source,
707 options->rec_source_flags | SRCF_RECORDING);
708 #endif /* CONFIG_CODEC != SWCODEC */
710 audio_set_recording_options(options);
713 void rec_command(enum recording_command cmd)
715 switch(cmd)
717 case RECORDING_CMD_STOP:
718 pm_activate_clipcount(false);
719 audio_stop_recording();
720 break;
721 case RECORDING_CMD_START:
722 /* steal mp3 buffer, create unique filename and start recording */
723 pm_reset_clipcount();
724 pm_activate_clipcount(true);
725 #if CONFIG_CODEC != SWCODEC
726 talk_buffer_steal(); /* we use the mp3 buffer */
727 #endif
728 audio_record(rec_create_filename(path_buffer));
729 break;
730 case RECORDING_CMD_START_NEWFILE:
731 /* create unique filename and start recording*/
732 pm_reset_clipcount();
733 pm_activate_clipcount(true); /* just to be sure */
734 audio_new_file(rec_create_filename(path_buffer));
735 break;
736 case RECORDING_CMD_PAUSE:
737 pm_activate_clipcount(false);
738 audio_pause_recording();
739 break;
740 case RECORDING_CMD_RESUME:
741 pm_activate_clipcount(true);
742 audio_resume_recording();
743 break;
747 /* used in trigger_listerner and recording_screen */
748 static unsigned int last_seconds = 0;
751 * Callback function so that the peak meter code can send an event
752 * to this application. This function can be passed to
753 * peak_meter_set_trigger_listener in order to activate the trigger.
755 static void trigger_listener(int trigger_status)
757 switch (trigger_status)
759 case TRIG_GO:
760 if(!(audio_status() & AUDIO_STATUS_RECORD))
762 rec_status |= RCSTAT_HAVE_RECORDED;
763 rec_command(RECORDING_CMD_START);
764 #if CONFIG_CODEC != SWCODEC
765 /* give control to mpeg thread so that it can start
766 recording */
767 yield(); yield(); yield();
768 #endif
771 /* if we're already recording this is a retrigger */
772 else
774 if((audio_status() & AUDIO_STATUS_PAUSE) &&
775 (global_settings.rec_trigger_type == 1))
777 rec_command(RECORDING_CMD_RESUME);
779 /* New file on trig start*/
780 else if (global_settings.rec_trigger_type != 2)
782 rec_command(RECORDING_CMD_START_NEWFILE);
783 /* tell recording_screen to reset the time */
784 last_seconds = 0;
787 break;
789 /* A _change_ to TRIG_READY means the current recording has stopped */
790 case TRIG_READY:
791 if(audio_status() & AUDIO_STATUS_RECORD)
793 switch(global_settings.rec_trigger_type)
795 case 0: /* Stop */
796 rec_command(RECORDING_CMD_STOP);
797 break;
799 case 1: /* Pause */
800 rec_command(RECORDING_CMD_PAUSE);
801 break;
803 case 2: /* New file on trig stop*/
804 rec_command(RECORDING_CMD_START_NEWFILE);
805 /* tell recording_screen to reset the time */
806 last_seconds = 0;
807 break;
810 if (global_settings.rec_trigger_mode != TRIG_MODE_REARM)
812 peak_meter_set_trigger_listener(NULL);
813 peak_meter_trigger(false);
816 break;
820 bool recording_start_automatic = false;
822 bool recording_screen(bool no_source)
824 long button;
825 bool done = false;
826 char buf[32];
827 char buf2[32];
828 int w, h;
829 int update_countdown = 1;
830 unsigned int seconds;
831 int hours, minutes;
832 char filename[13];
833 int last_audio_stat = -1;
834 int audio_stat;
835 #if CONFIG_CODEC == SWCODEC
836 int warning_counter = 0;
837 #define WARNING_PERIOD 7
838 #endif
839 #ifdef HAVE_FMRADIO_REC
840 /* Radio is left on if:
841 * 1) Is was on at the start and the initial source is FM Radio
842 * 2) 1) and the source was never changed to something else
844 int radio_status = (global_settings.rec_source != AUDIO_SRC_FMRADIO) ?
845 FMRADIO_OFF : get_radio_status();
846 #endif
847 #if (CONFIG_LED == LED_REAL)
848 bool led_state = false;
849 int led_countdown = 2;
850 #endif
851 #ifdef HAVE_AGC
852 bool peak_read = false;
853 bool peak_valid = false;
854 int peak_l, peak_r;
855 int balance = 0;
856 bool display_agc[NB_SCREENS];
857 #endif
858 int line[NB_SCREENS];
859 int i;
860 int filename_offset[NB_SCREENS];
861 int pm_y[NB_SCREENS];
862 int trig_xpos[NB_SCREENS];
863 int trig_ypos[NB_SCREENS];
864 int trig_width[NB_SCREENS];
865 /* pm_x = offset pm to put clipcount in front.
866 Use lcd_getstringsize() when not using SYSFONT */
867 int pm_x = global_settings.peak_meter_clipcounter ? 30 : 0;
869 static const unsigned char *byte_units[] = {
870 ID2P(LANG_BYTE),
871 ID2P(LANG_KILOBYTE),
872 ID2P(LANG_MEGABYTE),
873 ID2P(LANG_GIGABYTE)
876 int base_style = STYLE_INVERT;
877 int style;
878 #ifdef HAVE_LCD_COLOR
879 if (global_settings.cursor_style == 2) {
880 base_style |= STYLE_COLORBAR;
882 else if (global_settings.cursor_style == 3) {
883 base_style |= STYLE_GRADIENT;
885 #endif
887 struct audio_recording_options rec_options;
888 rec_status = RCSTAT_IN_RECSCREEN;
890 if (rec_create_directory() < 0)
892 rec_status = 0;
893 return false;
896 cursor = 0;
897 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
898 ata_set_led_enabled(false);
899 #endif
901 #if CONFIG_CODEC == SWCODEC
902 /* recording_menu gets messed up: so prevent manus talking */
903 talk_disable(true);
904 /* audio_init_recording stops anything playing when it takes the audio
905 buffer */
906 #else
907 /* Yes, we use the D/A for monitoring */
908 peak_meter_enabled = true;
909 peak_meter_playback(true);
910 #endif
912 audio_init_recording(0);
913 sound_set_volume(global_settings.volume);
915 #ifdef HAVE_AGC
916 peak_meter_get_peakhold(&peak_l, &peak_r);
917 #endif
919 rec_init_recording_options(&rec_options);
920 rec_set_recording_options(&rec_options);
922 set_gain();
924 #if CONFIG_RTC == 0
925 /* Create new filename for recording start */
926 rec_init_filename();
927 #endif
929 pm_reset_clipcount();
930 pm_activate_clipcount(false);
931 settings_apply_trigger();
933 #ifdef HAVE_AGC
934 agc_preset_str[0] = str(LANG_SYSFONT_OFF);
935 agc_preset_str[1] = str(LANG_SYSFONT_AGC_SAFETY);
936 agc_preset_str[2] = str(LANG_SYSFONT_AGC_LIVE);
937 agc_preset_str[3] = str(LANG_SYSFONT_AGC_DJSET);
938 agc_preset_str[4] = str(LANG_SYSFONT_AGC_MEDIUM);
939 agc_preset_str[5] = str(LANG_SYSFONT_AGC_VOICE);
940 if (global_settings.rec_source == AUDIO_SRC_MIC) {
941 agc_preset = global_settings.rec_agc_preset_mic;
942 agc_maxgain = global_settings.rec_agc_maxgain_mic;
944 else {
945 agc_preset = global_settings.rec_agc_preset_line;
946 agc_maxgain = global_settings.rec_agc_maxgain_line;
948 #endif /* HAVE_AGC */
950 FOR_NB_SCREENS(i)
952 screens[i].setfont(FONT_SYSFIXED);
953 screens[i].getstringsize("M", &w, &h);
954 screens[i].setmargins(global_settings.cursor_style ? 0 : w, 8);
955 filename_offset[i] = ((screens[i].height >= 80) ? 1 : 0);
956 pm_y[i] = 8 + h * (2 + filename_offset[i]);
959 #ifdef HAVE_REMOTE_LCD
960 if (!remote_display_on)
962 screens[1].clear_display();
963 snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON));
964 screens[1].puts((screens[1].width/w - strlen(buf))/2 + 1,
965 screens[1].height/(h*2) + 1, buf);
966 screens[1].update();
967 gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF));
969 #endif
971 while(!done)
973 audio_stat = audio_status();
975 #if (CONFIG_LED == LED_REAL)
978 * Flash the LED while waiting to record. Turn it on while
979 * recording.
981 if(audio_stat & AUDIO_STATUS_RECORD)
983 if (audio_stat & AUDIO_STATUS_PAUSE)
985 if (--led_countdown <= 0)
987 led_state = !led_state;
988 led(led_state);
989 led_countdown = 2;
992 else
994 /* trigger is on in status TRIG_READY (no check needed) */
995 led(true);
998 else
1000 int trigStat = peak_meter_trigger_status();
1002 * other trigger stati than trig_off and trig_steady
1003 * already imply that we are recording.
1005 if (trigStat == TRIG_STEADY)
1007 if (--led_countdown <= 0)
1009 led_state = !led_state;
1010 led(led_state);
1011 led_countdown = 2;
1014 else
1016 /* trigger is on in status TRIG_READY (no check needed) */
1017 led(false);
1020 #endif /* CONFIG_LED */
1022 /* Wait for a button a while (HZ/10) drawing the peak meter */
1023 button = peak_meter_draw_get_btn(pm_x, pm_y, h * PM_HEIGHT,
1024 screen_update);
1026 if (last_audio_stat != audio_stat)
1028 if (audio_stat & AUDIO_STATUS_RECORD)
1030 rec_status |= RCSTAT_HAVE_RECORDED;
1032 last_audio_stat = audio_stat;
1036 if (recording_start_automatic)
1038 /* simulate a button press */
1039 button = ACTION_REC_PAUSE;
1040 recording_start_automatic = false;
1043 switch(button)
1045 #ifdef HAVE_REMOTE_LCD
1046 case ACTION_REC_LCD:
1047 if (remote_display_on)
1049 remote_display_on = false;
1050 screen_update = 1;
1051 screens[1].clear_display();
1052 snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON));
1053 screens[1].puts((screens[1].width/w - strlen(buf))/2 + 1,
1054 screens[1].height/(h*2) + 1, buf);
1055 screens[1].update();
1056 gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF));
1058 else
1060 remote_display_on = true;
1061 screen_update = NB_SCREENS;
1063 break;
1064 #endif
1065 case ACTION_STD_CANCEL:
1066 /* turn off the trigger */
1067 peak_meter_trigger(false);
1068 peak_meter_set_trigger_listener(NULL);
1070 if(audio_stat & AUDIO_STATUS_RECORD)
1072 rec_command(RECORDING_CMD_STOP);
1074 else
1076 #if CONFIG_CODEC != SWCODEC
1077 peak_meter_playback(true);
1078 peak_meter_enabled = false;
1079 #endif
1080 done = true;
1082 update_countdown = 1; /* Update immediately */
1083 break;
1085 case ACTION_REC_PAUSE:
1086 case ACTION_REC_NEWFILE:
1087 /* Only act if the mpeg is stopped */
1088 if(!(audio_stat & AUDIO_STATUS_RECORD))
1090 /* is this manual or triggered recording? */
1091 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1092 (peak_meter_trigger_status() != TRIG_OFF))
1094 /* manual recording */
1095 rec_status |= RCSTAT_HAVE_RECORDED;
1096 rec_command(RECORDING_CMD_START);
1097 last_seconds = 0;
1098 if (global_settings.talk_menu)
1100 /* no voice possible here, but a beep */
1101 audio_beep(HZ/2); /* longer beep on start */
1104 /* this is triggered recording */
1105 else
1107 /* we don't start recording now, but enable the
1108 trigger and let the callback function
1109 trigger_listener control when the recording starts */
1110 peak_meter_trigger(true);
1111 peak_meter_set_trigger_listener(&trigger_listener);
1114 else
1116 /*if new file button pressed, start new file */
1117 if (button == ACTION_REC_NEWFILE)
1119 rec_command(RECORDING_CMD_START_NEWFILE);
1120 last_seconds = 0;
1122 else
1123 /* if pause button pressed, pause or resume */
1125 if(audio_stat & AUDIO_STATUS_PAUSE)
1127 rec_command(RECORDING_CMD_RESUME);
1128 if (global_settings.talk_menu)
1130 /* no voice possible here, but a beep */
1131 audio_beep(HZ/4); /* short beep on resume */
1134 else
1136 rec_command(RECORDING_CMD_PAUSE);
1140 update_countdown = 1; /* Update immediately */
1141 break;
1143 case ACTION_STD_PREV:
1144 cursor--;
1145 adjust_cursor();
1146 update_countdown = 1; /* Update immediately */
1147 break;
1149 case ACTION_STD_NEXT:
1150 cursor++;
1151 adjust_cursor();
1152 update_countdown = 1; /* Update immediately */
1153 break;
1155 case ACTION_SETTINGS_INC:
1156 case ACTION_SETTINGS_INCREPEAT:
1157 switch(cursor)
1159 case 0:
1160 global_settings.volume++;
1161 setvol();
1162 break;
1163 case 1:
1164 if(global_settings.rec_source == AUDIO_SRC_MIC)
1166 if(global_settings.rec_mic_gain <
1167 sound_max(SOUND_MIC_GAIN))
1168 global_settings.rec_mic_gain++;
1170 else
1172 if(global_settings.rec_left_gain <
1173 sound_max(SOUND_LEFT_GAIN))
1174 global_settings.rec_left_gain++;
1175 if(global_settings.rec_right_gain <
1176 sound_max(SOUND_RIGHT_GAIN))
1177 global_settings.rec_right_gain++;
1179 break;
1180 case 2:
1181 if(global_settings.rec_left_gain <
1182 sound_max(SOUND_LEFT_GAIN))
1183 global_settings.rec_left_gain++;
1184 break;
1185 case 3:
1186 if(global_settings.rec_right_gain <
1187 sound_max(SOUND_RIGHT_GAIN))
1188 global_settings.rec_right_gain++;
1189 break;
1190 #ifdef HAVE_AGC
1191 case 4:
1192 agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE);
1193 agc_enable = (agc_preset != 0);
1194 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1195 global_settings.rec_agc_preset_mic = agc_preset;
1196 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1197 } else {
1198 global_settings.rec_agc_preset_line = agc_preset;
1199 agc_maxgain = global_settings.rec_agc_maxgain_line;
1201 break;
1202 case 5:
1203 if (global_settings.rec_source == AUDIO_SRC_MIC)
1205 agc_maxgain = MIN(agc_maxgain + 1,
1206 sound_max(SOUND_MIC_GAIN));
1207 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1209 else
1211 agc_maxgain = MIN(agc_maxgain + 1,
1212 sound_max(SOUND_LEFT_GAIN));
1213 global_settings.rec_agc_maxgain_line = agc_maxgain;
1215 break;
1216 #endif /* HAVE_AGC */
1218 set_gain();
1219 update_countdown = 1; /* Update immediately */
1220 break;
1222 case ACTION_SETTINGS_DEC:
1223 case ACTION_SETTINGS_DECREPEAT:
1224 switch(cursor)
1226 case 0:
1227 global_settings.volume--;
1228 setvol();
1229 break;
1230 case 1:
1231 if(global_settings.rec_source == AUDIO_SRC_MIC)
1233 if(global_settings.rec_mic_gain >
1234 sound_min(SOUND_MIC_GAIN))
1235 global_settings.rec_mic_gain--;
1237 else
1239 if(global_settings.rec_left_gain >
1240 sound_min(SOUND_LEFT_GAIN))
1241 global_settings.rec_left_gain--;
1242 if(global_settings.rec_right_gain >
1243 sound_min(SOUND_RIGHT_GAIN))
1244 global_settings.rec_right_gain--;
1246 break;
1247 case 2:
1248 if(global_settings.rec_left_gain >
1249 sound_min(SOUND_LEFT_GAIN))
1250 global_settings.rec_left_gain--;
1251 break;
1252 case 3:
1253 if(global_settings.rec_right_gain >
1254 sound_min(SOUND_RIGHT_GAIN))
1255 global_settings.rec_right_gain--;
1256 break;
1257 #ifdef HAVE_AGC
1258 case 4:
1259 agc_preset = MAX(agc_preset - 1, 0);
1260 agc_enable = (agc_preset != 0);
1261 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1262 global_settings.rec_agc_preset_mic = agc_preset;
1263 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1264 } else {
1265 global_settings.rec_agc_preset_line = agc_preset;
1266 agc_maxgain = global_settings.rec_agc_maxgain_line;
1268 break;
1269 case 5:
1270 if (global_settings.rec_source == AUDIO_SRC_MIC)
1272 agc_maxgain = MAX(agc_maxgain - 1,
1273 sound_min(SOUND_MIC_GAIN));
1274 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1276 else
1278 agc_maxgain = MAX(agc_maxgain - 1,
1279 sound_min(SOUND_LEFT_GAIN));
1280 global_settings.rec_agc_maxgain_line = agc_maxgain;
1282 break;
1283 #endif /* HAVE_AGC */
1285 set_gain();
1286 update_countdown = 1; /* Update immediately */
1287 break;
1289 case ACTION_STD_MENU:
1290 #if CONFIG_CODEC == SWCODEC
1291 if(!(audio_stat & AUDIO_STATUS_RECORD))
1292 #else
1293 if(audio_stat != AUDIO_STATUS_RECORD)
1294 #endif
1296 #ifdef HAVE_FMRADIO_REC
1297 const int prev_rec_source = global_settings.rec_source;
1298 #endif
1300 #if (CONFIG_LED == LED_REAL)
1301 /* led is restored at begin of loop / end of function */
1302 led(false);
1303 #endif
1304 if (recording_menu(no_source))
1306 done = true;
1307 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1308 #ifdef HAVE_FMRADIO_REC
1309 radio_status = FMRADIO_OFF;
1310 #endif
1312 else
1314 #ifdef HAVE_FMRADIO_REC
1315 /* If input changes away from FM Radio, radio will
1316 remain off when recording screen closes. */
1317 if (global_settings.rec_source != prev_rec_source
1318 && prev_rec_source == AUDIO_SRC_FMRADIO)
1319 radio_status = FMRADIO_OFF;
1320 #endif
1322 #if CONFIG_CODEC == SWCODEC
1323 /* reinit after submenu exit */
1324 audio_close_recording();
1325 audio_init_recording(0);
1326 #endif
1328 rec_init_recording_options(&rec_options);
1329 rec_set_recording_options(&rec_options);
1331 if(rec_create_directory() < 0)
1333 goto rec_abort;
1336 #if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
1337 /* If format changed, a new number is required */
1338 rec_init_filename();
1339 #endif
1341 #ifdef HAVE_AGC
1342 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1343 agc_preset = global_settings.rec_agc_preset_mic;
1344 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1346 else {
1347 agc_preset = global_settings.rec_agc_preset_line;
1348 agc_maxgain = global_settings.rec_agc_maxgain_line;
1350 #endif
1352 adjust_cursor();
1353 set_gain();
1354 update_countdown = 1; /* Update immediately */
1356 FOR_NB_SCREENS(i)
1358 screens[i].setfont(FONT_SYSFIXED);
1359 screens[i].setmargins(
1360 global_settings.cursor_style ? 0 : w, 8);
1364 break;
1366 #if CONFIG_KEYPAD == RECORDER_PAD
1367 case ACTION_REC_F2:
1368 if(audio_stat != AUDIO_STATUS_RECORD)
1370 #if (CONFIG_LED == LED_REAL)
1371 /* led is restored at begin of loop / end of function */
1372 led(false);
1373 #endif
1374 if (f2_rec_screen())
1376 rec_status |= RCSTAT_HAVE_RECORDED;
1377 done = true;
1379 else
1380 update_countdown = 1; /* Update immediately */
1382 break;
1384 case ACTION_REC_F3:
1385 if(audio_stat & AUDIO_STATUS_RECORD)
1387 rec_command(RECORDING_CMD_START_NEWFILE);
1388 last_seconds = 0;
1390 else
1392 #if (CONFIG_LED == LED_REAL)
1393 /* led is restored at begin of loop / end of function */
1394 led(false);
1395 #endif
1396 if (f3_rec_screen())
1398 rec_status |= RCSTAT_HAVE_RECORDED;
1399 done = true;
1401 else
1402 update_countdown = 1; /* Update immediately */
1404 break;
1405 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
1407 case SYS_USB_CONNECTED:
1408 /* Only accept USB connection when not recording */
1409 if(!(audio_stat & AUDIO_STATUS_RECORD))
1411 default_event_handler(SYS_USB_CONNECTED);
1412 done = true;
1413 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1414 #ifdef HAVE_FMRADIO_REC
1415 radio_status = FMRADIO_OFF;
1416 #endif
1418 break;
1420 default:
1421 default_event_handler(button);
1422 break;
1423 } /* end switch */
1425 #ifdef HAVE_AGC
1426 peak_read = !peak_read;
1427 if (peak_read) { /* every 2nd run of loop */
1428 peak_time++;
1429 peak_valid = read_peak_levels(&peak_l, &peak_r, &balance);
1432 /* Handle AGC every 200ms when enabled and peak data is valid */
1433 if (peak_read && agc_enable && peak_valid)
1434 auto_gain_control(&peak_l, &peak_r, &balance);
1435 #endif
1437 FOR_NB_SCREENS(i)
1438 screens[i].setfont(FONT_SYSFIXED);
1440 seconds = audio_recorded_time() / HZ;
1442 update_countdown--;
1443 if(update_countdown == 0 || seconds > last_seconds)
1445 unsigned int dseconds, dhours, dminutes;
1446 unsigned long num_recorded_bytes, dsize, dmb;
1447 int pos = 0;
1449 update_countdown = 5;
1450 last_seconds = seconds;
1452 dseconds = rec_timesplit_seconds();
1453 dsize = rec_sizesplit_bytes();
1454 num_recorded_bytes = audio_num_recorded_bytes();
1456 for(i = 0; i < screen_update; i++)
1457 screens[i].clear_display();
1459 style = base_style;
1461 #ifdef HAVE_LCD_COLOR
1462 /* special action for gradient - set default for 1 line gradient */
1463 if(global_settings.cursor_style == 3)
1464 style = base_style | CURLN_PACK(0) | NUMLN_PACK(1);
1465 #endif /* HAVE_LCD_COLOR */
1467 #if CONFIG_CODEC == SWCODEC
1468 if ((audio_stat & AUDIO_STATUS_WARNING)
1469 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
1471 /* Switch back and forth displaying warning on first available
1472 line to ensure visibility - the motion should also help
1473 draw attention */
1474 /* Don't use language string unless agreed upon to make this
1475 method permanent - could do something in the statusbar */
1476 snprintf(buf, sizeof(buf), "Warning: %08X",
1477 pcm_rec_get_warnings());
1479 else
1480 #endif /* CONFIG_CODEC == SWCODEC */
1481 if ((global_settings.rec_sizesplit) &&
1482 (global_settings.rec_split_method))
1484 dmb = dsize/1024/1024;
1485 snprintf(buf, sizeof(buf), "%s %dMB",
1486 str(LANG_SYSFONT_SPLIT_SIZE), dmb);
1488 else
1490 hours = seconds / 3600;
1491 minutes = (seconds - (hours * 3600)) / 60;
1492 snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d",
1493 str(LANG_SYSFONT_RECORDING_TIME),
1494 hours, minutes, seconds%60);
1497 for(i = 0; i < screen_update; i++)
1498 screens[i].puts(0, 0, buf);
1500 if(audio_stat & AUDIO_STATUS_PRERECORD)
1502 snprintf(buf, sizeof(buf), "%s...",
1503 str(LANG_SYSFONT_RECORD_PRERECORD));
1505 else
1507 /* Display the split interval if the record timesplit
1508 is active */
1509 if ((global_settings.rec_timesplit) &&
1510 !(global_settings.rec_split_method))
1512 /* Display the record timesplit interval rather
1513 than the file size if the record timer is
1514 active */
1515 dhours = dseconds / 3600;
1516 dminutes = (dseconds - (dhours * 3600)) / 60;
1517 snprintf(buf, sizeof(buf), "%s %02d:%02d",
1518 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC),
1519 dhours, dminutes);
1521 else
1523 output_dyn_value(buf2, sizeof buf2,
1524 num_recorded_bytes,
1525 byte_units, true);
1526 snprintf(buf, sizeof(buf), "%s %s",
1527 str(LANG_SYSFONT_RECORDING_SIZE), buf2);
1530 for(i = 0; i < screen_update; i++)
1531 screens[i].puts(0, 1, buf);
1533 for(i = 0; i < screen_update; i++)
1535 if (filename_offset[i] > 0)
1537 *filename = '\0';
1538 if (audio_stat & AUDIO_STATUS_RECORD)
1540 strncpy(filename, path_buffer +
1541 strlen(path_buffer) - 12, 13);
1542 filename[12]='\0';
1545 snprintf(buf, sizeof(buf), "%s %s",
1546 str(LANG_SYSFONT_RECORDING_FILENAME), filename);
1547 screens[i].puts(0, 2, buf);
1551 /* We will do file splitting regardless, either at the end of
1552 a split interval, or when the filesize approaches the 2GB
1553 FAT file size (compatibility) limit. */
1554 if ((audio_stat && !(global_settings.rec_split_method)
1555 && global_settings.rec_timesplit && (seconds >= dseconds))
1556 || (audio_stat && global_settings.rec_split_method
1557 && global_settings.rec_sizesplit
1558 && (num_recorded_bytes >= dsize))
1559 || (num_recorded_bytes >= MAX_FILE_SIZE))
1561 if (!(global_settings.rec_split_type)
1562 || (num_recorded_bytes >= MAX_FILE_SIZE))
1564 rec_command(RECORDING_CMD_START_NEWFILE);
1565 last_seconds = 0;
1567 else
1569 peak_meter_trigger(false);
1570 peak_meter_set_trigger_listener(NULL);
1571 rec_command(RECORDING_CMD_STOP);
1573 update_countdown = 1;
1576 /* draw the clipcounter just in front of the peakmeter */
1577 if(global_settings.peak_meter_clipcounter)
1579 char clpstr[32];
1580 snprintf(clpstr, 32, "%4d", pm_get_clipcount());
1581 for(i = 0; i < screen_update; i++)
1583 if(PM_HEIGHT > 1)
1584 screens[i].puts(0, 2 + filename_offset[i],
1585 str(LANG_SYSFONT_PM_CLIPCOUNT));
1586 screens[i].puts(0, 1 + PM_HEIGHT + filename_offset[i],
1587 clpstr);
1591 snprintf(buf, sizeof(buf), "%s: %s", str(LANG_SYSFONT_VOLUME),
1592 fmt_gain(SOUND_VOLUME,
1593 global_settings.volume,
1594 buf2, sizeof(buf2)));
1596 if (global_settings.cursor_style && (pos++ == cursor))
1598 for(i = 0; i < screen_update; i++)
1599 screens[i].puts_style_offset(0, filename_offset[i] +
1600 PM_HEIGHT + 2, buf, style,0);
1602 else
1604 for(i = 0; i < screen_update; i++)
1605 screens[i].puts(0, filename_offset[i] + PM_HEIGHT + 2, buf);
1608 if(global_settings.rec_source == AUDIO_SRC_MIC)
1610 /* Draw MIC recording gain */
1611 snprintf(buf, sizeof(buf), "%s:%s", str(LANG_SYSFONT_GAIN),
1612 fmt_gain(SOUND_MIC_GAIN,
1613 global_settings.rec_mic_gain,
1614 buf2, sizeof(buf2)));
1615 if(global_settings.cursor_style && ((1==cursor)||(2==cursor)))
1617 for(i = 0; i < screen_update; i++)
1618 screens[i].puts_style_offset(0, filename_offset[i] +
1619 PM_HEIGHT + 3, buf, style,0);
1621 else
1623 for(i = 0; i < screen_update; i++)
1624 screens[i].puts(0, filename_offset[i] +
1625 PM_HEIGHT + 3, buf);
1628 else if(0
1629 HAVE_LINE_REC_( || global_settings.rec_source ==
1630 AUDIO_SRC_LINEIN)
1631 HAVE_FMRADIO_REC_( || global_settings.rec_source ==
1632 AUDIO_SRC_FMRADIO)
1635 /* Draw LINE or FMRADIO recording gain */
1636 snprintf(buf, sizeof(buf), "%s:%s",
1637 str(LANG_SYSFONT_RECORDING_LEFT),
1638 fmt_gain(SOUND_LEFT_GAIN,
1639 global_settings.rec_left_gain,
1640 buf2, sizeof(buf2)));
1641 #ifdef HAVE_LCD_COLOR
1642 /* special action for gradient - double line gradient - line1 */
1643 if((global_settings.cursor_style == 3) &&
1644 (1==cursor))
1645 style = base_style | CURLN_PACK(0) | NUMLN_PACK(2);
1646 #endif /* HAVE_LCD_COLOR */
1647 if(global_settings.cursor_style && ((1==cursor)||(2==cursor)))
1649 for(i = 0; i < screen_update; i++)
1650 screens[i].puts_style_offset(0, filename_offset[i] +
1651 PM_HEIGHT + 3, buf, style,0);
1653 else
1655 for(i = 0; i < screen_update; i++)
1656 screens[i].puts(0, filename_offset[i] +
1657 PM_HEIGHT + 3, buf);
1660 snprintf(buf, sizeof(buf), "%s:%s",
1661 str(LANG_SYSFONT_RECORDING_RIGHT),
1662 fmt_gain(SOUND_RIGHT_GAIN,
1663 global_settings.rec_right_gain,
1664 buf2, sizeof(buf2)));
1665 #ifdef HAVE_LCD_COLOR
1666 /* special action for gradient - double line gradient - line2 */
1667 if((global_settings.cursor_style == 3) &&
1668 (1==cursor))
1669 style = base_style | CURLN_PACK(1) | NUMLN_PACK(2);
1670 #endif /* HAVE_LCD_COLOR */
1671 if(global_settings.cursor_style && ((1==cursor)||(3==cursor)))
1673 for(i = 0; i < screen_update; i++)
1674 screens[i].puts_style_offset(0, filename_offset[i] +
1675 PM_HEIGHT + 4, buf, style,0);
1677 else
1679 for(i = 0; i < screen_update; i++)
1680 screens[i].puts(0, filename_offset[i] +
1681 PM_HEIGHT + 4, buf);
1684 #ifdef HAVE_LCD_COLOR
1685 /* special action for gradient - back to single line gradient */
1686 if(global_settings.cursor_style == 3)
1687 style = base_style | CURLN_PACK(0) | NUMLN_PACK(1);
1688 #endif /* HAVE_LCD_COLOR */
1690 FOR_NB_SCREENS(i)
1692 switch (global_settings.rec_source)
1694 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
1695 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
1696 line[i] = 5;
1697 break;
1699 case AUDIO_SRC_MIC:
1700 line[i] = 4;
1701 break;
1702 #ifdef HAVE_SPDIF_REC
1703 case AUDIO_SRC_SPDIF:
1704 line[i] = 3;
1705 break;
1706 #endif
1707 default:
1708 line[i] = 5; /* to prevent uninitialisation
1709 warnings for line[0] */
1710 break;
1711 } /* end switch */
1712 #ifdef HAVE_AGC
1713 if (screens[i].height < h * (2 + filename_offset[i] +
1714 PM_HEIGHT + line[i]))
1716 line[i] -= 1;
1717 display_agc[i] = false;
1719 else
1720 display_agc[i] = true;
1722 if ((cursor==4) || (cursor==5))
1723 display_agc[i] = true;
1726 /************** AGC test info ******************
1727 snprintf(buf, sizeof(buf), "D:%d U:%d",
1728 (agc_droptime+2)/5, (agc_risetime+2)/5);
1729 lcd_putsxy(1, LCD_HEIGHT - 8, buf);
1730 snprintf(buf, sizeof(buf), "B:%d",
1731 (agc_baltime+2)/5);
1732 lcd_putsxy(LCD_WIDTH/2 + 3, LCD_HEIGHT - 8, buf);
1733 ***********************************************/
1735 if (cursor == 5)
1736 snprintf(buf, sizeof(buf), "%s: %s",
1737 str(LANG_SYSFONT_RECORDING_AGC_MAXGAIN),
1738 fmt_gain(SOUND_LEFT_GAIN,
1739 agc_maxgain, buf2, sizeof(buf2)));
1740 else if (agc_preset == 0)
1741 snprintf(buf, sizeof(buf), "%s: %s",
1742 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1743 agc_preset_str[agc_preset]);
1744 else if (global_settings.rec_source == AUDIO_SRC_MIC)
1745 snprintf(buf, sizeof(buf), "%s: %s%s",
1746 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1747 agc_preset_str[agc_preset],
1748 fmt_gain(SOUND_LEFT_GAIN,
1749 agc_maxgain -
1750 global_settings.rec_mic_gain,
1751 buf2, sizeof(buf2)));
1752 else
1753 snprintf(buf, sizeof(buf), "%s: %s%s",
1754 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1755 agc_preset_str[agc_preset],
1756 fmt_gain(SOUND_LEFT_GAIN,
1757 agc_maxgain -
1758 (global_settings.rec_left_gain +
1759 global_settings.rec_right_gain)/2,
1760 buf2, sizeof(buf2)));
1762 if(global_settings.cursor_style && ((cursor==4) || (cursor==5)))
1764 for(i = 0; i < screen_update; i++)
1765 screens[i].puts_style_offset(0, filename_offset[i] +
1766 PM_HEIGHT + line[i], buf, style,0);
1768 else if (global_settings.rec_source == AUDIO_SRC_MIC
1769 HAVE_LINE_REC_(|| global_settings.rec_source ==
1770 AUDIO_SRC_LINEIN)
1771 HAVE_FMRADIO_REC_(|| global_settings.rec_source ==
1772 AUDIO_SRC_FMRADIO)
1775 for(i = 0; i < screen_update; i++) {
1776 if (display_agc[i]) {
1777 screens[i].puts(0, filename_offset[i] +
1778 PM_HEIGHT + line[i], buf);
1783 if (global_settings.rec_source == AUDIO_SRC_MIC)
1785 if(agc_maxgain < (global_settings.rec_mic_gain))
1786 change_recording_gain(false, true, true);
1788 else
1790 if(agc_maxgain < (global_settings.rec_left_gain))
1791 change_recording_gain(false, true, false);
1792 if(agc_maxgain < (global_settings.rec_right_gain))
1793 change_recording_gain(false, false, true);
1795 #else /* !HAVE_AGC */
1797 #endif /* HAVE_AGC */
1799 if(!global_settings.cursor_style) {
1800 switch(cursor)
1802 case 1:
1803 for(i = 0; i < screen_update; i++)
1804 screen_put_cursorxy(&screens[i], 0,
1805 filename_offset[i] +
1806 PM_HEIGHT + 3, true);
1808 if(global_settings.rec_source != AUDIO_SRC_MIC)
1810 for(i = 0; i < screen_update; i++)
1811 screen_put_cursorxy(&screens[i], 0,
1812 filename_offset[i] +
1813 PM_HEIGHT + 4, true);
1815 break;
1816 case 2:
1817 for(i = 0; i < screen_update; i++)
1818 screen_put_cursorxy(&screens[i], 0,
1819 filename_offset[i] +
1820 PM_HEIGHT + 3, true);
1821 break;
1822 case 3:
1823 for(i = 0; i < screen_update; i++)
1824 screen_put_cursorxy(&screens[i], 0,
1825 filename_offset[i] +
1826 PM_HEIGHT + 4, true);
1827 break;
1828 #ifdef HAVE_AGC
1829 case 4:
1830 case 5:
1831 for(i = 0; i < screen_update; i++)
1832 screen_put_cursorxy(&screens[i], 0,
1833 filename_offset[i] +
1834 PM_HEIGHT + line[i], true);
1835 break;
1836 #endif /* HAVE_AGC */
1837 default:
1838 for(i = 0; i < screen_update; i++)
1839 screen_put_cursorxy(&screens[i], 0,
1840 filename_offset[i] +
1841 PM_HEIGHT + 2, true);
1845 #ifdef HAVE_AGC
1846 hist_time++;
1847 #endif
1849 for(i = 0; i < screen_update; i++)
1851 gui_statusbar_draw(&(statusbars.statusbars[i]), true);
1852 peak_meter_screen(&screens[i], pm_x, pm_y[i], h*PM_HEIGHT);
1853 screens[i].update();
1856 /* draw the trigger status */
1857 FOR_NB_SCREENS(i)
1859 trig_width[i] = ((screens[i].height < 64) ||
1860 ((screens[i].height < 72) && (PM_HEIGHT > 1))) ?
1861 screens[i].width - 14 * w : screens[i].width;
1862 trig_xpos[i] = screens[i].width - trig_width[i];
1863 trig_ypos[i] = ((screens[i].height < 72) && (PM_HEIGHT > 1)) ?
1864 h*2 :
1865 h*(1 + filename_offset[i] + PM_HEIGHT +
1866 line[i]
1867 #ifdef HAVE_AGC
1869 #endif
1873 if (peak_meter_trigger_status() != TRIG_OFF)
1875 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width,
1876 screen_update);
1877 for(i = 0; i < screen_update; i++){
1878 screens[i].update_rect(trig_xpos[i], trig_ypos[i],
1879 trig_width[i] + 2, TRIG_HEIGHT);
1884 if(audio_stat & AUDIO_STATUS_ERROR)
1886 done = true;
1888 } /* end while(!done) */
1890 audio_stat = audio_status();
1891 if (audio_stat & AUDIO_STATUS_ERROR)
1893 gui_syncsplash(0, str(LANG_SYSFONT_DISK_FULL));
1894 gui_syncstatusbar_draw(&statusbars, true);
1896 FOR_NB_SCREENS(i)
1897 screens[i].update();
1899 #if CONFIG_CODEC == SWCODEC
1900 /* stop recording - some players like H10 freeze otherwise
1901 TO DO: find out why it freezes and fix properly */
1902 rec_command(RECORDING_CMD_STOP);
1903 audio_close_recording();
1904 #endif
1906 audio_error_clear();
1908 while(1)
1910 if (action_userabort(TIMEOUT_NOBLOCK))
1911 break;
1915 rec_abort:
1917 #if CONFIG_CODEC == SWCODEC
1918 rec_command(RECORDING_CMD_STOP);
1919 audio_close_recording();
1921 #ifdef HAVE_FMRADIO_REC
1922 if (radio_status != FMRADIO_OFF)
1923 /* Restore radio playback - radio_status should be unchanged if started
1924 through fm radio screen (barring usb connect) */
1925 rec_set_source(AUDIO_SRC_FMRADIO, (radio_status & FMRADIO_PAUSED) ?
1926 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
1927 else
1928 #endif
1929 /* Go back to playback mode */
1930 rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
1932 /* restore talking */
1933 talk_disable(false);
1934 #else /* !SWCODEC */
1935 audio_init_playback();
1936 #endif /* CONFIG_CODEC == SWCODEC */
1938 /* make sure the trigger is really turned off */
1939 peak_meter_trigger(false);
1940 peak_meter_set_trigger_listener(NULL);
1942 rec_status &= ~RCSTAT_IN_RECSCREEN;
1943 sound_settings_apply();
1945 FOR_NB_SCREENS(i)
1946 screens[i].setfont(FONT_UI);
1948 /* if the directory was created or recording happened, make sure the
1949 browser is updated */
1950 if (rec_status & (RCSTAT_CREATED_DIRECTORY | RCSTAT_HAVE_RECORDED))
1951 reload_directory();
1953 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
1954 ata_set_led_enabled(true);
1955 #endif
1957 settings_save();
1959 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
1960 } /* recording_screen */
1962 #if CONFIG_KEYPAD == RECORDER_PAD
1963 static bool f2_rec_screen(void)
1965 static const char* const freq_str[6] =
1967 "44.1kHz",
1968 "48kHz",
1969 "32kHz",
1970 "22.05kHz",
1971 "24kHz",
1972 "16kHz"
1975 bool exit = false;
1976 bool used = false;
1977 int w, h, i;
1978 char buf[32];
1979 int button;
1980 struct audio_recording_options rec_options;
1982 FOR_NB_SCREENS(i)
1984 screens[i].setfont(FONT_SYSFIXED);
1985 screens[i].getstringsize("A",&w,&h);
1988 while (!exit) {
1989 const char* ptr=NULL;
1991 FOR_NB_SCREENS(i)
1993 screens[i].clear_display();
1995 /* Recording quality */
1996 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
1997 str(LANG_SYSFONT_RECORDING_QUALITY));
2000 snprintf(buf, sizeof(buf), "%d", global_settings.rec_quality);
2001 FOR_NB_SCREENS(i)
2003 screens[i].putsxy(0, LCD_HEIGHT/2-h, buf);
2004 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
2005 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
2008 /* Frequency */
2009 snprintf(buf, sizeof buf, "%s:", str(LANG_SYSFONT_RECORDING_FREQUENCY));
2010 ptr = freq_str[global_settings.rec_frequency];
2011 FOR_NB_SCREENS(i)
2013 screens[i].getstringsize(buf,&w,&h);
2014 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
2015 screens[i].getstringsize(ptr, &w, &h);
2016 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
2017 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
2018 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
2021 /* Channel mode */
2022 switch ( global_settings.rec_channels ) {
2023 case 0:
2024 ptr = str(LANG_SYSFONT_CHANNEL_STEREO);
2025 break;
2027 case 1:
2028 ptr = str(LANG_SYSFONT_CHANNEL_MONO);
2029 break;
2032 FOR_NB_SCREENS(i)
2034 screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h);
2035 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
2036 str(LANG_SYSFONT_CHANNELS));
2037 screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h);
2038 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h,
2039 str(LANG_SYSFONT_MODE));
2040 screens[i].getstringsize(ptr, &w, &h);
2041 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
2042 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
2043 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
2045 screens[i].update();
2048 button = button_get(true);
2049 switch (button) {
2050 case BUTTON_LEFT:
2051 case BUTTON_F2 | BUTTON_LEFT:
2052 global_settings.rec_quality++;
2053 if(global_settings.rec_quality > 7)
2054 global_settings.rec_quality = 0;
2055 used = true;
2056 break;
2058 case BUTTON_DOWN:
2059 case BUTTON_F2 | BUTTON_DOWN:
2060 global_settings.rec_frequency++;
2061 if(global_settings.rec_frequency > 5)
2062 global_settings.rec_frequency = 0;
2063 used = true;
2064 break;
2066 case BUTTON_RIGHT:
2067 case BUTTON_F2 | BUTTON_RIGHT:
2068 global_settings.rec_channels++;
2069 if(global_settings.rec_channels > 1)
2070 global_settings.rec_channels = 0;
2071 used = true;
2072 break;
2074 case BUTTON_F2 | BUTTON_REL:
2075 if ( used )
2076 exit = true;
2077 used = true;
2078 break;
2080 case BUTTON_F2 | BUTTON_REPEAT:
2081 used = true;
2082 break;
2084 default:
2085 if(default_event_handler(button) == SYS_USB_CONNECTED)
2086 return true;
2087 break;
2091 rec_init_recording_options(&rec_options);
2092 rec_set_recording_options(&rec_options);
2094 set_gain();
2096 settings_save();
2097 FOR_NB_SCREENS(i)
2098 screens[i].setfont(FONT_UI);
2100 return false;
2103 static bool f3_rec_screen(void)
2105 bool exit = false;
2106 bool used = false;
2107 int w, h, i;
2108 int button;
2109 char *src_str[] =
2111 str(LANG_SYSFONT_RECORDING_SRC_MIC),
2112 str(LANG_SYSFONT_LINE_IN),
2113 str(LANG_SYSFONT_RECORDING_SRC_DIGITAL)
2115 struct audio_recording_options rec_options;
2117 FOR_NB_SCREENS(i)
2119 screens[i].setfont(FONT_SYSFIXED);
2120 screens[i].getstringsize("A",&w,&h);
2123 while (!exit) {
2124 char* ptr=NULL;
2125 ptr = src_str[global_settings.rec_source];
2126 FOR_NB_SCREENS(i)
2128 screens[i].clear_display();
2130 /* Recording source */
2131 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
2132 str(LANG_SYSFONT_RECORDING_SOURCE));
2134 screens[i].getstringsize(ptr, &w, &h);
2135 screens[i].putsxy(0, LCD_HEIGHT/2-h, ptr);
2136 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
2137 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
2140 /* trigger setup */
2141 ptr = str(LANG_SYSFONT_RECORD_TRIGGER);
2142 FOR_NB_SCREENS(i)
2144 screens[i].getstringsize(ptr,&w,&h);
2145 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr);
2146 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
2147 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
2149 screens[i].update();
2152 button = button_get(true);
2153 switch (button) {
2154 case BUTTON_DOWN:
2155 case BUTTON_F3 | BUTTON_DOWN:
2156 #ifndef SIMULATOR
2157 rectrigger();
2158 settings_apply_trigger();
2159 #endif
2160 exit = true;
2161 break;
2163 case BUTTON_LEFT:
2164 case BUTTON_F3 | BUTTON_LEFT:
2165 global_settings.rec_source++;
2166 if(global_settings.rec_source > AUDIO_SRC_MAX)
2167 global_settings.rec_source = 0;
2168 used = true;
2169 break;
2171 case BUTTON_F3 | BUTTON_REL:
2172 if ( used )
2173 exit = true;
2174 used = true;
2175 break;
2177 case BUTTON_F3 | BUTTON_REPEAT:
2178 used = true;
2179 break;
2181 default:
2182 if(default_event_handler(button) == SYS_USB_CONNECTED)
2183 return true;
2184 break;
2188 rec_init_recording_options(&rec_options);
2189 rec_set_recording_options(&rec_options);
2191 set_gain();
2193 settings_save();
2194 FOR_NB_SCREENS(i)
2195 screens[i].setfont(FONT_UI);
2197 return false;
2199 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
2201 #if CONFIG_CODEC == SWCODEC
2202 void audio_beep(int duration)
2204 /* dummy */
2205 (void)duration;
2208 #ifdef SIMULATOR
2209 /* stubs for recording sim */
2210 void audio_init_recording(unsigned int buffer_offset)
2212 buffer_offset = buffer_offset;
2215 void audio_close_recording(void)
2219 unsigned long pcm_rec_get_warnings(void)
2221 return 0;
2224 unsigned long audio_recorded_time(void)
2226 return 123;
2229 unsigned long audio_num_recorded_bytes(void)
2231 return 5 * 1024 * 1024;
2234 void rec_set_source(int source, unsigned flags)
2236 source = source;
2237 flags = flags;
2240 void audio_set_recording_options(struct audio_recording_options *options)
2242 options = options;
2245 void audio_set_recording_gain(int left, int right, int type)
2247 left = left;
2248 right = right;
2249 type = type;
2252 void audio_record(const char *filename)
2254 filename = filename;
2257 void audio_new_file(const char *filename)
2259 filename = filename;
2262 void audio_stop_recording(void)
2266 void audio_pause_recording(void)
2270 void audio_resume_recording(void)
2274 #endif /* #ifdef SIMULATOR */
2275 #endif /* #ifdef CONFIG_CODEC == SWCODEC */
2277 #endif /* HAVE_RECORDING */