Don't objcopy simulator plugins.
[kugel-rb.git] / apps / recorder / recording.c
blobb2c81cd21b5c4a550d3ef2b53022236961fa8821
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "config.h"
24 #include <stdio.h>
25 #include <stdbool.h>
26 #include <stdlib.h>
28 #include "system.h"
29 #include "power.h"
30 #include "powermgmt.h"
31 #include "lcd.h"
32 #include "led.h"
33 #include "mpeg.h"
34 #include "audio.h"
35 #if CONFIG_CODEC == SWCODEC
36 #include "thread.h"
37 #include "playback.h"
38 #include "enc_config.h"
39 #if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT)
40 #include "spdif.h"
41 #endif
42 #endif /* CONFIG_CODEC == SWCODEC */
43 #include "pcm_record.h"
44 #include "recording.h"
45 #include "mp3_playback.h"
46 #include "mas.h"
47 #include "button.h"
48 #include "kernel.h"
49 #include "settings.h"
50 #include "lang.h"
51 #include "font.h"
52 #include "icons.h"
53 #include "icon.h"
54 #include "screens.h"
55 #include "peakmeter.h"
56 #include "statusbar.h"
57 #include "menu.h"
58 #include "sound_menu.h"
59 #include "timefuncs.h"
60 #include "debug.h"
61 #include "misc.h"
62 #include "tree.h"
63 #include "string.h"
64 #include "dir.h"
65 #include "errno.h"
66 #include "talk.h"
67 #include "sound.h"
68 #include "storage.h"
69 #if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
70 && !defined(SIMULATOR)
71 #include "ata.h"
72 #endif
73 #include "splash.h"
74 #include "screen_access.h"
75 #include "action.h"
76 #include "radio.h"
77 #include "sound_menu.h"
78 #include "viewport.h"
79 #include "list.h"
81 #ifdef HAVE_RECORDING
82 /* This array holds the record timer interval lengths, in seconds */
83 static const unsigned long rec_timer_seconds[] =
85 0, /* 0 means OFF */
86 5*60, /* 00:05 */
87 10*60, /* 00:10 */
88 15*60, /* 00:15 */
89 30*60, /* 00:30 */
90 60*60, /* 01:00 */
91 74*60, /* 74:00 */
92 80*60, /* 80:00 */
93 2*60*60, /* 02:00 */
94 4*60*60, /* 04:00 */
95 6*60*60, /* 06:00 */
96 8*60*60, /* 08:00 */
97 10L*60*60, /* 10:00 */
98 12L*60*60, /* 12:00 */
99 18L*60*60, /* 18:00 */
100 24L*60*60 /* 24:00 */
103 static unsigned int rec_timesplit_seconds(void)
105 return rec_timer_seconds[global_settings.rec_timesplit];
108 /* This array holds the record size interval lengths, in bytes */
109 static const unsigned long rec_size_bytes[] =
111 0, /* 0 means OFF */
112 5*1024*1024, /* 5MB */
113 10*1024*1024, /* 10MB */
114 15*1024*1024, /* 15MB */
115 32*1024*1024, /* 32MB */
116 64*1024*1024, /* 64MB */
117 75*1024*1024, /* 75MB */
118 100*1024*1024, /* 100MB */
119 128*1024*1024, /* 128MB */
120 256*1024*1024, /* 256MB */
121 512*1024*1024, /* 512MB */
122 650*1024*1024, /* 650MB */
123 700*1024*1024, /* 700MB */
124 1024*1024*1024, /* 1GB */
125 1536*1024*1024, /* 1.5GB */
126 1792*1024*1024, /* 1.75GB */
129 static unsigned long rec_sizesplit_bytes(void)
131 return rec_size_bytes[global_settings.rec_sizesplit];
134 void settings_apply_trigger(void)
136 int start_thres, stop_thres;
137 if (global_settings.peak_meter_dbfs)
139 start_thres = global_settings.rec_start_thres_db - 1;
140 stop_thres = global_settings.rec_stop_thres_db - 1;
142 else
144 start_thres = global_settings.rec_start_thres_linear;
145 stop_thres = global_settings.rec_stop_thres_linear;
148 peak_meter_define_trigger(
149 start_thres,
150 global_settings.rec_start_duration*HZ,
151 MIN(global_settings.rec_start_duration*HZ / 2, 2*HZ),
152 stop_thres,
153 global_settings.rec_stop_postrec*HZ,
154 global_settings.rec_stop_gap*HZ
157 /* recording screen status flags */
158 enum rec_status_flags
160 RCSTAT_IN_RECSCREEN = 0x00000001,
161 RCSTAT_BEEN_IN_USB_MODE = 0x00000002,
162 RCSTAT_CREATED_DIRECTORY = 0x00000004,
163 RCSTAT_HAVE_RECORDED = 0x00000008,
166 static int rec_status = 0;
168 bool in_recording_screen(void)
170 return (rec_status & RCSTAT_IN_RECSCREEN) != 0;
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 /* as we have the ability to disable the remote, we need an alternative loop */
188 #define FOR_NB_ACTIVE_SCREENS(i) for(i = 0; i < screen_update; i++)
190 static bool update_list = false; /* (GIU) list needs updating */
192 /** File name creation **/
193 #if CONFIG_RTC == 0
194 /* current file number to assist in creating unique numbered filenames
195 without actually having to create the file on disk */
196 static int file_number = -1;
197 #endif /* CONFIG_RTC */
199 #if CONFIG_CODEC == SWCODEC
201 #define REC_FILE_ENDING(rec_format) \
202 (audio_formats[rec_format_afmt[rec_format]].ext_list)
204 #else /* CONFIG_CODEC != SWCODEC */
206 /* default record file extension for HWCODEC */
207 #define REC_FILE_ENDING(rec_format) \
208 (audio_formats[AFMT_MPA_L3].ext_list)
210 #endif /* CONFIG_CODEC == SWCODEC */
212 /* path for current file */
213 static char path_buffer[MAX_PATH];
215 /** Automatic Gain Control (AGC) **/
216 #ifdef HAVE_AGC
217 /* Timing counters:
218 * peak_time is incremented every 0.2s, every 2nd run of record screen loop.
219 * hist_time is incremented every 0.5s, display update.
220 * peak_time is the counter of the peak hold read and agc process,
221 * overflow every 13 years 8-)
223 static long peak_time = 0;
224 static long hist_time = 0;
226 static short peak_valid_mem[4];
227 #define BAL_MEM_SIZE 24
228 static short balance_mem[BAL_MEM_SIZE];
230 /* Automatic Gain Control */
231 #define AGC_MODE_SIZE 5
232 #define AGC_SAFETY_MODE 0
234 static const char* agc_preset_str[] =
235 { "Off", "S", "L", "D", "M", "V" };
236 /* "Off",
237 "Safety (clip)",
238 "Live (slow)",
239 "DJ-Set (slow)",
240 "Medium",
241 "Voice (fast)" */
242 #define AGC_CLIP 32766
243 #define AGC_PEAK 29883 /* fast gain reduction threshold -0.8dB */
244 #define AGC_HIGH 27254 /* accelerated gain reduction threshold -1.6dB */
245 #define AGC_IMG 823 /* threshold for balance control -32dB */
246 /* autogain high level thresholds (-3dB, -7dB, -4dB, -5dB, -5dB) */
247 static const short agc_th_hi[AGC_MODE_SIZE] =
248 { 23197, 14637, 21156, 18428, 18426 };
249 /* autogain low level thresholds (-14dB, -11dB, -6dB, -7dB, -8dB) */
250 static const short agc_th_lo[AGC_MODE_SIZE] =
251 { 6538, 9235, 16422, 14636, 13045 };
252 /* autogain threshold times [1/5s] or [200ms] */
253 static const short agc_tdrop[AGC_MODE_SIZE] =
254 { 900, 225, 150, 60, 8 };
255 static const short agc_trise[AGC_MODE_SIZE] =
256 { 9000, 750, 400, 150, 20 };
257 static const short agc_tbal[AGC_MODE_SIZE] =
258 { 4500, 500, 300, 100, 15 };
259 /* AGC operation */
260 static bool agc_enable = true;
261 static short agc_preset;
262 /* AGC levels */
263 static int agc_left = 0;
264 static int agc_right = 0;
265 /* AGC time since high target volume was exceeded */
266 static short agc_droptime = 0;
267 /* AGC time since volume fallen below low target */
268 static short agc_risetime = 0;
269 /* AGC balance time exceeding +/- 0.7dB */
270 static short agc_baltime = 0;
271 /* AGC maximum gain */
272 static short agc_maxgain;
273 #endif /* HAVE_AGC */
275 static void set_gain(void)
277 if(global_settings.rec_source == AUDIO_SRC_MIC)
279 audio_set_recording_gain(global_settings.rec_mic_gain,
280 0, AUDIO_GAIN_MIC);
282 else
284 /* AUDIO_SRC_LINEIN, AUDIO_SRC_FMRADIO, AUDIO_SRC_SPDIF */
285 audio_set_recording_gain(global_settings.rec_left_gain,
286 global_settings.rec_right_gain,
287 AUDIO_GAIN_LINEIN);
289 /* reset the clipping indicators */
290 peak_meter_set_clip_hold(global_settings.peak_meter_clip_hold);
291 update_list = true;
294 #ifdef HAVE_AGC
295 /* Read peak meter values & calculate balance.
296 * Returns validity of peak values.
297 * Used for automatic gain control and history diagram.
299 static bool read_peak_levels(int *peak_l, int *peak_r, int *balance)
301 peak_meter_get_peakhold(peak_l, peak_r);
302 peak_valid_mem[peak_time % 3] = *peak_l;
303 if (((peak_valid_mem[0] == peak_valid_mem[1]) &&
304 (peak_valid_mem[1] == peak_valid_mem[2])) &&
305 ((*peak_l < 32767) || storage_disk_is_active()))
306 return false;
308 if (*peak_r > *peak_l)
309 balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_l ?
310 MIN((10000 * *peak_r) / *peak_l - 10000, 15118) : 15118);
311 else
312 balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_r ?
313 MAX(10000 - (10000 * *peak_l) / *peak_r, -15118) : -15118);
314 *balance = 0;
315 int i;
316 for (i = 0; i < BAL_MEM_SIZE; i++)
317 *balance += balance_mem[i];
318 *balance = *balance / BAL_MEM_SIZE;
320 return true;
323 /* AGC helper function to check if maximum gain is reached */
324 static bool agc_gain_is_max(bool left, bool right)
326 /* range -128...+108 [0.5dB] */
327 short gain_current_l;
328 short gain_current_r;
330 if (agc_preset == 0)
331 return false;
333 switch (global_settings.rec_source)
335 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
336 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
337 gain_current_l = global_settings.rec_left_gain;
338 gain_current_r = global_settings.rec_right_gain;
339 break;
340 case AUDIO_SRC_MIC:
341 default:
342 gain_current_l = global_settings.rec_mic_gain;
343 gain_current_r = global_settings.rec_mic_gain;
346 return ((left && (gain_current_l >= agc_maxgain)) ||
347 (right && (gain_current_r >= agc_maxgain)));
350 static void change_recording_gain(bool increment, bool left, bool right)
352 int factor = (increment ? 1 : -1);
354 switch (global_settings.rec_source)
356 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
357 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
358 if (left) global_settings.rec_left_gain += factor;
359 if (right) global_settings.rec_right_gain += factor;
360 break;
361 case AUDIO_SRC_MIC:
362 global_settings.rec_mic_gain += factor;
367 * Handle automatic gain control (AGC).
368 * Change recording gain if peak_x levels are above or below
369 * target volume for specified timeouts.
371 static void auto_gain_control(int *peak_l, int *peak_r, int *balance)
373 int agc_mono;
374 short agc_mode;
375 bool increment;
377 if (*peak_l > agc_left)
378 agc_left = *peak_l;
379 else
380 agc_left -= (agc_left - *peak_l + 3) >> 2;
381 if (*peak_r > agc_right)
382 agc_right = *peak_r;
383 else
384 agc_right -= (agc_right - *peak_r + 3) >> 2;
385 agc_mono = (agc_left + agc_right) / 2;
387 agc_mode = abs(agc_preset) - 1;
388 if (agc_mode < 0) {
389 agc_enable = false;
390 return;
393 if (agc_mode != AGC_SAFETY_MODE) {
394 /* Automatic balance control - only if not in safety mode */
395 if ((agc_left > AGC_IMG) && (agc_right > AGC_IMG))
397 if (*balance < -556)
399 if (*balance > -900)
400 agc_baltime -= !(peak_time % 4); /* 0.47 - 0.75dB */
401 else if (*balance > -4125)
402 agc_baltime--; /* 0.75 - 3.00dB */
403 else if (*balance > -7579)
404 agc_baltime -= 2; /* 3.00 - 4.90dB */
405 else
406 agc_baltime -= !(peak_time % 8); /* 4.90 - inf dB */
407 if (agc_baltime > 0)
408 agc_baltime -= (peak_time % 2);
410 else if (*balance > 556)
412 if (*balance < 900)
413 agc_baltime += !(peak_time % 4);
414 else if (*balance < 4125)
415 agc_baltime++;
416 else if (*balance < 7579)
417 agc_baltime += 2;
418 else
419 agc_baltime += !(peak_time % 8);
420 if (agc_baltime < 0)
421 agc_baltime += (peak_time % 2);
424 if ((*balance * agc_baltime) < 0)
426 if (*balance < 0)
427 agc_baltime -= peak_time % 2;
428 else
429 agc_baltime += peak_time % 2;
432 increment = ((agc_risetime / 2) > agc_droptime);
434 if (agc_baltime < -agc_tbal[agc_mode])
436 if (!increment || !agc_gain_is_max(!increment, increment)) {
437 change_recording_gain(increment, !increment, increment);
438 set_gain();
440 agc_baltime = 0;
442 else if (agc_baltime > +agc_tbal[agc_mode])
444 if (!increment || !agc_gain_is_max(increment, !increment)) {
445 change_recording_gain(increment, increment, !increment);
446 set_gain();
448 agc_baltime = 0;
451 else if (!(hist_time % 4))
453 if (agc_baltime < 0)
454 agc_baltime++;
455 else
456 agc_baltime--;
460 /* Automatic gain control */
461 if ((agc_left > agc_th_hi[agc_mode]) || (agc_right > agc_th_hi[agc_mode]))
463 if ((agc_left > AGC_CLIP) || (agc_right > AGC_CLIP))
464 agc_droptime += agc_tdrop[agc_mode] /
465 (global_settings.rec_agc_cliptime + 1);
466 if (agc_left > AGC_HIGH) {
467 agc_droptime++;
468 agc_risetime=0;
469 if (agc_left > AGC_PEAK)
470 agc_droptime += 2;
472 if (agc_right > AGC_HIGH) {
473 agc_droptime++;
474 agc_risetime=0;
475 if (agc_right > AGC_PEAK)
476 agc_droptime += 2;
478 if (agc_mono > agc_th_hi[agc_mode])
479 agc_droptime++;
480 else
481 agc_droptime += !(peak_time % 2);
483 if (agc_droptime >= agc_tdrop[agc_mode])
485 change_recording_gain(false, true, true);
486 agc_droptime = 0;
487 agc_risetime = 0;
488 set_gain();
490 agc_risetime = MAX(agc_risetime - 1, 0);
492 else if (agc_mono < agc_th_lo[agc_mode])
494 if (agc_mono < (agc_th_lo[agc_mode] / 8))
495 agc_risetime += !(peak_time % 5);
496 else if (agc_mono < (agc_th_lo[agc_mode] / 2))
497 agc_risetime += 2;
498 else
499 agc_risetime++;
501 if (agc_risetime >= agc_trise[agc_mode]) {
502 if ((agc_mode != AGC_SAFETY_MODE) &&
503 (!agc_gain_is_max(true, true))) {
504 change_recording_gain(true, true, true);
505 set_gain();
507 agc_risetime = 0;
508 agc_droptime = 0;
510 agc_droptime = MAX(agc_droptime - 1, 0);
512 else if (!(peak_time % 6)) /* on target level every 1.2 sec */
514 agc_risetime = MAX(agc_risetime - 1, 0);
515 agc_droptime = MAX(agc_droptime - 1, 0);
518 #endif /* HAVE_AGC */
520 static const char* const fmtstr[] =
522 "%c%d %s", /* no decimals */
523 "%c%d.%d %s ", /* 1 decimal */
524 "%c%d.%02d %s " /* 2 decimals */
527 static char *fmt_gain(int snd, int val, char *str, int len)
529 int i, d, numdec;
530 const char *unit;
531 char sign = ' ';
533 val = sound_val2phys(snd, val);
534 if(val < 0)
536 sign = '-';
537 val = -val;
539 numdec = sound_numdecimals(snd);
540 unit = sound_unit(snd);
542 if(numdec)
544 i = val / (10*numdec);
545 d = val % (10*numdec);
546 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
548 else
549 snprintf(str, len, fmtstr[numdec], sign, val, unit);
551 return str;
554 /* the list below must match enum audio_sources in audio.h */
555 static const char* const prestr[] =
557 HAVE_MIC_IN_([AUDIO_SRC_MIC] = "R_MIC_",)
558 HAVE_LINE_REC_([AUDIO_SRC_LINEIN] = "R_LINE_",)
559 HAVE_SPDIF_IN_([AUDIO_SRC_SPDIF] = "R_SPDIF_",)
560 HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO] = "R_FM_",)
563 char *rec_create_filename(char *buffer)
565 char ext[16];
566 const char *pref = "R_";
568 /* Directory existence and writeablility should have already been
569 * verified - do not pass NULL pointers to pcmrec */
571 if((unsigned)global_settings.rec_source < AUDIO_NUM_SOURCES)
573 pref = prestr[global_settings.rec_source];
576 strcpy(buffer, global_settings.rec_directory);
578 snprintf(ext, sizeof(ext), ".%s",
579 REC_FILE_ENDING(global_settings.rec_format));
581 #if CONFIG_RTC == 0
582 return create_numbered_filename(buffer, buffer, pref, ext, 4,
583 &file_number);
584 #else
585 /* We'll wait at least up to the start of the next second so no duplicate
586 names are created */
587 return create_datetime_filename(buffer, buffer, pref, ext, true);
588 #endif
591 #if CONFIG_RTC == 0
592 /* Hit disk to get a starting filename for the type */
593 static void rec_init_filename(void)
595 file_number = -1;
596 rec_create_filename(path_buffer);
597 file_number--;
599 #endif
601 int rec_create_directory(void)
603 int rc = 0;
604 const char * const folder = global_settings.rec_directory;
606 if (strcmp(folder, "/") && !dir_exists(folder))
608 rc = mkdir(folder);
610 if(rc < 0)
612 while (action_userabort(HZ) == false)
614 splashf(0, "%s %s",
615 str(LANG_REC_DIR_NOT_WRITABLE),
616 str(LANG_OFF_ABORT));
619 else
621 rec_status |= RCSTAT_CREATED_DIRECTORY;
622 rc = 1;
626 return rc;
629 void rec_init_recording_options(struct audio_recording_options *options)
631 options->rec_source = global_settings.rec_source;
632 options->rec_frequency = global_settings.rec_frequency;
633 options->rec_channels = global_settings.rec_channels;
634 options->rec_prerecord_time = global_settings.rec_prerecord_time;
635 #if CONFIG_CODEC == SWCODEC
636 options->rec_mono_mode = global_settings.rec_mono_mode;
637 options->rec_source_flags = 0;
638 options->enc_config.rec_format = global_settings.rec_format;
639 global_to_encoder_config(&options->enc_config);
640 #else
641 options->rec_quality = global_settings.rec_quality;
642 options->rec_editable = global_settings.rec_editable;
643 #endif
646 #if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
647 void rec_set_source(int source, unsigned flags)
649 /* Set audio input source, power up/down devices */
650 audio_set_input_source(source, flags);
652 /* Set peakmeters for recording or reset to playback */
653 peak_meter_playback((flags & SRCF_RECORDING) == 0);
654 peak_meter_enabled = true;
656 #endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
658 void rec_set_recording_options(struct audio_recording_options *options)
660 #if CONFIG_CODEC != SWCODEC
661 if (global_settings.rec_prerecord_time)
663 talk_buffer_steal(); /* will use the mp3 buffer */
665 #else /* == SWCODEC */
666 rec_set_source(options->rec_source,
667 options->rec_source_flags | SRCF_RECORDING);
668 #endif /* CONFIG_CODEC != SWCODEC */
670 audio_set_recording_options(options);
673 void rec_command(enum recording_command cmd)
675 switch(cmd)
677 case RECORDING_CMD_STOP_SHUTDOWN:
678 pm_activate_clipcount(false);
679 audio_stop_recording();
680 #if CONFIG_CODEC == SWCODEC
681 audio_close_recording();
682 #endif
683 sys_poweroff();
684 break;
685 case RECORDING_CMD_STOP:
686 pm_activate_clipcount(false);
687 audio_stop_recording();
688 break;
689 case RECORDING_CMD_START:
690 /* steal mp3 buffer, create unique filename and start recording */
691 pm_reset_clipcount();
692 pm_activate_clipcount(true);
693 #if CONFIG_CODEC != SWCODEC
694 talk_buffer_steal(); /* we use the mp3 buffer */
695 #endif
696 audio_record(rec_create_filename(path_buffer));
697 break;
698 case RECORDING_CMD_START_NEWFILE:
699 /* create unique filename and start recording*/
700 pm_reset_clipcount();
701 pm_activate_clipcount(true); /* just to be sure */
702 audio_new_file(rec_create_filename(path_buffer));
703 break;
704 case RECORDING_CMD_PAUSE:
705 pm_activate_clipcount(false);
706 audio_pause_recording();
707 break;
708 case RECORDING_CMD_RESUME:
709 pm_activate_clipcount(true);
710 audio_resume_recording();
711 break;
713 update_list = true;
716 /* used in trigger_listerner and recording_screen */
717 static unsigned int last_seconds = 0;
720 * Callback function so that the peak meter code can send an event
721 * to this application. This function can be passed to
722 * peak_meter_set_trigger_listener in order to activate the trigger.
724 static void trigger_listener(int trigger_status)
726 switch (trigger_status)
728 case TRIG_GO:
729 if(!(audio_status() & AUDIO_STATUS_RECORD))
731 rec_status |= RCSTAT_HAVE_RECORDED;
732 rec_command(RECORDING_CMD_START);
733 #if CONFIG_CODEC != SWCODEC
734 /* give control to mpeg thread so that it can start
735 recording */
736 yield(); yield(); yield();
737 #endif
740 /* if we're already recording this is a retrigger */
741 else
743 if((audio_status() & AUDIO_STATUS_PAUSE) &&
744 (global_settings.rec_trigger_type == TRIG_TYPE_PAUSE))
746 rec_command(RECORDING_CMD_RESUME);
748 /* New file on trig start*/
749 else if (global_settings.rec_trigger_type != TRIG_TYPE_NEW_FILE)
751 rec_command(RECORDING_CMD_START_NEWFILE);
752 /* tell recording_screen to reset the time */
753 last_seconds = 0;
756 break;
758 /* A _change_ to TRIG_READY means the current recording has stopped */
759 case TRIG_READY:
760 if(audio_status() & AUDIO_STATUS_RECORD)
762 switch(global_settings.rec_trigger_type)
764 case TRIG_TYPE_STOP: /* Stop */
765 rec_command(RECORDING_CMD_STOP);
766 break;
768 case TRIG_TYPE_PAUSE: /* Pause */
769 rec_command(RECORDING_CMD_PAUSE);
770 break;
772 case TRIG_TYPE_NEW_FILE: /* New file on trig stop*/
773 rec_command(RECORDING_CMD_START_NEWFILE);
774 /* tell recording_screen to reset the time */
775 last_seconds = 0;
776 break;
778 case 3: /* Stop and shutdown */
779 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
780 break;
783 if (global_settings.rec_trigger_mode != TRIG_MODE_REARM)
785 peak_meter_set_trigger_listener(NULL);
786 peak_meter_trigger(false);
789 break;
793 /* Stuff for drawing the screen */
795 enum rec_list_items_stereo {
796 ITEM_VOLUME = 0,
797 ITEM_GAIN = 1,
798 ITEM_GAIN_L = 2,
799 ITEM_GAIN_R = 3,
800 #ifdef HAVE_AGC
801 ITEM_AGC_MODE = 4,
802 ITEM_AGC_MAXDB = 5,
803 ITEM_FILENAME = 7,
804 ITEM_COUNT = 7,
805 #else
806 ITEM_FILENAME = 7,
807 ITEM_COUNT = 5,
808 #endif
811 enum rec_list_items_mono {
812 ITEM_VOLUME_M = 0,
813 ITEM_GAIN_M = 1,
814 #ifdef HAVE_AGC
815 ITEM_AGC_MODE_M = 4,
816 ITEM_AGC_MAXDB_M = 5,
817 ITEM_FILENAME_M = 7,
818 ITEM_COUNT_M = 5,
819 #else
820 ITEM_FILENAME_M = 7,
821 ITEM_COUNT_M = 3,
822 #endif
825 #ifdef HAVE_SPDIF_REC
826 enum rec_list_items_spdif {
827 ITEM_VOLUME_D = 0,
828 #if CONFIG_CODEC == SWCODEC
829 ITEM_SAMPLERATE_D = 6,
830 ITEM_FILENAME_D = 7,
831 ITEM_COUNT_D = 3,
832 #else
833 ITEM_FILENAME_D = 7,
834 ITEM_COUNT_D = 2,
835 #endif
837 #endif
839 static int listid_to_enum[ITEM_COUNT];
841 static char * reclist_get_name(int selected_item, void * data,
842 char * buffer, size_t buffer_len)
844 char buf2[32];
845 #ifdef HAVE_AGC
846 char buf3[32];
847 #endif
848 data = data; /* not used */
849 if(selected_item >= ITEM_COUNT)
850 return "";
852 switch (listid_to_enum[selected_item])
854 case ITEM_VOLUME:
855 snprintf(buffer, buffer_len, "%s: %s", str(LANG_VOLUME),
856 fmt_gain(SOUND_VOLUME,
857 global_settings.volume,
858 buf2, sizeof(buf2)));
859 break;
860 case ITEM_GAIN:
861 if(global_settings.rec_source == AUDIO_SRC_MIC)
863 /* Draw MIC recording gain */
864 snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
865 fmt_gain(SOUND_MIC_GAIN,
866 global_settings.rec_mic_gain,
867 buf2, sizeof(buf2)));
869 else
871 int avg_gain = (global_settings.rec_left_gain +
872 global_settings.rec_right_gain) / 2;
873 snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
874 fmt_gain(SOUND_LEFT_GAIN,
875 avg_gain,
876 buf2, sizeof(buf2)));
878 break;
879 case ITEM_GAIN_L:
880 snprintf(buffer, buffer_len, "%s: %s",
881 str(LANG_GAIN_LEFT),
882 fmt_gain(SOUND_LEFT_GAIN,
883 global_settings.rec_left_gain,
884 buf2, sizeof(buf2)));
885 break;
886 case ITEM_GAIN_R:
887 snprintf(buffer, buffer_len, "%s: %s",
888 str(LANG_GAIN_RIGHT),
889 fmt_gain(SOUND_RIGHT_GAIN,
890 global_settings.rec_right_gain,
891 buf2, sizeof(buf2)));
892 break;
893 #ifdef HAVE_AGC
894 case ITEM_AGC_MODE:
895 snprintf(buffer, buffer_len, "%s: %s",
896 str(LANG_RECORDING_AGC_PRESET),
897 agc_preset_str[agc_preset]);
898 break;
899 case ITEM_AGC_MAXDB:
900 if (agc_preset == 0)
901 snprintf(buffer, buffer_len, "%s: %s",
902 str(LANG_RECORDING_AGC_MAXGAIN),
903 fmt_gain(SOUND_LEFT_GAIN,
904 agc_maxgain, buf2, sizeof(buf2)));
905 else if (global_settings.rec_source == AUDIO_SRC_MIC)
906 snprintf(buffer, buffer_len, "%s: %s (%s)",
907 str(LANG_RECORDING_AGC_MAXGAIN),
908 fmt_gain(SOUND_MIC_GAIN,
909 agc_maxgain, buf2, sizeof(buf2)),
910 fmt_gain(SOUND_MIC_GAIN,
911 agc_maxgain - global_settings.rec_mic_gain,
912 buf3, sizeof(buf3)));
913 else
914 snprintf(buffer, buffer_len, "%s: %s (%s)",
915 str(LANG_RECORDING_AGC_MAXGAIN),
916 fmt_gain(SOUND_LEFT_GAIN,
917 agc_maxgain, buf2, sizeof(buf2)),
918 fmt_gain(SOUND_LEFT_GAIN,
919 agc_maxgain -
920 (global_settings.rec_left_gain +
921 global_settings.rec_right_gain)/2,
922 buf3, sizeof(buf3)));
923 break;
924 #endif
925 #if CONFIG_CODEC == SWCODEC
926 #ifdef HAVE_SPDIF_REC
927 case ITEM_SAMPLERATE_D:
928 snprintf(buffer, buffer_len, "%s: %d",
929 str(LANG_RECORDING_FREQUENCY),
930 pcm_rec_sample_rate());
931 break;
932 #endif
933 #endif
934 case ITEM_FILENAME:
936 if(audio_status() & AUDIO_STATUS_RECORD)
938 size_t tot_len = strlen(path_buffer) +
939 strlen(str(LANG_RECORDING_FILENAME)) + 1;
940 if(tot_len > buffer_len)
942 snprintf(buffer, buffer_len, "%s %s",
943 str(LANG_RECORDING_FILENAME),
944 path_buffer + tot_len - buffer_len);
946 else
948 snprintf(buffer, buffer_len, "%s %s",
949 str(LANG_RECORDING_FILENAME), path_buffer);
952 else
954 strncpy(buffer, str(LANG_RECORDING_FILENAME), buffer_len);
956 break;
958 default:
959 return "";
961 return buffer;
965 bool recording_start_automatic = false;
967 bool recording_screen(bool no_source)
969 int button;
970 int done = -1; /* negative to re-init, positive to quit, zero to run */
971 char buf[32]; /* for preparing strings */
972 char buf2[32]; /* for preparing strings */
973 int w, h; /* character width/height */
974 int update_countdown = 0; /* refresh counter */
975 unsigned int seconds;
976 int hours, minutes;
977 int audio_stat = 0; /* status of the audio system */
978 int last_audio_stat = -1; /* previous status so we can act on changes */
979 struct viewport vp_list[NB_SCREENS], vp_top[NB_SCREENS]; /* the viewports */
981 #if CONFIG_CODEC == SWCODEC
982 int warning_counter = 0;
983 #define WARNING_PERIOD 7
984 #endif
986 #if CONFIG_CODEC == SWCODEC
987 #ifdef HAVE_SPDIF_REC
988 unsigned long prev_sample_rate = 0;
989 #endif
990 #endif
992 #ifdef HAVE_FMRADIO_REC
993 /* Radio is left on if:
994 * 1) Is was on at the start and the initial source is FM Radio
995 * 2) 1) and the source was never changed to something else
997 int radio_status = (global_settings.rec_source != AUDIO_SRC_FMRADIO) ?
998 FMRADIO_OFF : get_radio_status();
999 #endif
1000 #if (CONFIG_LED == LED_REAL)
1001 bool led_state = false;
1002 int led_countdown = 2;
1003 #endif
1004 #ifdef HAVE_AGC
1005 bool peak_read = false;
1006 bool peak_valid = false;
1007 int peak_l, peak_r;
1008 int balance = 0;
1009 #endif
1010 int i;
1011 int pm_x[NB_SCREENS]; /* peakmeter (and trigger bar) x pos */
1012 int pm_y[NB_SCREENS]; /* peakmeter y pos */
1013 int pm_h[NB_SCREENS]; /* peakmeter height */
1014 int trig_ypos[NB_SCREENS]; /* trigger bar y pos */
1015 int trig_width[NB_SCREENS]; /* trigger bar width */
1016 bool compact_view[NB_SCREENS]; /* tweak layout tiny screens / big fonts */
1018 struct gui_synclist lists; /* the list in the bottom vp */
1019 #ifdef HAVE_FMRADIO_REC
1020 int prev_rec_source = global_settings.rec_source; /* detect source change */
1021 #endif
1023 #if CONFIG_TUNER
1024 bool statusbar = global_settings.statusbar;
1025 global_status.statusbar_forced = statusbar?0:1;
1026 global_settings.statusbar = true;
1027 gui_syncstatusbar_draw(&statusbars,true);
1028 #endif
1030 static const unsigned char *byte_units[] = {
1031 ID2P(LANG_BYTE),
1032 ID2P(LANG_KILOBYTE),
1033 ID2P(LANG_MEGABYTE),
1034 ID2P(LANG_GIGABYTE)
1037 struct audio_recording_options rec_options;
1038 rec_status = RCSTAT_IN_RECSCREEN;
1040 #if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
1041 && !defined(SIMULATOR)
1042 ata_set_led_enabled(false);
1043 #endif
1045 #if CONFIG_CODEC == SWCODEC
1046 /* recording_menu gets messed up: so prevent manus talking */
1047 talk_disable(true);
1048 /* audio_init_recording stops anything playing when it takes the audio
1049 buffer */
1050 #else
1051 /* Yes, we use the D/A for monitoring */
1052 peak_meter_enabled = true;
1053 peak_meter_playback(true);
1054 #endif
1056 #ifdef HAVE_AGC
1057 peak_meter_get_peakhold(&peak_l, &peak_r);
1058 #endif
1060 pm_reset_clipcount();
1061 pm_activate_clipcount(false);
1062 settings_apply_trigger();
1064 #ifdef HAVE_AGC
1065 agc_preset_str[0] = str(LANG_OFF);
1066 agc_preset_str[1] = str(LANG_AGC_SAFETY);
1067 agc_preset_str[2] = str(LANG_AGC_LIVE);
1068 agc_preset_str[3] = str(LANG_AGC_DJSET);
1069 agc_preset_str[4] = str(LANG_AGC_MEDIUM);
1070 agc_preset_str[5] = str(LANG_AGC_VOICE);
1071 #endif /* HAVE_AGC */
1073 #if CONFIG_CODEC == SWCODEC
1074 audio_close_recording();
1075 #endif
1076 audio_init_recording(0);
1077 sound_set_volume(global_settings.volume);
1079 #if CONFIG_RTC == 0
1080 /* Create new filename for recording start */
1081 rec_init_filename();
1082 #endif
1084 /* viewport init and calculations that only needs to be done once */
1085 FOR_NB_SCREENS(i)
1087 struct viewport *v;
1088 /* top vp, 4 lines, force sys font if total screen < 6 lines
1089 NOTE: one could limit the list to 1 line and get away with 5 lines */
1090 v = &vp_top[i];
1091 viewport_set_defaults(v, i); /*already takes care of statusbar*/
1092 if (viewport_get_nb_lines(v) < 4)
1094 /* compact needs 4 lines total */
1095 v->font = FONT_SYSFIXED;
1096 compact_view[i] = false;
1098 else
1100 if (viewport_get_nb_lines(v) < (4+2)) /*top=4,list=2*/
1101 compact_view[i] = true;
1102 else
1103 compact_view[i] = false;
1105 v->height = (font_get(v->font)->height)*(compact_view[i] ? 3 : 4);
1107 /* list section, rest of the screen */
1108 v = &vp_list[i];
1109 viewport_set_defaults(v, i);
1110 v->font = vp_top[i].font;
1111 v->y = vp_top[i].y + vp_top[i].height;
1112 v->height = screens[i].lcdheight - v->y; /* the rest */
1113 screens[i].set_viewport(&vp_top[i]); /* req for next calls */
1115 screens[i].getstringsize("W", &w, &h);
1116 pm_y[i] = font_get(vp_top[i].font)->height * 2;
1117 trig_ypos[i] = font_get(vp_top[i].font)->height * 3;
1118 if(compact_view[i])
1119 trig_ypos[i] -= (font_get(vp_top[i].font)->height)/2;
1122 /* init the bottom list */
1123 gui_synclist_init(&lists, reclist_get_name, NULL, false, 1, vp_list);
1124 gui_synclist_set_title(&lists, NULL, Icon_NOICON);
1126 /* start of the loop: we stay in this loop until user quits recscreen */
1127 while(done <= 0)
1129 if(done < 0)
1131 /* request to re-init stuff, done after settings screen */
1132 done = 0;
1133 #ifdef HAVE_FMRADIO_REC
1134 /* If input changes away from FM Radio,
1135 radio will remain off when recording screen closes. */
1136 if (global_settings.rec_source != prev_rec_source
1137 && prev_rec_source == AUDIO_SRC_FMRADIO)
1138 radio_status = FMRADIO_OFF;
1139 prev_rec_source = global_settings.rec_source;
1140 #endif
1142 FOR_NB_SCREENS(i)
1144 pm_x[i] = 0;
1145 if(global_settings.peak_meter_clipcounter)
1147 int clipwidth = 0;
1148 screens[i].getstringsize(str(LANG_PM_CLIPCOUNT),
1149 &clipwidth, &h); /* h is same */
1150 pm_x[i] = clipwidth+1;
1152 if(global_settings.rec_trigger_mode == TRIG_MODE_OFF)
1153 pm_h[i] = font_get(vp_top[i].font)->height * 2;
1154 else
1155 pm_h[i] = font_get(vp_top[i].font)->height;
1156 if(compact_view[i])
1157 pm_h[i] /= 2;
1158 trig_width[i] = vp_top[i].width - pm_x[i];
1159 screens[i].clear_display();
1160 screens[i].update();
1163 #if CONFIG_CODEC == SWCODEC
1164 audio_close_recording();
1165 audio_init_recording(0);
1166 #endif
1168 rec_init_recording_options(&rec_options);
1169 rec_set_recording_options(&rec_options);
1171 if(rec_create_directory() < 0)
1173 rec_status = 0;
1174 goto rec_abort;
1177 #if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
1178 /* If format changed, a new number is required */
1179 rec_init_filename();
1180 #endif
1182 #ifdef HAVE_AGC
1183 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1184 agc_preset = global_settings.rec_agc_preset_mic;
1185 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1187 else {
1188 agc_preset = global_settings.rec_agc_preset_line;
1189 agc_maxgain = global_settings.rec_agc_maxgain_line;
1191 #endif
1193 set_gain();
1194 update_countdown = 0; /* Update immediately */
1196 /* populate translation table for list id -> enum */
1197 #ifdef HAVE_SPDIF_REC
1198 if(global_settings.rec_source == AUDIO_SRC_SPDIF)
1200 listid_to_enum[0] = ITEM_VOLUME_D;
1201 #if CONFIG_CODEC == SWCODEC
1202 listid_to_enum[1] = ITEM_SAMPLERATE_D;
1203 listid_to_enum[2] = ITEM_FILENAME_D;
1204 #else
1205 listid_to_enum[1] = ITEM_FILENAME_D;
1206 #endif
1208 gui_synclist_set_nb_items(&lists, ITEM_COUNT_D); /* spdif */
1210 else
1211 #endif
1212 if((global_settings.rec_source == AUDIO_SRC_MIC) ||
1213 (global_settings.rec_channels == 1))
1215 listid_to_enum[0] = ITEM_VOLUME_M;
1216 listid_to_enum[1] = ITEM_GAIN_M;
1217 #ifdef HAVE_AGC
1218 listid_to_enum[2] = ITEM_AGC_MODE_M;
1219 listid_to_enum[3] = ITEM_AGC_MAXDB_M;
1220 listid_to_enum[4] = ITEM_FILENAME_M;
1221 #else
1222 listid_to_enum[2] = ITEM_FILENAME_M;
1223 #endif
1224 gui_synclist_set_nb_items(&lists, ITEM_COUNT_M); /* mono */
1226 else
1228 listid_to_enum[0] = ITEM_VOLUME;
1229 listid_to_enum[1] = ITEM_GAIN;
1230 listid_to_enum[2] = ITEM_GAIN_L;
1231 listid_to_enum[3] = ITEM_GAIN_R;
1232 #ifdef HAVE_AGC
1233 listid_to_enum[4] = ITEM_AGC_MODE;
1234 listid_to_enum[5] = ITEM_AGC_MAXDB;
1235 listid_to_enum[6] = ITEM_FILENAME;
1236 #else
1237 listid_to_enum[4] = ITEM_FILENAME;
1238 #endif
1239 gui_synclist_set_nb_items(&lists, ITEM_COUNT); /* stereo */
1242 gui_synclist_draw(&lists);
1243 } /* if(done < 0) */
1245 audio_stat = audio_status();
1247 #if (CONFIG_LED == LED_REAL)
1250 * Flash the LED while waiting to record. Turn it on while
1251 * recording.
1253 if(audio_stat & AUDIO_STATUS_RECORD)
1255 if (audio_stat & AUDIO_STATUS_PAUSE)
1257 if (--led_countdown <= 0)
1259 led_state = !led_state;
1260 led(led_state);
1261 led_countdown = 2;
1264 else
1266 /* trigger is on in status TRIG_READY (no check needed) */
1267 led(true);
1270 else
1272 int trig_stat = peak_meter_trigger_status();
1274 * other trigger stati than trig_off and trig_steady
1275 * already imply that we are recording.
1277 if (trig_stat == TRIG_STEADY)
1279 if (--led_countdown <= 0)
1281 led_state = !led_state;
1282 led(led_state);
1283 led_countdown = 2;
1286 else
1288 /* trigger is on in status TRIG_READY (no check needed) */
1289 led(false);
1292 #endif /* CONFIG_LED */
1294 /* first set current vp - stays like this for drawing that follows */
1295 FOR_NB_SCREENS(i)
1296 screens[i].set_viewport(&vp_top[i]);
1298 /* Wait for a button a while (HZ/10) drawing the peak meter */
1299 button = peak_meter_draw_get_btn(CONTEXT_RECSCREEN,
1300 pm_x, pm_y, pm_h,
1301 screen_update);
1303 if (last_audio_stat != audio_stat)
1305 if (audio_stat & AUDIO_STATUS_RECORD)
1307 rec_status |= RCSTAT_HAVE_RECORDED;
1309 last_audio_stat = audio_stat;
1310 update_list = true;
1313 if (recording_start_automatic)
1315 /* simulate a button press */
1316 button = ACTION_REC_PAUSE;
1317 recording_start_automatic = false;
1320 /* let list handle the button */
1321 gui_synclist_do_button(&lists, &button, LIST_WRAP_UNLESS_HELD);
1323 /* list code changes active viewport - change it back */
1324 FOR_NB_SCREENS(i)
1325 screens[i].set_viewport(&vp_top[i]);
1327 switch(button)
1329 case ACTION_SETTINGS_INC:
1330 case ACTION_SETTINGS_INCREPEAT:
1331 switch (listid_to_enum[gui_synclist_get_sel_pos(&lists)])
1333 case ITEM_VOLUME:
1334 global_settings.volume++;
1335 setvol();
1336 break;
1337 case ITEM_GAIN:
1338 if(global_settings.rec_source == AUDIO_SRC_MIC)
1340 if(global_settings.rec_mic_gain <
1341 sound_max(SOUND_MIC_GAIN))
1342 global_settings.rec_mic_gain++;
1344 else
1346 if(global_settings.rec_left_gain <
1347 sound_max(SOUND_LEFT_GAIN))
1348 global_settings.rec_left_gain++;
1349 if(global_settings.rec_right_gain <
1350 sound_max(SOUND_RIGHT_GAIN))
1351 global_settings.rec_right_gain++;
1353 break;
1354 case ITEM_GAIN_L:
1355 if(global_settings.rec_left_gain <
1356 sound_max(SOUND_LEFT_GAIN))
1357 global_settings.rec_left_gain++;
1358 break;
1359 case ITEM_GAIN_R:
1360 if(global_settings.rec_right_gain <
1361 sound_max(SOUND_RIGHT_GAIN))
1362 global_settings.rec_right_gain++;
1363 break;
1364 #ifdef HAVE_AGC
1365 case ITEM_AGC_MODE:
1366 agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE);
1367 agc_enable = (agc_preset != 0);
1368 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1369 global_settings.rec_agc_preset_mic = agc_preset;
1370 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1371 } else {
1372 global_settings.rec_agc_preset_line = agc_preset;
1373 agc_maxgain = global_settings.rec_agc_maxgain_line;
1375 break;
1376 case ITEM_AGC_MAXDB:
1377 if (global_settings.rec_source == AUDIO_SRC_MIC)
1379 agc_maxgain = MIN(agc_maxgain + 1,
1380 sound_max(SOUND_MIC_GAIN));
1381 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1383 else
1385 agc_maxgain = MIN(agc_maxgain + 1,
1386 sound_max(SOUND_LEFT_GAIN));
1387 global_settings.rec_agc_maxgain_line = agc_maxgain;
1389 break;
1390 #endif /* HAVE_AGC */
1392 set_gain();
1393 update_countdown = 0; /* Update immediately */
1394 break;
1395 case ACTION_SETTINGS_DEC:
1396 case ACTION_SETTINGS_DECREPEAT:
1397 switch (listid_to_enum[gui_synclist_get_sel_pos(&lists)])
1399 case ITEM_VOLUME:
1400 global_settings.volume--;
1401 setvol();
1402 break;
1403 case ITEM_GAIN:
1404 if(global_settings.rec_source == AUDIO_SRC_MIC)
1406 if(global_settings.rec_mic_gain >
1407 sound_min(SOUND_MIC_GAIN))
1408 global_settings.rec_mic_gain--;
1410 else
1412 if(global_settings.rec_left_gain >
1413 sound_min(SOUND_LEFT_GAIN))
1414 global_settings.rec_left_gain--;
1415 if(global_settings.rec_right_gain >
1416 sound_min(SOUND_RIGHT_GAIN))
1417 global_settings.rec_right_gain--;
1419 break;
1420 case ITEM_GAIN_L:
1421 if(global_settings.rec_left_gain >
1422 sound_min(SOUND_LEFT_GAIN))
1423 global_settings.rec_left_gain--;
1424 break;
1425 case ITEM_GAIN_R:
1426 if(global_settings.rec_right_gain >
1427 sound_min(SOUND_RIGHT_GAIN))
1428 global_settings.rec_right_gain--;
1429 break;
1430 #ifdef HAVE_AGC
1431 case ITEM_AGC_MODE:
1432 agc_preset = MAX(agc_preset - 1, 0);
1433 agc_enable = (agc_preset != 0);
1434 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1435 global_settings.rec_agc_preset_mic = agc_preset;
1436 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1437 } else {
1438 global_settings.rec_agc_preset_line = agc_preset;
1439 agc_maxgain = global_settings.rec_agc_maxgain_line;
1441 break;
1442 case ITEM_AGC_MAXDB:
1443 if (global_settings.rec_source == AUDIO_SRC_MIC)
1445 agc_maxgain = MAX(agc_maxgain - 1,
1446 sound_min(SOUND_MIC_GAIN));
1447 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1449 else
1451 agc_maxgain = MAX(agc_maxgain - 1,
1452 sound_min(SOUND_LEFT_GAIN));
1453 global_settings.rec_agc_maxgain_line = agc_maxgain;
1455 break;
1456 #endif /* HAVE_AGC */
1458 set_gain();
1459 update_countdown = 0; /* Update immediately */
1460 break;
1461 case ACTION_STD_CANCEL:
1462 /* turn off the trigger */
1463 peak_meter_trigger(false);
1464 peak_meter_set_trigger_listener(NULL);
1466 if(audio_stat & AUDIO_STATUS_RECORD)
1468 rec_command(RECORDING_CMD_STOP);
1470 else
1472 #if CONFIG_CODEC != SWCODEC
1473 peak_meter_playback(true);
1474 peak_meter_enabled = false;
1475 #endif
1476 done = 1;
1478 update_countdown = 0; /* Update immediately */
1479 break;
1480 #ifdef HAVE_REMOTE_LCD
1481 case ACTION_REC_LCD:
1482 /* this feature exists for some h1x0/h3x0 targets that suffer
1483 from noise caused by remote LCD updates
1484 NOTE 1: this will leave the list on the remote
1485 NOTE 2: to be replaced by a global LCD_off() routine */
1486 if(remote_display_on)
1488 /* switch to single screen, leave message on remote */
1489 screen_update = 1;
1490 screens[1].clear_viewport();
1491 screens[1].puts(0, 0, str(LANG_REMOTE_LCD_OFF));
1492 screens[1].puts(0, 1, str(LANG_REMOTE_LCD_ON));
1493 screens[1].update_viewport();
1495 else
1497 /* remote switched on again */
1498 update_list = true;
1499 screen_update = NB_SCREENS;
1501 remote_display_on = !remote_display_on; /* toggle */
1502 update_countdown = 0; /* Update immediately */
1503 break;
1504 #endif
1505 case ACTION_REC_PAUSE:
1506 case ACTION_REC_NEWFILE:
1507 /* Only act if the mpeg is stopped */
1508 if(!(audio_stat & AUDIO_STATUS_RECORD))
1510 /* is this manual or triggered recording? */
1511 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1512 (peak_meter_trigger_status() != TRIG_OFF))
1514 /* manual recording */
1515 rec_status |= RCSTAT_HAVE_RECORDED;
1516 rec_command(RECORDING_CMD_START);
1517 last_seconds = 0;
1518 if (global_settings.talk_menu)
1520 /* no voice possible here, but a beep */
1521 audio_beep(HZ/2); /* longer beep on start */
1524 /* this is triggered recording */
1525 else
1527 /* we don't start recording now, but enable the
1528 trigger and let the callback function
1529 trigger_listener control when the recording starts */
1530 peak_meter_trigger(true);
1531 peak_meter_set_trigger_listener(&trigger_listener);
1534 else
1536 /*if new file button pressed, start new file */
1537 if (button == ACTION_REC_NEWFILE)
1539 rec_command(RECORDING_CMD_START_NEWFILE);
1540 last_seconds = 0;
1542 else
1543 /* if pause button pressed, pause or resume */
1545 if(audio_stat & AUDIO_STATUS_PAUSE)
1547 rec_command(RECORDING_CMD_RESUME);
1548 if (global_settings.talk_menu)
1550 /* no voice possible here, but a beep */
1551 audio_beep(HZ/4); /* short beep on resume */
1554 else
1556 rec_command(RECORDING_CMD_PAUSE);
1560 update_countdown = 0; /* Update immediately */
1561 break;
1562 case ACTION_STD_MENU:
1563 #if CONFIG_CODEC == SWCODEC
1564 if(!(audio_stat & AUDIO_STATUS_RECORD))
1565 #else
1566 if(audio_stat != AUDIO_STATUS_RECORD)
1567 #endif
1569 #if (CONFIG_LED == LED_REAL)
1570 /* led is restored at begin of loop / end of function */
1571 led(false);
1572 #endif
1573 if (recording_menu(no_source))
1575 done = 1;
1576 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1577 #ifdef HAVE_FMRADIO_REC
1578 radio_status = FMRADIO_OFF;
1579 #endif
1581 else
1583 done = -1;
1584 /* the init is now done at the beginning of the loop */
1587 break;
1589 #if CONFIG_KEYPAD == RECORDER_PAD
1590 case ACTION_REC_F2:
1591 if(audio_stat != AUDIO_STATUS_RECORD)
1593 #if (CONFIG_LED == LED_REAL)
1594 /* led is restored at begin of loop / end of function */
1595 led(false);
1596 #endif
1597 if (f2_rec_screen())
1599 rec_status |= RCSTAT_HAVE_RECORDED;
1600 done = true;
1602 else
1603 update_countdown = 0; /* Update immediately */
1605 break;
1607 case ACTION_REC_F3:
1608 if(audio_stat & AUDIO_STATUS_RECORD)
1610 rec_command(RECORDING_CMD_START_NEWFILE);
1611 last_seconds = 0;
1613 else
1615 #if (CONFIG_LED == LED_REAL)
1616 /* led is restored at begin of loop / end of function */
1617 led(false);
1618 #endif
1619 if (f3_rec_screen())
1621 rec_status |= RCSTAT_HAVE_RECORDED;
1622 done = true;
1624 else
1625 update_countdown = 0; /* Update immediately */
1627 break;
1628 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
1630 case SYS_USB_CONNECTED:
1631 /* Only accept USB connection when not recording */
1632 if(!(audio_stat & AUDIO_STATUS_RECORD))
1634 FOR_NB_SCREENS(i)
1635 screens[i].set_viewport(NULL);
1636 default_event_handler(SYS_USB_CONNECTED);
1637 done = true;
1638 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1639 #ifdef HAVE_FMRADIO_REC
1640 radio_status = FMRADIO_OFF;
1641 #endif
1643 break;
1644 } /*switch(button)*/
1646 #ifdef HAVE_AGC
1647 peak_read = !peak_read;
1648 if (peak_read) { /* every 2nd run of loop */
1649 peak_time++;
1650 peak_valid = read_peak_levels(&peak_l, &peak_r, &balance);
1653 /* Handle AGC every 200ms when enabled and peak data is valid */
1654 if (peak_read && agc_enable && peak_valid)
1655 auto_gain_control(&peak_l, &peak_r, &balance);
1656 #endif
1658 seconds = audio_recorded_time() / HZ;
1660 /* start of vp_top drawing */
1661 if(update_countdown-- == 0 || seconds > last_seconds)
1663 unsigned int dseconds, dhours, dminutes;
1664 unsigned long num_recorded_bytes, dsize, dmb;
1666 /* we assume vp_top is the current viewport! */
1667 FOR_NB_ACTIVE_SCREENS(i)
1668 screens[i].clear_viewport();
1670 update_countdown = 5;
1671 last_seconds = seconds;
1673 dseconds = rec_timesplit_seconds();
1674 dsize = rec_sizesplit_bytes();
1675 num_recorded_bytes = audio_num_recorded_bytes();
1677 #if CONFIG_CODEC == SWCODEC
1678 if ((audio_stat & AUDIO_STATUS_WARNING)
1679 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
1681 /* Switch back and forth displaying warning on first available
1682 line to ensure visibility - the motion should also help
1683 draw attention */
1684 /* Don't use language string unless agreed upon to make this
1685 method permanent - could do something in the statusbar */
1686 snprintf(buf, sizeof(buf), "Warning: %08X",
1687 pcm_rec_get_warnings());
1689 else
1690 #endif /* CONFIG_CODEC == SWCODEC */
1691 if ((global_settings.rec_sizesplit) &&
1692 (global_settings.rec_split_method))
1694 dmb = dsize/1024/1024;
1695 snprintf(buf, sizeof(buf), "%s %dMB",
1696 str(LANG_SPLIT_SIZE), dmb);
1698 else
1700 hours = seconds / 3600;
1701 minutes = (seconds - (hours * 3600)) / 60;
1702 snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d",
1703 str(LANG_RECORDING_TIME),
1704 hours, minutes, seconds%60);
1707 FOR_NB_ACTIVE_SCREENS(i)
1708 screens[i].puts(0, 0, buf);
1710 if(audio_stat & AUDIO_STATUS_PRERECORD)
1712 snprintf(buf, sizeof(buf), "%s...",
1713 str(LANG_RECORD_PRERECORD));
1715 else
1717 /* Display the split interval if the record timesplit
1718 is active */
1719 if ((global_settings.rec_timesplit) &&
1720 !(global_settings.rec_split_method))
1722 /* Display the record timesplit interval rather
1723 than the file size if the record timer is active */
1724 dhours = dseconds / 3600;
1725 dminutes = (dseconds - (dhours * 3600)) / 60;
1726 snprintf(buf, sizeof(buf), "%s %02d:%02d",
1727 str(LANG_RECORDING_TIMESPLIT_REC),
1728 dhours, dminutes);
1730 else
1732 output_dyn_value(buf2, sizeof buf2,
1733 num_recorded_bytes,
1734 byte_units, true);
1735 snprintf(buf, sizeof(buf), "%s %s",
1736 str(LANG_RECORDING_SIZE), buf2);
1740 FOR_NB_ACTIVE_SCREENS(i)
1741 screens[i].puts(0, 1, buf);
1743 /* We will do file splitting regardless, either at the end of
1744 a split interval, or when the filesize approaches the 2GB
1745 FAT file size (compatibility) limit. */
1746 if ((audio_stat && !(global_settings.rec_split_method)
1747 && global_settings.rec_timesplit && (seconds >= dseconds))
1748 || (audio_stat && global_settings.rec_split_method
1749 && global_settings.rec_sizesplit
1750 && (num_recorded_bytes >= dsize))
1751 || (num_recorded_bytes >= MAX_FILE_SIZE))
1753 if (!(global_settings.rec_split_type)
1754 || (num_recorded_bytes >= MAX_FILE_SIZE))
1756 rec_command(RECORDING_CMD_START_NEWFILE);
1757 last_seconds = 0;
1759 else
1761 peak_meter_trigger(false);
1762 peak_meter_set_trigger_listener(NULL);
1763 if( global_settings.rec_split_type == 1)
1764 rec_command(RECORDING_CMD_STOP);
1765 else
1766 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
1768 update_countdown = 0;
1771 /* draw the clipcounter just in front of the peakmeter */
1772 if(global_settings.peak_meter_clipcounter)
1774 char clpstr[32];
1775 snprintf(clpstr, 32, "%4d", pm_get_clipcount());
1776 FOR_NB_ACTIVE_SCREENS(i)
1778 if(!compact_view[i])
1779 screens[i].puts(0, 2,str(LANG_PM_CLIPCOUNT));
1780 screens[i].puts(0, compact_view[i] ? 2 : 3, clpstr);
1784 #ifdef HAVE_AGC
1785 hist_time++;
1786 #endif
1788 /* draw the trigger status */
1789 if (peak_meter_trigger_status() != TRIG_OFF)
1791 peak_meter_draw_trig(pm_x, trig_ypos, trig_width,
1792 screen_update);
1793 FOR_NB_ACTIVE_SCREENS(i)
1794 screens[i].update_viewport_rect(pm_x[i], trig_ypos[i],
1795 trig_width[i] + 2, TRIG_HEIGHT);
1798 #ifdef HAVE_AGC
1799 if (global_settings.rec_source == AUDIO_SRC_MIC)
1801 if(agc_maxgain < (global_settings.rec_mic_gain))
1802 change_recording_gain(false, true, true);
1804 else
1806 if(agc_maxgain < (global_settings.rec_left_gain))
1807 change_recording_gain(false, true, false);
1808 if(agc_maxgain < (global_settings.rec_right_gain))
1809 change_recording_gain(false, false, true);
1811 #endif /* HAVE_AGC */
1813 #if CONFIG_CODEC == SWCODEC
1814 #ifdef HAVE_SPDIF_REC
1815 if((global_settings.rec_source == AUDIO_SRC_SPDIF) &&
1816 (prev_sample_rate != pcm_rec_sample_rate()))
1818 /* spdif samplerate changed */
1819 prev_sample_rate = pcm_rec_sample_rate();
1820 update_list = true;
1822 #endif
1823 #endif
1825 if(update_list)
1827 /* update_list is set whenever content changes */
1828 update_list = false;
1829 gui_synclist_draw(&lists);
1832 /* draw peakmeter again (check if this can be removed) */
1833 FOR_NB_ACTIVE_SCREENS(i)
1835 screens[i].set_viewport(NULL);
1836 gui_statusbar_draw(&(statusbars.statusbars[i]), true);
1837 screens[i].set_viewport(&vp_top[i]);
1838 peak_meter_screen(&screens[i], pm_x[i], pm_y[i], pm_h[i]);
1839 screens[i].update();
1841 } /* display update every second */
1843 if(audio_stat & AUDIO_STATUS_ERROR)
1845 done = true;
1847 } /* end while(!done) */
1849 audio_stat = audio_status();
1850 if (audio_stat & AUDIO_STATUS_ERROR)
1852 splash(0, str(LANG_DISK_FULL));
1853 gui_syncstatusbar_draw(&statusbars, true);
1855 FOR_NB_SCREENS(i)
1856 screens[i].update();
1858 #if CONFIG_CODEC == SWCODEC
1859 /* stop recording - some players like H10 freeze otherwise
1860 TO DO: find out why it freezes and fix properly */
1861 rec_command(RECORDING_CMD_STOP);
1862 audio_close_recording();
1863 #endif
1865 audio_error_clear();
1867 while(1)
1869 if (action_userabort(TIMEOUT_NOBLOCK))
1870 break;
1874 rec_abort:
1876 #if CONFIG_CODEC == SWCODEC
1877 rec_command(RECORDING_CMD_STOP);
1878 audio_close_recording();
1880 #ifdef HAVE_FMRADIO_REC
1881 if (radio_status != FMRADIO_OFF)
1882 /* Restore radio playback - radio_status should be unchanged if started
1883 through fm radio screen (barring usb connect) */
1884 rec_set_source(AUDIO_SRC_FMRADIO, (radio_status & FMRADIO_PAUSED) ?
1885 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
1886 else
1887 #endif
1888 /* Go back to playback mode */
1889 rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
1891 /* restore talking */
1892 talk_disable(false);
1893 #else /* !SWCODEC */
1894 audio_init_playback();
1895 #endif /* CONFIG_CODEC == SWCODEC */
1897 /* make sure the trigger is really turned off */
1898 peak_meter_trigger(false);
1899 peak_meter_set_trigger_listener(NULL);
1901 rec_status &= ~RCSTAT_IN_RECSCREEN;
1902 sound_settings_apply();
1904 FOR_NB_SCREENS(i)
1905 screens[i].setfont(FONT_UI);
1907 /* if the directory was created or recording happened, make sure the
1908 browser is updated */
1909 if (rec_status & (RCSTAT_CREATED_DIRECTORY | RCSTAT_HAVE_RECORDED))
1910 reload_directory();
1912 #if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
1913 && !defined(SIMULATOR)
1914 ata_set_led_enabled(true);
1915 #endif
1917 #if CONFIG_TUNER
1918 global_settings.statusbar = statusbar;
1919 global_status.statusbar_forced = 0;
1920 #endif
1922 settings_save();
1924 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
1925 } /* recording_screen */
1927 #if CONFIG_KEYPAD == RECORDER_PAD
1928 static bool f2_rec_screen(void)
1930 static const char* const freq_str[6] =
1932 "44.1kHz",
1933 "48kHz",
1934 "32kHz",
1935 "22.05kHz",
1936 "24kHz",
1937 "16kHz"
1940 bool exit = false;
1941 bool used = false;
1942 int w, h, i;
1943 char buf[32];
1944 int button;
1945 struct audio_recording_options rec_options;
1947 FOR_NB_SCREENS(i)
1949 screens[i].setfont(FONT_SYSFIXED);
1950 screens[i].getstringsize("A",&w,&h);
1953 while (!exit) {
1954 const char* ptr=NULL;
1956 FOR_NB_SCREENS(i)
1958 screens[i].clear_display();
1960 /* Recording quality */
1961 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
1962 str(LANG_SYSFONT_RECORDING_QUALITY));
1965 snprintf(buf, sizeof(buf), "%d", global_settings.rec_quality);
1966 FOR_NB_SCREENS(i)
1968 screens[i].putsxy(0, LCD_HEIGHT/2-h, buf);
1969 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
1970 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
1973 /* Frequency */
1974 snprintf(buf, sizeof buf, "%s:", str(LANG_SYSFONT_RECORDING_FREQUENCY));
1975 ptr = freq_str[global_settings.rec_frequency];
1976 FOR_NB_SCREENS(i)
1978 screens[i].getstringsize(buf,&w,&h);
1979 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
1980 screens[i].getstringsize(ptr, &w, &h);
1981 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
1982 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
1983 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
1986 /* Channel mode */
1987 switch ( global_settings.rec_channels ) {
1988 case 0:
1989 ptr = str(LANG_SYSFONT_CHANNEL_STEREO);
1990 break;
1992 case 1:
1993 ptr = str(LANG_SYSFONT_CHANNEL_MONO);
1994 break;
1997 FOR_NB_SCREENS(i)
1999 screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h);
2000 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
2001 str(LANG_SYSFONT_CHANNELS));
2002 screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h);
2003 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h,
2004 str(LANG_SYSFONT_MODE));
2005 screens[i].getstringsize(ptr, &w, &h);
2006 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
2007 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
2008 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
2010 screens[i].update();
2013 button = button_get(true);
2014 switch (button) {
2015 case BUTTON_LEFT:
2016 case BUTTON_F2 | BUTTON_LEFT:
2017 global_settings.rec_quality++;
2018 if(global_settings.rec_quality > 7)
2019 global_settings.rec_quality = 0;
2020 used = true;
2021 break;
2023 case BUTTON_DOWN:
2024 case BUTTON_F2 | BUTTON_DOWN:
2025 global_settings.rec_frequency++;
2026 if(global_settings.rec_frequency > 5)
2027 global_settings.rec_frequency = 0;
2028 used = true;
2029 break;
2031 case BUTTON_RIGHT:
2032 case BUTTON_F2 | BUTTON_RIGHT:
2033 global_settings.rec_channels++;
2034 if(global_settings.rec_channels > 1)
2035 global_settings.rec_channels = 0;
2036 used = true;
2037 break;
2039 case BUTTON_F2 | BUTTON_REL:
2040 if ( used )
2041 exit = true;
2042 used = true;
2043 break;
2045 case BUTTON_F2 | BUTTON_REPEAT:
2046 used = true;
2047 break;
2049 default:
2050 if(default_event_handler(button) == SYS_USB_CONNECTED)
2051 return true;
2052 break;
2056 rec_init_recording_options(&rec_options);
2057 rec_set_recording_options(&rec_options);
2059 set_gain();
2061 settings_save();
2062 FOR_NB_SCREENS(i)
2063 screens[i].setfont(FONT_UI);
2065 return false;
2068 static bool f3_rec_screen(void)
2070 bool exit = false;
2071 bool used = false;
2072 int w, h, i;
2073 int button;
2074 char *src_str[] =
2076 str(LANG_SYSFONT_RECORDING_SRC_MIC),
2077 str(LANG_SYSFONT_LINE_IN),
2078 str(LANG_SYSFONT_RECORDING_SRC_DIGITAL)
2080 struct audio_recording_options rec_options;
2082 FOR_NB_SCREENS(i)
2084 screens[i].setfont(FONT_SYSFIXED);
2085 screens[i].getstringsize("A",&w,&h);
2088 while (!exit) {
2089 char* ptr=NULL;
2090 ptr = src_str[global_settings.rec_source];
2091 FOR_NB_SCREENS(i)
2093 screens[i].clear_display();
2095 /* Recording source */
2096 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
2097 str(LANG_SYSFONT_RECORDING_SOURCE));
2099 screens[i].getstringsize(ptr, &w, &h);
2100 screens[i].putsxy(0, LCD_HEIGHT/2-h, ptr);
2101 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
2102 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
2105 /* trigger setup */
2106 ptr = str(LANG_SYSFONT_RECORD_TRIGGER);
2107 FOR_NB_SCREENS(i)
2109 screens[i].getstringsize(ptr,&w,&h);
2110 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr);
2111 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
2112 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
2114 screens[i].update();
2117 button = button_get(true);
2118 switch (button) {
2119 case BUTTON_DOWN:
2120 case BUTTON_F3 | BUTTON_DOWN:
2121 #ifndef SIMULATOR
2122 rectrigger();
2123 settings_apply_trigger();
2124 #endif
2125 exit = true;
2126 break;
2128 case BUTTON_LEFT:
2129 case BUTTON_F3 | BUTTON_LEFT:
2130 global_settings.rec_source++;
2131 if(global_settings.rec_source > AUDIO_SRC_MAX)
2132 global_settings.rec_source = 0;
2133 used = true;
2134 break;
2136 case BUTTON_F3 | BUTTON_REL:
2137 if ( used )
2138 exit = true;
2139 used = true;
2140 break;
2142 case BUTTON_F3 | BUTTON_REPEAT:
2143 used = true;
2144 break;
2146 default:
2147 if(default_event_handler(button) == SYS_USB_CONNECTED)
2148 return true;
2149 break;
2153 rec_init_recording_options(&rec_options);
2154 rec_set_recording_options(&rec_options);
2156 set_gain();
2158 settings_save();
2159 FOR_NB_SCREENS(i)
2160 screens[i].setfont(FONT_UI);
2162 return false;
2164 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
2166 #if CONFIG_CODEC == SWCODEC
2167 void audio_beep(int duration)
2169 /* dummy */
2170 (void)duration;
2173 #ifdef SIMULATOR
2174 /* stubs for recording sim */
2175 void audio_init_recording(unsigned int buffer_offset)
2177 buffer_offset = buffer_offset;
2180 void audio_close_recording(void)
2184 unsigned long pcm_rec_get_warnings(void)
2186 return 0;
2189 unsigned long pcm_rec_sample_rate(void)
2191 return 0;
2194 unsigned long audio_recorded_time(void)
2196 return 123;
2199 unsigned long audio_num_recorded_bytes(void)
2201 return 5 * 1024 * 1024;
2204 void rec_set_source(int source, unsigned flags)
2206 source = source;
2207 flags = flags;
2210 void audio_set_recording_options(struct audio_recording_options *options)
2212 options = options;
2215 void audio_set_recording_gain(int left, int right, int type)
2217 left = left;
2218 right = right;
2219 type = type;
2222 void audio_record(const char *filename)
2224 filename = filename;
2227 void audio_new_file(const char *filename)
2229 filename = filename;
2232 void audio_stop_recording(void)
2236 void audio_pause_recording(void)
2240 void audio_resume_recording(void)
2244 #endif /* #ifdef SIMULATOR */
2245 #endif /* #ifdef CONFIG_CODEC == SWCODEC */
2247 #endif /* HAVE_RECORDING */