FS#10824 - viewport/statusbar API rework.
[kugel-rb.git] / apps / recorder / recording.c
blob0d1ada73f67f9e285d7346a99b5befc5d8950091
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 "audio.h"
34 #if CONFIG_CODEC == SWCODEC
35 #include "thread.h"
36 #include "enc_config.h"
37 #if defined(HAVE_SPDIF_IN) || defined(HAVE_SPDIF_OUT)
38 #include "spdif.h"
39 #endif
40 #endif /* CONFIG_CODEC == SWCODEC */
41 #include "pcm_record.h"
42 #include "recording.h"
43 #include "mp3_playback.h"
44 #include "mas.h"
45 #include "button.h"
46 #include "kernel.h"
47 #include "settings.h"
48 #include "lang.h"
49 #include "font.h"
50 #include "icons.h"
51 #include "icon.h"
52 #include "screens.h"
53 #include "peakmeter.h"
54 #include "menu.h"
55 #include "sound_menu.h"
56 #include "timefuncs.h"
57 #include "debug.h"
58 #include "misc.h"
59 #include "tree.h"
60 #include "string.h"
61 #include "dir.h"
62 #include "errno.h"
63 #include "talk.h"
64 #include "sound.h"
65 #include "storage.h"
66 #if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
67 && !defined(SIMULATOR)
68 #include "ata.h"
69 #endif
70 #include "splash.h"
71 #include "screen_access.h"
72 #include "action.h"
73 #include "radio.h"
74 #include "viewport.h"
75 #include "list.h"
76 #include "general.h"
77 #include "appevents.h"
79 #ifdef HAVE_RECORDING
80 /* This array holds the record timer interval lengths, in seconds */
81 static const unsigned long rec_timer_seconds[] =
83 0, /* 0 means OFF */
84 5*60, /* 00:05 */
85 10*60, /* 00:10 */
86 15*60, /* 00:15 */
87 30*60, /* 00:30 */
88 60*60, /* 01:00 */
89 74*60, /* 01:14 */
90 80*60, /* 01:20 */
91 2*60*60, /* 02:00 */
92 4*60*60, /* 04:00 */
93 6*60*60, /* 06:00 */
94 8*60*60, /* 08:00 */
95 10L*60*60, /* 10:00 */
96 12L*60*60, /* 12:00 */
97 18L*60*60, /* 18:00 */
98 24L*60*60 /* 24:00 */
101 static unsigned int rec_timesplit_seconds(void)
103 return rec_timer_seconds[global_settings.rec_timesplit];
106 /* This array holds the record size interval lengths, in bytes */
107 static const unsigned long rec_size_bytes[] =
109 0, /* 0 means OFF */
110 5*1024*1024, /* 5MB */
111 10*1024*1024, /* 10MB */
112 15*1024*1024, /* 15MB */
113 32*1024*1024, /* 32MB */
114 64*1024*1024, /* 64MB */
115 75*1024*1024, /* 75MB */
116 100*1024*1024, /* 100MB */
117 128*1024*1024, /* 128MB */
118 256*1024*1024, /* 256MB */
119 512*1024*1024, /* 512MB */
120 650*1024*1024, /* 650MB */
121 700*1024*1024, /* 700MB */
122 1024*1024*1024, /* 1GB */
123 1536*1024*1024, /* 1.5GB */
124 1792*1024*1024, /* 1.75GB */
127 static unsigned long rec_sizesplit_bytes(void)
129 return rec_size_bytes[global_settings.rec_sizesplit];
132 void settings_apply_trigger(void)
134 int start_thres, stop_thres;
135 if (global_settings.peak_meter_dbfs)
137 start_thres = global_settings.rec_start_thres_db - 1;
138 stop_thres = global_settings.rec_stop_thres_db - 1;
140 else
142 start_thres = global_settings.rec_start_thres_linear;
143 stop_thres = global_settings.rec_stop_thres_linear;
146 peak_meter_define_trigger(
147 start_thres,
148 global_settings.rec_start_duration*HZ,
149 MIN(global_settings.rec_start_duration*HZ / 2, 2*HZ),
150 stop_thres,
151 global_settings.rec_stop_postrec*HZ,
152 global_settings.rec_stop_gap*HZ
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 #if CONFIG_KEYPAD == RECORDER_PAD
172 static bool f2_rec_screen(void);
173 static bool f3_rec_screen(void);
174 #endif
176 #define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */
178 #ifndef HAVE_REMOTE_LCD
179 static const int screen_update = NB_SCREENS;
180 #else
181 static int screen_update = NB_SCREENS;
182 static bool remote_display_on = true;
183 #endif
185 /* as we have the ability to disable the remote, we need an alternative loop */
186 #define FOR_NB_ACTIVE_SCREENS(i) for(i = 0; i < screen_update; i++)
188 static bool update_list = false; /* (GIU) list needs updating */
190 /** File name creation **/
191 #if CONFIG_RTC == 0
192 /* current file number to assist in creating unique numbered filenames
193 without actually having to create the file on disk */
194 static int file_number = -1;
195 #endif /* CONFIG_RTC */
197 #if CONFIG_CODEC == SWCODEC
199 #define REC_FILE_ENDING(rec_format) \
200 (audio_formats[rec_format_afmt[rec_format]].ext_list)
202 #else /* CONFIG_CODEC != SWCODEC */
204 /* default record file extension for HWCODEC */
205 #define REC_FILE_ENDING(rec_format) \
206 (audio_formats[AFMT_MPA_L3].ext_list)
208 #endif /* CONFIG_CODEC == SWCODEC */
210 /* path for current file */
211 static char path_buffer[MAX_PATH];
213 /** Automatic Gain Control (AGC) **/
214 #ifdef HAVE_AGC
215 /* Timing counters:
216 * peak_time is incremented every 0.2s, every 2nd run of record screen loop.
217 * hist_time is incremented every 0.5s, display update.
218 * peak_time is the counter of the peak hold read and agc process,
219 * overflow every 13 years 8-)
221 static long peak_time = 0;
222 static long hist_time = 0;
224 static short peak_valid_mem[4];
225 #define BAL_MEM_SIZE 24
226 static short balance_mem[BAL_MEM_SIZE];
228 /* Automatic Gain Control */
229 #define AGC_MODE_SIZE 5
230 #define AGC_SAFETY_MODE 0
232 static const char* agc_preset_str[] =
233 { "Off", "S", "L", "D", "M", "V" };
234 /* "Off",
235 "Safety (clip)",
236 "Live (slow)",
237 "DJ-Set (slow)",
238 "Medium",
239 "Voice (fast)" */
240 #define AGC_CLIP 32766
241 #define AGC_PEAK 29883 /* fast gain reduction threshold -0.8dB */
242 #define AGC_HIGH 27254 /* accelerated gain reduction threshold -1.6dB */
243 #define AGC_IMG 823 /* threshold for balance control -32dB */
244 /* autogain high level thresholds (-3dB, -7dB, -4dB, -5dB, -5dB) */
245 static const short agc_th_hi[AGC_MODE_SIZE] =
246 { 23197, 14637, 21156, 18428, 18426 };
247 /* autogain low level thresholds (-14dB, -11dB, -6dB, -7dB, -8dB) */
248 static const short agc_th_lo[AGC_MODE_SIZE] =
249 { 6538, 9235, 16422, 14636, 13045 };
250 /* autogain threshold times [1/5s] or [200ms] */
251 static const short agc_tdrop[AGC_MODE_SIZE] =
252 { 900, 225, 150, 60, 8 };
253 static const short agc_trise[AGC_MODE_SIZE] =
254 { 9000, 750, 400, 150, 20 };
255 static const short agc_tbal[AGC_MODE_SIZE] =
256 { 4500, 500, 300, 100, 15 };
257 /* AGC operation */
258 static bool agc_enable = true;
259 static short agc_preset;
260 /* AGC levels */
261 static int agc_left = 0;
262 static int agc_right = 0;
263 /* AGC time since high target volume was exceeded */
264 static short agc_droptime = 0;
265 /* AGC time since volume fallen below low target */
266 static short agc_risetime = 0;
267 /* AGC balance time exceeding +/- 0.7dB */
268 static short agc_baltime = 0;
269 /* AGC maximum gain */
270 static short agc_maxgain;
271 #endif /* HAVE_AGC */
273 static void set_gain(void)
275 #ifdef HAVE_MIC_REC
276 if(global_settings.rec_source == AUDIO_SRC_MIC)
278 audio_set_recording_gain(global_settings.rec_mic_gain,
279 0, AUDIO_GAIN_MIC);
281 else
282 #endif /* MIC */
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 #if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
336 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
337 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
338 gain_current_l = global_settings.rec_left_gain;
339 gain_current_r = global_settings.rec_right_gain;
340 break;
341 #endif /* LINE, FMRADIO */
342 #if defined(HAVE_MIC_REC)
343 case AUDIO_SRC_MIC:
344 default:
345 gain_current_l = global_settings.rec_mic_gain;
346 gain_current_r = global_settings.rec_mic_gain;
347 #endif /* MIC */
350 return ((left && (gain_current_l >= agc_maxgain)) ||
351 (right && (gain_current_r >= agc_maxgain)));
354 static void change_recording_gain(bool increment, bool left, bool right)
356 int factor = (increment ? 1 : -1);
358 switch (global_settings.rec_source)
360 #if defined(HAVE_LINE_REC) || defined(HAVE_FMRADIO_REC)
361 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
362 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
363 if (left) global_settings.rec_left_gain += factor;
364 if (right) global_settings.rec_right_gain += factor;
365 break;
366 #endif /* LINE, FMRADIO */
367 #if defined(HAVE_MIC_REC)
368 case AUDIO_SRC_MIC:
369 global_settings.rec_mic_gain += factor;
370 #endif
375 * Handle automatic gain control (AGC).
376 * Change recording gain if peak_x levels are above or below
377 * target volume for specified timeouts.
379 static void auto_gain_control(int *peak_l, int *peak_r, int *balance)
381 int agc_mono;
382 short agc_mode;
383 bool increment;
385 if (*peak_l > agc_left)
386 agc_left = *peak_l;
387 else
388 agc_left -= (agc_left - *peak_l + 3) >> 2;
389 if (*peak_r > agc_right)
390 agc_right = *peak_r;
391 else
392 agc_right -= (agc_right - *peak_r + 3) >> 2;
393 agc_mono = (agc_left + agc_right) / 2;
395 agc_mode = abs(agc_preset) - 1;
396 if (agc_mode < 0) {
397 agc_enable = false;
398 return;
401 if (agc_mode != AGC_SAFETY_MODE) {
402 /* Automatic balance control - only if not in safety mode */
403 if ((agc_left > AGC_IMG) && (agc_right > AGC_IMG))
405 if (*balance < -556)
407 if (*balance > -900)
408 agc_baltime -= !(peak_time % 4); /* 0.47 - 0.75dB */
409 else if (*balance > -4125)
410 agc_baltime--; /* 0.75 - 3.00dB */
411 else if (*balance > -7579)
412 agc_baltime -= 2; /* 3.00 - 4.90dB */
413 else
414 agc_baltime -= !(peak_time % 8); /* 4.90 - inf dB */
415 if (agc_baltime > 0)
416 agc_baltime -= (peak_time % 2);
418 else if (*balance > 556)
420 if (*balance < 900)
421 agc_baltime += !(peak_time % 4);
422 else if (*balance < 4125)
423 agc_baltime++;
424 else if (*balance < 7579)
425 agc_baltime += 2;
426 else
427 agc_baltime += !(peak_time % 8);
428 if (agc_baltime < 0)
429 agc_baltime += (peak_time % 2);
432 if ((*balance * agc_baltime) < 0)
434 if (*balance < 0)
435 agc_baltime -= peak_time % 2;
436 else
437 agc_baltime += peak_time % 2;
440 increment = ((agc_risetime / 2) > agc_droptime);
442 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;
450 else if (agc_baltime > +agc_tbal[agc_mode])
452 if (!increment || !agc_gain_is_max(increment, !increment)) {
453 change_recording_gain(increment, increment, !increment);
454 set_gain();
456 agc_baltime = 0;
459 else if (!(hist_time % 4))
461 if (agc_baltime < 0)
462 agc_baltime++;
463 else
464 agc_baltime--;
468 /* Automatic gain control */
469 if ((agc_left > agc_th_hi[agc_mode]) || (agc_right > agc_th_hi[agc_mode]))
471 if ((agc_left > AGC_CLIP) || (agc_right > AGC_CLIP))
472 agc_droptime += agc_tdrop[agc_mode] /
473 (global_settings.rec_agc_cliptime + 1);
474 if (agc_left > AGC_HIGH) {
475 agc_droptime++;
476 agc_risetime=0;
477 if (agc_left > AGC_PEAK)
478 agc_droptime += 2;
480 if (agc_right > AGC_HIGH) {
481 agc_droptime++;
482 agc_risetime=0;
483 if (agc_right > AGC_PEAK)
484 agc_droptime += 2;
486 if (agc_mono > agc_th_hi[agc_mode])
487 agc_droptime++;
488 else
489 agc_droptime += !(peak_time % 2);
491 if (agc_droptime >= agc_tdrop[agc_mode])
493 change_recording_gain(false, true, true);
494 agc_droptime = 0;
495 agc_risetime = 0;
496 set_gain();
498 agc_risetime = MAX(agc_risetime - 1, 0);
500 else if (agc_mono < agc_th_lo[agc_mode])
502 if (agc_mono < (agc_th_lo[agc_mode] / 8))
503 agc_risetime += !(peak_time % 5);
504 else if (agc_mono < (agc_th_lo[agc_mode] / 2))
505 agc_risetime += 2;
506 else
507 agc_risetime++;
509 if (agc_risetime >= agc_trise[agc_mode]) {
510 if ((agc_mode != AGC_SAFETY_MODE) &&
511 (!agc_gain_is_max(true, true))) {
512 change_recording_gain(true, true, true);
513 set_gain();
515 agc_risetime = 0;
516 agc_droptime = 0;
518 agc_droptime = MAX(agc_droptime - 1, 0);
520 else if (!(peak_time % 6)) /* on target level every 1.2 sec */
522 agc_risetime = MAX(agc_risetime - 1, 0);
523 agc_droptime = MAX(agc_droptime - 1, 0);
526 #endif /* HAVE_AGC */
528 static const char* const fmtstr[] =
530 "%c%d %s", /* no decimals */
531 "%c%d.%d %s ", /* 1 decimal */
532 "%c%d.%02d %s " /* 2 decimals */
535 static char *fmt_gain(int snd, int val, char *str, int len)
537 int i, d, numdec;
538 const char *unit;
539 char sign = ' ';
541 val = sound_val2phys(snd, val);
542 if(val < 0)
544 sign = '-';
545 val = -val;
547 numdec = sound_numdecimals(snd);
548 unit = sound_unit(snd);
550 if(numdec)
552 i = val / (10*numdec);
553 d = val % (10*numdec);
554 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
556 else
557 snprintf(str, len, fmtstr[numdec], sign, val, unit);
559 return str;
562 /* the list below must match enum audio_sources in audio.h */
563 static const char* const prestr[] =
565 HAVE_MIC_IN_([AUDIO_SRC_MIC] = "R_MIC_",)
566 HAVE_LINE_REC_([AUDIO_SRC_LINEIN] = "R_LINE_",)
567 HAVE_SPDIF_IN_([AUDIO_SRC_SPDIF] = "R_SPDIF_",)
568 HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO] = "R_FM_",)
571 char *rec_create_filename(char *buffer)
573 char ext[16];
574 const char *pref = "R_";
576 /* Directory existence and writeablility should have already been
577 * verified - do not pass NULL pointers to pcmrec */
579 if((unsigned)global_settings.rec_source < AUDIO_NUM_SOURCES)
581 pref = prestr[global_settings.rec_source];
584 strcpy(buffer, global_settings.rec_directory);
586 snprintf(ext, sizeof(ext), ".%s",
587 REC_FILE_ENDING(global_settings.rec_format));
589 #if CONFIG_RTC == 0
590 return create_numbered_filename(buffer, buffer, pref, ext, 4,
591 &file_number);
592 #else
593 /* We'll wait at least up to the start of the next second so no duplicate
594 names are created */
595 return create_datetime_filename(buffer, buffer, pref, ext, true);
596 #endif
599 #if CONFIG_RTC == 0
600 /* Hit disk to get a starting filename for the type */
601 static void rec_init_filename(void)
603 file_number = -1;
604 rec_create_filename(path_buffer);
605 file_number--;
607 #endif
609 int rec_create_directory(void)
611 int rc = 0;
612 const char * const folder = global_settings.rec_directory;
614 if (strcmp(folder, "/") && !dir_exists(folder))
616 rc = mkdir(folder);
618 if(rc < 0)
620 while (action_userabort(HZ) == false)
622 splashf(0, "%s %s",
623 str(LANG_REC_DIR_NOT_WRITABLE),
624 str(LANG_OFF_ABORT));
627 else
629 rec_status |= RCSTAT_CREATED_DIRECTORY;
630 rc = 1;
634 return rc;
637 void rec_init_recording_options(struct audio_recording_options *options)
639 options->rec_source = global_settings.rec_source;
640 options->rec_frequency = global_settings.rec_frequency;
641 options->rec_channels = global_settings.rec_channels;
642 options->rec_prerecord_time = global_settings.rec_prerecord_time;
643 #if CONFIG_CODEC == SWCODEC
644 options->rec_mono_mode = global_settings.rec_mono_mode;
645 options->rec_source_flags = 0;
646 options->enc_config.rec_format = global_settings.rec_format;
647 global_to_encoder_config(&options->enc_config);
648 #else
649 options->rec_quality = global_settings.rec_quality;
650 options->rec_editable = global_settings.rec_editable;
651 #endif
654 #if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
655 void rec_set_source(int source, unsigned flags)
657 /* Set audio input source, power up/down devices */
658 audio_set_input_source(source, flags);
660 /* Set peakmeters for recording or reset to playback */
661 peak_meter_playback((flags & SRCF_RECORDING) == 0);
662 peak_meter_enabled = true;
664 #endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
666 void rec_set_recording_options(struct audio_recording_options *options)
668 #if CONFIG_CODEC != SWCODEC
669 if (global_settings.rec_prerecord_time)
671 talk_buffer_steal(); /* will use the mp3 buffer */
673 #else /* == SWCODEC */
674 rec_set_source(options->rec_source,
675 options->rec_source_flags | SRCF_RECORDING);
676 #endif /* CONFIG_CODEC != SWCODEC */
678 audio_set_recording_options(options);
681 void rec_command(enum recording_command cmd)
683 switch(cmd)
685 case RECORDING_CMD_STOP_SHUTDOWN:
686 pm_activate_clipcount(false);
687 audio_stop_recording();
688 #if CONFIG_CODEC == SWCODEC
689 audio_close_recording();
690 #endif
691 sys_poweroff();
692 break;
693 case RECORDING_CMD_STOP:
694 pm_activate_clipcount(false);
695 audio_stop_recording();
696 break;
697 case RECORDING_CMD_START:
698 /* steal mp3 buffer, create unique filename and start recording */
699 pm_reset_clipcount();
700 pm_activate_clipcount(true);
701 #if CONFIG_CODEC != SWCODEC
702 talk_buffer_steal(); /* we use the mp3 buffer */
703 #endif
704 audio_record(rec_create_filename(path_buffer));
705 break;
706 case RECORDING_CMD_START_NEWFILE:
707 /* create unique filename and start recording*/
708 pm_reset_clipcount();
709 pm_activate_clipcount(true); /* just to be sure */
710 audio_new_file(rec_create_filename(path_buffer));
711 break;
712 case RECORDING_CMD_PAUSE:
713 pm_activate_clipcount(false);
714 audio_pause_recording();
715 break;
716 case RECORDING_CMD_RESUME:
717 pm_activate_clipcount(true);
718 audio_resume_recording();
719 break;
721 update_list = true;
724 /* used in trigger_listerner and recording_screen */
725 static unsigned int last_seconds = 0;
728 * Callback function so that the peak meter code can send an event
729 * to this application. This function can be passed to
730 * peak_meter_set_trigger_listener in order to activate the trigger.
732 static void trigger_listener(int trigger_status)
734 switch (trigger_status)
736 case TRIG_GO:
737 if(!(audio_status() & AUDIO_STATUS_RECORD))
739 rec_status |= RCSTAT_HAVE_RECORDED;
740 rec_command(RECORDING_CMD_START);
741 #if CONFIG_CODEC != SWCODEC
742 /* give control to mpeg thread so that it can start
743 recording */
744 yield(); yield(); yield();
745 #endif
748 /* if we're already recording this is a retrigger */
749 else
751 if((audio_status() & AUDIO_STATUS_PAUSE) &&
752 (global_settings.rec_trigger_type == TRIG_TYPE_PAUSE))
754 rec_command(RECORDING_CMD_RESUME);
756 /* New file on trig start*/
757 else if (global_settings.rec_trigger_type != TRIG_TYPE_NEW_FILE)
759 rec_command(RECORDING_CMD_START_NEWFILE);
760 /* tell recording_screen to reset the time */
761 last_seconds = 0;
764 break;
766 /* A _change_ to TRIG_READY means the current recording has stopped */
767 case TRIG_READY:
768 if(audio_status() & AUDIO_STATUS_RECORD)
770 switch(global_settings.rec_trigger_type)
772 case TRIG_TYPE_STOP: /* Stop */
773 rec_command(RECORDING_CMD_STOP);
774 break;
776 case TRIG_TYPE_PAUSE: /* Pause */
777 rec_command(RECORDING_CMD_PAUSE);
778 break;
780 case TRIG_TYPE_NEW_FILE: /* New file on trig stop*/
781 rec_command(RECORDING_CMD_START_NEWFILE);
782 /* tell recording_screen to reset the time */
783 last_seconds = 0;
784 break;
786 case 3: /* Stop and shutdown */
787 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
788 break;
791 if (global_settings.rec_trigger_mode != TRIG_MODE_REARM)
793 peak_meter_set_trigger_listener(NULL);
794 peak_meter_trigger(false);
797 break;
801 /* Stuff for drawing the screen */
803 enum rec_list_items_stereo {
804 ITEM_VOLUME = 0,
805 ITEM_GAIN = 1,
806 ITEM_GAIN_L = 2,
807 ITEM_GAIN_R = 3,
808 #ifdef HAVE_AGC
809 ITEM_AGC_MODE = 4,
810 ITEM_AGC_MAXDB = 5,
811 ITEM_FILENAME = 7,
812 ITEM_COUNT = 7,
813 #else
814 ITEM_FILENAME = 7,
815 ITEM_COUNT = 5,
816 #endif
819 enum rec_list_items_mono {
820 ITEM_VOLUME_M = 0,
821 ITEM_GAIN_M = 1,
822 #ifdef HAVE_AGC
823 ITEM_AGC_MODE_M = 4,
824 ITEM_AGC_MAXDB_M = 5,
825 ITEM_FILENAME_M = 7,
826 ITEM_COUNT_M = 5,
827 #else
828 ITEM_FILENAME_M = 7,
829 ITEM_COUNT_M = 3,
830 #endif
833 #ifdef HAVE_SPDIF_REC
834 enum rec_list_items_spdif {
835 ITEM_VOLUME_D = 0,
836 #if CONFIG_CODEC == SWCODEC
837 ITEM_SAMPLERATE_D = 6,
838 ITEM_FILENAME_D = 7,
839 ITEM_COUNT_D = 3,
840 #else
841 ITEM_FILENAME_D = 7,
842 ITEM_COUNT_D = 2,
843 #endif
845 #endif
847 static int listid_to_enum[ITEM_COUNT];
849 static const char* reclist_get_name(int selected_item, void * data,
850 char * buffer, size_t buffer_len)
852 char buf2[32];
853 #ifdef HAVE_AGC
854 char buf3[32];
855 #endif
856 data = data; /* not used */
857 if(selected_item >= ITEM_COUNT)
858 return "";
860 switch (listid_to_enum[selected_item])
862 case ITEM_VOLUME:
863 snprintf(buffer, buffer_len, "%s: %s", str(LANG_VOLUME),
864 fmt_gain(SOUND_VOLUME,
865 global_settings.volume,
866 buf2, sizeof(buf2)));
867 break;
868 case ITEM_GAIN:
869 #ifdef HAVE_MIC_REC
870 if(global_settings.rec_source == AUDIO_SRC_MIC)
872 /* Draw MIC recording gain */
873 snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
874 fmt_gain(SOUND_MIC_GAIN,
875 global_settings.rec_mic_gain,
876 buf2, sizeof(buf2)));
878 else
879 #endif /* MIC */
881 int avg_gain = (global_settings.rec_left_gain +
882 global_settings.rec_right_gain) / 2;
883 snprintf(buffer, buffer_len, "%s: %s", str(LANG_GAIN),
884 fmt_gain(SOUND_LEFT_GAIN,
885 avg_gain,
886 buf2, sizeof(buf2)));
888 break;
889 case ITEM_GAIN_L:
890 snprintf(buffer, buffer_len, "%s: %s",
891 str(LANG_GAIN_LEFT),
892 fmt_gain(SOUND_LEFT_GAIN,
893 global_settings.rec_left_gain,
894 buf2, sizeof(buf2)));
895 break;
896 case ITEM_GAIN_R:
897 snprintf(buffer, buffer_len, "%s: %s",
898 str(LANG_GAIN_RIGHT),
899 fmt_gain(SOUND_RIGHT_GAIN,
900 global_settings.rec_right_gain,
901 buf2, sizeof(buf2)));
902 break;
903 #ifdef HAVE_AGC
904 case ITEM_AGC_MODE:
905 snprintf(buffer, buffer_len, "%s: %s",
906 str(LANG_RECORDING_AGC_PRESET),
907 agc_preset_str[agc_preset]);
908 break;
909 case ITEM_AGC_MAXDB:
910 if (agc_preset == 0)
911 snprintf(buffer, buffer_len, "%s: %s",
912 str(LANG_RECORDING_AGC_MAXGAIN),
913 fmt_gain(SOUND_LEFT_GAIN,
914 agc_maxgain, buf2, sizeof(buf2)));
915 #ifdef HAVE_MIC_REC
916 else if (global_settings.rec_source == AUDIO_SRC_MIC)
917 snprintf(buffer, buffer_len, "%s: %s (%s)",
918 str(LANG_RECORDING_AGC_MAXGAIN),
919 fmt_gain(SOUND_MIC_GAIN,
920 agc_maxgain, buf2, sizeof(buf2)),
921 fmt_gain(SOUND_MIC_GAIN,
922 agc_maxgain - global_settings.rec_mic_gain,
923 buf3, sizeof(buf3)));
924 else
925 #endif /* MIC */
926 snprintf(buffer, buffer_len, "%s: %s (%s)",
927 str(LANG_RECORDING_AGC_MAXGAIN),
928 fmt_gain(SOUND_LEFT_GAIN,
929 agc_maxgain, buf2, sizeof(buf2)),
930 fmt_gain(SOUND_LEFT_GAIN,
931 agc_maxgain -
932 (global_settings.rec_left_gain +
933 global_settings.rec_right_gain)/2,
934 buf3, sizeof(buf3)));
935 break;
936 #endif
937 #if CONFIG_CODEC == SWCODEC
938 #ifdef HAVE_SPDIF_REC
939 case ITEM_SAMPLERATE_D:
940 snprintf(buffer, buffer_len, "%s: %d",
941 str(LANG_RECORDING_FREQUENCY),
942 pcm_rec_sample_rate());
943 break;
944 #endif
945 #endif
946 case ITEM_FILENAME:
948 if(audio_status() & AUDIO_STATUS_RECORD)
950 size_t tot_len = strlen(path_buffer) +
951 strlen(str(LANG_RECORDING_FILENAME)) + 1;
952 if(tot_len > buffer_len)
954 snprintf(buffer, buffer_len, "%s %s",
955 str(LANG_RECORDING_FILENAME),
956 path_buffer + tot_len - buffer_len);
958 else
960 snprintf(buffer, buffer_len, "%s %s",
961 str(LANG_RECORDING_FILENAME), path_buffer);
964 else
966 return str(LANG_RECORDING_FILENAME);
968 break;
970 default:
971 return "";
973 return buffer;
977 bool recording_start_automatic = false;
979 bool recording_screen(bool no_source)
981 int button;
982 int done = -1; /* negative to re-init, positive to quit, zero to run */
983 char buf[32]; /* for preparing strings */
984 char buf2[32]; /* for preparing strings */
985 int w, h; /* character width/height */
986 int update_countdown = 0; /* refresh counter */
987 unsigned int seconds;
988 int hours, minutes;
989 int audio_stat = 0; /* status of the audio system */
990 int last_audio_stat = -1; /* previous status so we can act on changes */
991 struct viewport vp_list[NB_SCREENS], vp_top[NB_SCREENS]; /* the viewports */
993 #if CONFIG_CODEC == SWCODEC
994 int warning_counter = 0;
995 #define WARNING_PERIOD 7
996 #endif
998 #if CONFIG_CODEC == SWCODEC
999 #ifdef HAVE_SPDIF_REC
1000 unsigned long prev_sample_rate = 0;
1001 #endif
1002 #endif
1004 #ifdef HAVE_FMRADIO_REC
1005 /* Radio is left on if:
1006 * 1) Is was on at the start and the initial source is FM Radio
1007 * 2) 1) and the source was never changed to something else
1009 int radio_status = (global_settings.rec_source != AUDIO_SRC_FMRADIO) ?
1010 FMRADIO_OFF : get_radio_status();
1011 #endif
1012 #if (CONFIG_LED == LED_REAL)
1013 bool led_state = false;
1014 int led_countdown = 2;
1015 #endif
1016 #ifdef HAVE_AGC
1017 bool peak_read = false;
1018 bool peak_valid = false;
1019 int peak_l, peak_r;
1020 int balance = 0;
1021 #endif
1022 int i;
1023 int pm_x[NB_SCREENS]; /* peakmeter (and trigger bar) x pos */
1024 int pm_y[NB_SCREENS]; /* peakmeter y pos */
1025 int pm_h[NB_SCREENS]; /* peakmeter height */
1026 int trig_ypos[NB_SCREENS]; /* trigger bar y pos */
1027 int trig_width[NB_SCREENS]; /* trigger bar width */
1028 bool compact_view[NB_SCREENS]; /* tweak layout tiny screens / big fonts */
1030 struct gui_synclist lists; /* the list in the bottom vp */
1031 #ifdef HAVE_FMRADIO_REC
1032 int prev_rec_source = global_settings.rec_source; /* detect source change */
1033 #endif
1035 struct audio_recording_options rec_options;
1036 rec_status = RCSTAT_IN_RECSCREEN;
1038 #if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
1039 && !defined(SIMULATOR)
1040 ata_set_led_enabled(false);
1041 #endif
1043 #if CONFIG_CODEC == SWCODEC
1044 /* recording_menu gets messed up: so prevent manus talking */
1045 talk_disable(true);
1046 /* audio_init_recording stops anything playing when it takes the audio
1047 buffer */
1048 #else
1049 /* Yes, we use the D/A for monitoring */
1050 peak_meter_enabled = true;
1051 peak_meter_playback(true);
1052 #endif
1054 #ifdef HAVE_AGC
1055 peak_meter_get_peakhold(&peak_l, &peak_r);
1056 #endif
1058 pm_reset_clipcount();
1059 pm_activate_clipcount(false);
1060 settings_apply_trigger();
1062 #ifdef HAVE_AGC
1063 agc_preset_str[0] = str(LANG_OFF);
1064 agc_preset_str[1] = str(LANG_AGC_SAFETY);
1065 agc_preset_str[2] = str(LANG_AGC_LIVE);
1066 agc_preset_str[3] = str(LANG_AGC_DJSET);
1067 agc_preset_str[4] = str(LANG_AGC_MEDIUM);
1068 agc_preset_str[5] = str(LANG_AGC_VOICE);
1069 #endif /* HAVE_AGC */
1071 #if CONFIG_CODEC == SWCODEC
1072 audio_close_recording();
1073 #endif
1074 audio_init_recording(0);
1075 sound_set_volume(global_settings.volume);
1077 #if CONFIG_RTC == 0
1078 /* Create new filename for recording start */
1079 rec_init_filename();
1080 #endif
1082 /* viewport init and calculations that only needs to be done once */
1083 FOR_NB_SCREENS(i)
1085 struct viewport *v;
1086 /* top vp, 4 lines, force sys font if total screen < 6 lines
1087 NOTE: one could limit the list to 1 line and get away with 5 lines */
1088 v = &vp_top[i];
1089 viewport_set_defaults(v, i);
1090 if (viewport_get_nb_lines(v) < 4)
1092 /* compact needs 4 lines total */
1093 v->font = FONT_SYSFIXED;
1094 compact_view[i] = false;
1096 else
1098 if (viewport_get_nb_lines(v) < (4+2)) /*top=4,list=2*/
1099 compact_view[i] = true;
1100 else
1101 compact_view[i] = false;
1103 vp_list[i] = *v; /* get a copy now so it can be sized more easily */
1104 v->height = (font_get(v->font)->height)*(compact_view[i] ? 3 : 4);
1106 /* list section, rest of the screen */
1107 vp_list[i].y += vp_top[i].height;
1108 vp_list[i].height -= vp_top[i].height;
1109 screens[i].set_viewport(&vp_top[i]); /* req for next calls */
1111 screens[i].getstringsize("W", &w, &h);
1112 pm_y[i] = font_get(vp_top[i].font)->height * 2;
1113 trig_ypos[i] = font_get(vp_top[i].font)->height * 3;
1114 if(compact_view[i])
1115 trig_ypos[i] -= (font_get(vp_top[i].font)->height)/2;
1118 /* init the bottom list */
1119 gui_synclist_init(&lists, reclist_get_name, NULL, false, 1, vp_list);
1120 gui_synclist_set_title(&lists, NULL, Icon_NOICON);
1123 send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
1125 /* start of the loop: we stay in this loop until user quits recscreen */
1126 while(done <= 0)
1128 if(done < 0)
1130 /* request to re-init stuff, done after settings screen */
1131 done = 0;
1132 #ifdef HAVE_FMRADIO_REC
1133 /* If input changes away from FM Radio,
1134 radio will remain off when recording screen closes. */
1135 if (global_settings.rec_source != prev_rec_source
1136 && prev_rec_source == AUDIO_SRC_FMRADIO)
1137 radio_status = FMRADIO_OFF;
1138 prev_rec_source = global_settings.rec_source;
1139 #endif
1141 FOR_NB_SCREENS(i)
1143 pm_x[i] = 0;
1144 if(global_settings.peak_meter_clipcounter)
1146 int clipwidth = 0;
1147 screens[i].getstringsize(str(LANG_PM_CLIPCOUNT),
1148 &clipwidth, &h); /* h is same */
1149 pm_x[i] = clipwidth+1;
1151 if(global_settings.rec_trigger_mode == TRIG_MODE_OFF)
1152 pm_h[i] = font_get(vp_top[i].font)->height * 2;
1153 else
1154 pm_h[i] = font_get(vp_top[i].font)->height;
1155 if(compact_view[i])
1156 pm_h[i] /= 2;
1157 trig_width[i] = vp_top[i].width - pm_x[i];
1160 #if CONFIG_CODEC == SWCODEC
1161 audio_close_recording();
1162 audio_init_recording(0);
1163 #endif
1165 rec_init_recording_options(&rec_options);
1166 rec_set_recording_options(&rec_options);
1168 if(rec_create_directory() < 0)
1170 rec_status = 0;
1171 goto rec_abort;
1174 #if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
1175 /* If format changed, a new number is required */
1176 rec_init_filename();
1177 #endif
1179 #ifdef HAVE_AGC
1180 #ifdef HAVE_MIC_REC
1181 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1182 agc_preset = global_settings.rec_agc_preset_mic;
1183 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1185 else
1186 #endif /* MIC */
1188 agc_preset = global_settings.rec_agc_preset_line;
1189 agc_maxgain = global_settings.rec_agc_maxgain_line;
1191 #endif /* HAVE_AGC */
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(HAVE_MIC_REC_((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 /* Wait for a button a while (HZ/10) drawing the peak meter */
1295 button = peak_meter_draw_get_btn(CONTEXT_RECSCREEN,
1296 pm_x, pm_y, pm_h,
1297 screen_update, vp_top);
1298 if (last_audio_stat != audio_stat)
1300 if (audio_stat & AUDIO_STATUS_RECORD)
1302 rec_status |= RCSTAT_HAVE_RECORDED;
1304 last_audio_stat = audio_stat;
1305 update_list = true;
1308 if (recording_start_automatic)
1310 /* simulate a button press */
1311 button = ACTION_REC_PAUSE;
1312 recording_start_automatic = false;
1315 /* let list handle the button */
1316 gui_synclist_do_button(&lists, &button, LIST_WRAP_UNLESS_HELD);
1319 switch(button)
1321 case ACTION_SETTINGS_INC:
1322 case ACTION_SETTINGS_INCREPEAT:
1323 switch (listid_to_enum[gui_synclist_get_sel_pos(&lists)])
1325 case ITEM_VOLUME:
1326 global_settings.volume++;
1327 setvol();
1328 break;
1329 case ITEM_GAIN:
1330 #ifdef HAVE_MIC_REC
1331 if(global_settings.rec_source == AUDIO_SRC_MIC)
1333 if(global_settings.rec_mic_gain <
1334 sound_max(SOUND_MIC_GAIN))
1335 global_settings.rec_mic_gain++;
1337 else
1338 #endif /* MIC */
1340 if(global_settings.rec_left_gain <
1341 sound_max(SOUND_LEFT_GAIN))
1342 global_settings.rec_left_gain++;
1343 if(global_settings.rec_right_gain <
1344 sound_max(SOUND_RIGHT_GAIN))
1345 global_settings.rec_right_gain++;
1347 break;
1348 case ITEM_GAIN_L:
1349 if(global_settings.rec_left_gain <
1350 sound_max(SOUND_LEFT_GAIN))
1351 global_settings.rec_left_gain++;
1352 break;
1353 case ITEM_GAIN_R:
1354 if(global_settings.rec_right_gain <
1355 sound_max(SOUND_RIGHT_GAIN))
1356 global_settings.rec_right_gain++;
1357 break;
1358 #ifdef HAVE_AGC
1359 case ITEM_AGC_MODE:
1360 agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE);
1361 agc_enable = (agc_preset != 0);
1362 #ifdef HAVE_MIC_REC
1363 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1364 global_settings.rec_agc_preset_mic = agc_preset;
1365 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1366 } else
1367 #endif /* MIC */
1369 global_settings.rec_agc_preset_line = agc_preset;
1370 agc_maxgain = global_settings.rec_agc_maxgain_line;
1372 break;
1373 case ITEM_AGC_MAXDB:
1374 #ifdef HAVE_MIC_REC
1375 if (global_settings.rec_source == AUDIO_SRC_MIC)
1377 agc_maxgain = MIN(agc_maxgain + 1,
1378 sound_max(SOUND_MIC_GAIN));
1379 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1381 else
1382 #endif /* MIC */
1384 agc_maxgain = MIN(agc_maxgain + 1,
1385 sound_max(SOUND_LEFT_GAIN));
1386 global_settings.rec_agc_maxgain_line = agc_maxgain;
1388 break;
1389 #endif /* HAVE_AGC */
1391 set_gain();
1392 update_countdown = 0; /* Update immediately */
1393 break;
1394 case ACTION_SETTINGS_DEC:
1395 case ACTION_SETTINGS_DECREPEAT:
1396 switch (listid_to_enum[gui_synclist_get_sel_pos(&lists)])
1398 case ITEM_VOLUME:
1399 global_settings.volume--;
1400 setvol();
1401 break;
1402 case ITEM_GAIN:
1403 #ifdef HAVE_MIC_REC
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
1411 #endif /* MIC */
1413 if(global_settings.rec_left_gain >
1414 sound_min(SOUND_LEFT_GAIN))
1415 global_settings.rec_left_gain--;
1416 if(global_settings.rec_right_gain >
1417 sound_min(SOUND_RIGHT_GAIN))
1418 global_settings.rec_right_gain--;
1420 break;
1421 case ITEM_GAIN_L:
1422 if(global_settings.rec_left_gain >
1423 sound_min(SOUND_LEFT_GAIN))
1424 global_settings.rec_left_gain--;
1425 break;
1426 case ITEM_GAIN_R:
1427 if(global_settings.rec_right_gain >
1428 sound_min(SOUND_RIGHT_GAIN))
1429 global_settings.rec_right_gain--;
1430 break;
1431 #ifdef HAVE_AGC
1432 case ITEM_AGC_MODE:
1433 agc_preset = MAX(agc_preset - 1, 0);
1434 agc_enable = (agc_preset != 0);
1435 #ifdef HAVE_MIC_REC
1436 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1437 global_settings.rec_agc_preset_mic = agc_preset;
1438 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1439 } else
1440 #endif /* MIC */
1442 global_settings.rec_agc_preset_line = agc_preset;
1443 agc_maxgain = global_settings.rec_agc_maxgain_line;
1445 break;
1446 case ITEM_AGC_MAXDB:
1447 #ifdef HAVE_MIC_REC
1448 if (global_settings.rec_source == AUDIO_SRC_MIC)
1450 agc_maxgain = MAX(agc_maxgain - 1,
1451 sound_min(SOUND_MIC_GAIN));
1452 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1453 } else
1454 #endif /* MIC */
1456 agc_maxgain = MAX(agc_maxgain - 1,
1457 sound_min(SOUND_LEFT_GAIN));
1458 global_settings.rec_agc_maxgain_line = agc_maxgain;
1460 break;
1461 #endif /* HAVE_AGC */
1463 set_gain();
1464 update_countdown = 0; /* Update immediately */
1465 break;
1466 case ACTION_STD_CANCEL:
1467 /* turn off the trigger */
1468 peak_meter_trigger(false);
1469 peak_meter_set_trigger_listener(NULL);
1471 if(audio_stat & AUDIO_STATUS_RECORD)
1473 rec_command(RECORDING_CMD_STOP);
1475 else
1477 #if CONFIG_CODEC != SWCODEC
1478 peak_meter_playback(true);
1479 peak_meter_enabled = false;
1480 #endif
1481 done = 1;
1483 update_countdown = 0; /* Update immediately */
1484 break;
1485 #ifdef HAVE_REMOTE_LCD
1486 case ACTION_REC_LCD:
1487 /* this feature exists for some h1x0/h3x0 targets that suffer
1488 from noise caused by remote LCD updates
1489 NOTE 1: this will leave the list on the remote
1490 NOTE 2: to be replaced by a global LCD_off() routine */
1491 if(remote_display_on)
1493 /* switch to single screen, leave message on remote */
1494 screen_update = 1;
1495 screens[1].clear_viewport();
1496 screens[1].puts(0, 0, str(LANG_REMOTE_LCD_OFF));
1497 screens[1].puts(0, 1, str(LANG_REMOTE_LCD_ON));
1498 screens[1].update_viewport();
1500 else
1502 /* remote switched on again */
1503 update_list = true;
1504 screen_update = NB_SCREENS;
1506 remote_display_on = !remote_display_on; /* toggle */
1507 update_countdown = 0; /* Update immediately */
1508 break;
1509 #endif
1510 case ACTION_REC_PAUSE:
1511 case ACTION_REC_NEWFILE:
1512 /* Only act if the mpeg is stopped */
1513 if(!(audio_stat & AUDIO_STATUS_RECORD))
1515 /* is this manual or triggered recording? */
1516 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1517 (peak_meter_trigger_status() != TRIG_OFF))
1519 /* manual recording */
1520 rec_status |= RCSTAT_HAVE_RECORDED;
1521 rec_command(RECORDING_CMD_START);
1522 last_seconds = 0;
1523 if (global_settings.talk_menu)
1525 /* no voice possible here, but a beep */
1526 audio_beep(HZ/2); /* longer beep on start */
1529 /* this is triggered recording */
1530 else
1532 /* we don't start recording now, but enable the
1533 trigger and let the callback function
1534 trigger_listener control when the recording starts */
1535 peak_meter_trigger(true);
1536 peak_meter_set_trigger_listener(&trigger_listener);
1539 else
1541 /*if new file button pressed, start new file */
1542 if (button == ACTION_REC_NEWFILE)
1544 rec_command(RECORDING_CMD_START_NEWFILE);
1545 last_seconds = 0;
1547 else
1548 /* if pause button pressed, pause or resume */
1550 if(audio_stat & AUDIO_STATUS_PAUSE)
1552 rec_command(RECORDING_CMD_RESUME);
1553 if (global_settings.talk_menu)
1555 /* no voice possible here, but a beep */
1556 audio_beep(HZ/4); /* short beep on resume */
1559 else
1561 rec_command(RECORDING_CMD_PAUSE);
1565 update_countdown = 0; /* Update immediately */
1566 break;
1567 case ACTION_STD_MENU:
1568 #if CONFIG_CODEC == SWCODEC
1569 if(!(audio_stat & AUDIO_STATUS_RECORD))
1570 #else
1571 if(audio_stat != AUDIO_STATUS_RECORD)
1572 #endif
1574 #if (CONFIG_LED == LED_REAL)
1575 /* led is restored at begin of loop / end of function */
1576 led(false);
1577 #endif
1578 if (recording_menu(no_source))
1580 done = 1;
1581 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1582 #ifdef HAVE_FMRADIO_REC
1583 radio_status = FMRADIO_OFF;
1584 #endif
1586 else
1588 done = -1;
1589 /* the init is now done at the beginning of the loop */
1592 break;
1594 #if CONFIG_KEYPAD == RECORDER_PAD
1595 case ACTION_REC_F2:
1596 if(audio_stat != AUDIO_STATUS_RECORD)
1598 #if (CONFIG_LED == LED_REAL)
1599 /* led is restored at begin of loop / end of function */
1600 led(false);
1601 #endif
1602 if (f2_rec_screen())
1604 rec_status |= RCSTAT_HAVE_RECORDED;
1605 done = true;
1607 else
1608 update_countdown = 0; /* Update immediately */
1610 break;
1612 case ACTION_REC_F3:
1613 if(audio_stat & AUDIO_STATUS_RECORD)
1615 rec_command(RECORDING_CMD_START_NEWFILE);
1616 last_seconds = 0;
1618 else
1620 #if (CONFIG_LED == LED_REAL)
1621 /* led is restored at begin of loop / end of function */
1622 led(false);
1623 #endif
1624 if (f3_rec_screen())
1626 rec_status |= RCSTAT_HAVE_RECORDED;
1627 done = true;
1629 else
1630 update_countdown = 0; /* Update immediately */
1632 break;
1633 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
1635 case SYS_USB_CONNECTED:
1636 /* Only accept USB connection when not recording */
1637 if(!(audio_stat & AUDIO_STATUS_RECORD))
1639 FOR_NB_SCREENS(i)
1640 screens[i].set_viewport(NULL);
1641 default_event_handler(SYS_USB_CONNECTED);
1642 done = true;
1643 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1644 #ifdef HAVE_FMRADIO_REC
1645 radio_status = FMRADIO_OFF;
1646 #endif
1648 break;
1649 } /*switch(button)*/
1651 #ifdef HAVE_AGC
1652 peak_read = !peak_read;
1653 if (peak_read) { /* every 2nd run of loop */
1654 peak_time++;
1655 peak_valid = read_peak_levels(&peak_l, &peak_r, &balance);
1658 /* Handle AGC every 200ms when enabled and peak data is valid */
1659 if (peak_read && agc_enable && peak_valid)
1660 auto_gain_control(&peak_l, &peak_r, &balance);
1661 #endif
1663 seconds = audio_recorded_time() / HZ;
1665 /* start of vp_top drawing */
1666 if(update_countdown-- == 0 || seconds > last_seconds)
1668 unsigned int dseconds, dhours, dminutes;
1669 unsigned long num_recorded_bytes, dsize, dmb;
1672 FOR_NB_SCREENS(i)
1674 screens[i].set_viewport(&vp_top[i]);
1675 screens[i].clear_viewport();
1677 update_countdown = 5;
1678 last_seconds = seconds;
1680 dseconds = rec_timesplit_seconds();
1681 dsize = rec_sizesplit_bytes();
1682 num_recorded_bytes = audio_num_recorded_bytes();
1684 #if CONFIG_CODEC == SWCODEC
1685 if ((audio_stat & AUDIO_STATUS_WARNING)
1686 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
1688 /* Switch back and forth displaying warning on first available
1689 line to ensure visibility - the motion should also help
1690 draw attention */
1691 /* Don't use language string unless agreed upon to make this
1692 method permanent - could do something in the statusbar */
1693 snprintf(buf, sizeof(buf), "Warning: %08X",
1694 pcm_rec_get_warnings());
1696 else
1697 #endif /* CONFIG_CODEC == SWCODEC */
1698 if ((global_settings.rec_sizesplit) &&
1699 (global_settings.rec_split_method))
1701 dmb = dsize/1024/1024;
1702 snprintf(buf, sizeof(buf), "%s %dMB",
1703 str(LANG_SPLIT_SIZE), dmb);
1705 else
1707 hours = seconds / 3600;
1708 minutes = (seconds - (hours * 3600)) / 60;
1709 snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d",
1710 str(LANG_RECORDING_TIME),
1711 hours, minutes, seconds%60);
1714 FOR_NB_ACTIVE_SCREENS(i)
1715 screens[i].puts(0, 0, buf);
1717 if(audio_stat & AUDIO_STATUS_PRERECORD)
1719 snprintf(buf, sizeof(buf), "%s...",
1720 str(LANG_RECORD_PRERECORD));
1722 else
1724 /* Display the split interval if the record timesplit
1725 is active */
1726 if ((global_settings.rec_timesplit) &&
1727 !(global_settings.rec_split_method))
1729 /* Display the record timesplit interval rather
1730 than the file size if the record timer is active */
1731 dhours = dseconds / 3600;
1732 dminutes = (dseconds - (dhours * 3600)) / 60;
1733 snprintf(buf, sizeof(buf), "%s %02d:%02d",
1734 str(LANG_RECORDING_TIMESPLIT_REC),
1735 dhours, dminutes);
1737 else
1739 output_dyn_value(buf2, sizeof buf2,
1740 num_recorded_bytes,
1741 byte_units, true);
1742 snprintf(buf, sizeof(buf), "%s %s",
1743 str(LANG_RECORDING_SIZE), buf2);
1747 FOR_NB_ACTIVE_SCREENS(i)
1748 screens[i].puts(0, 1, buf);
1750 /* We will do file splitting regardless, either at the end of
1751 a split interval, or when the filesize approaches the 2GB
1752 FAT file size (compatibility) limit. */
1753 if ((audio_stat && !(global_settings.rec_split_method)
1754 && global_settings.rec_timesplit && (seconds >= dseconds))
1755 || (audio_stat && global_settings.rec_split_method
1756 && global_settings.rec_sizesplit
1757 && (num_recorded_bytes >= dsize))
1758 || (num_recorded_bytes >= MAX_FILE_SIZE))
1760 if (!(global_settings.rec_split_type)
1761 || (num_recorded_bytes >= MAX_FILE_SIZE))
1763 rec_command(RECORDING_CMD_START_NEWFILE);
1764 last_seconds = 0;
1766 else
1768 peak_meter_trigger(false);
1769 peak_meter_set_trigger_listener(NULL);
1770 if( global_settings.rec_split_type == 1)
1771 rec_command(RECORDING_CMD_STOP);
1772 else
1773 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
1775 update_countdown = 0;
1778 /* draw the clipcounter just in front of the peakmeter */
1779 if(global_settings.peak_meter_clipcounter)
1781 int clipcount = pm_get_clipcount();
1782 FOR_NB_ACTIVE_SCREENS(i)
1784 if(!compact_view[i])
1786 screens[i].puts(0, 2, str(LANG_PM_CLIPCOUNT));
1787 screens[i].putsf(0, 3, "%4d", clipcount);
1789 else
1790 screens[i].putsf(0, 2, "%4d", clipcount);
1794 #ifdef HAVE_AGC
1795 hist_time++;
1796 #endif
1798 /* draw the trigger status */
1799 if (peak_meter_trigger_status() != TRIG_OFF)
1801 peak_meter_draw_trig(pm_x, trig_ypos, trig_width,
1802 screen_update);
1803 FOR_NB_ACTIVE_SCREENS(i)
1804 screens[i].update_viewport_rect(pm_x[i], trig_ypos[i],
1805 trig_width[i] + 2, TRIG_HEIGHT);
1808 #ifdef HAVE_AGC
1809 #ifdef HAVE_MIC_REC
1810 if (global_settings.rec_source == AUDIO_SRC_MIC)
1812 if(agc_maxgain < (global_settings.rec_mic_gain))
1813 change_recording_gain(false, true, true);
1815 else
1816 #endif /* MIC */
1818 if(agc_maxgain < (global_settings.rec_left_gain))
1819 change_recording_gain(false, true, false);
1820 if(agc_maxgain < (global_settings.rec_right_gain))
1821 change_recording_gain(false, false, true);
1823 #endif /* HAVE_AGC */
1825 #if CONFIG_CODEC == SWCODEC
1826 #ifdef HAVE_SPDIF_REC
1827 if((global_settings.rec_source == AUDIO_SRC_SPDIF) &&
1828 (prev_sample_rate != pcm_rec_sample_rate()))
1830 /* spdif samplerate changed */
1831 prev_sample_rate = pcm_rec_sample_rate();
1832 update_list = true;
1834 #endif
1835 #endif
1837 if(update_list)
1839 /* update_list is set whenever content changes */
1840 update_list = false;
1841 gui_synclist_draw(&lists);
1844 /* draw peakmeter again (check if this can be removed) */
1845 FOR_NB_ACTIVE_SCREENS(i)
1847 screens[i].set_viewport(&vp_top[i]);
1848 peak_meter_screen(&screens[i], pm_x[i], pm_y[i], pm_h[i]);
1849 screens[i].update();
1851 } /* display update every second */
1853 if(audio_stat & AUDIO_STATUS_ERROR)
1855 done = true;
1857 } /* end while(!done) */
1859 audio_stat = audio_status();
1860 if (audio_stat & AUDIO_STATUS_ERROR)
1862 splash(0, str(LANG_DISK_FULL));
1864 FOR_NB_SCREENS(i)
1865 screens[i].update();
1867 #if CONFIG_CODEC == SWCODEC
1868 /* stop recording - some players like H10 freeze otherwise
1869 TO DO: find out why it freezes and fix properly */
1870 rec_command(RECORDING_CMD_STOP);
1871 audio_close_recording();
1872 #endif
1874 audio_error_clear();
1876 while(1)
1878 if (action_userabort(TIMEOUT_NOBLOCK))
1879 break;
1883 rec_abort:
1885 #if CONFIG_CODEC == SWCODEC
1886 rec_command(RECORDING_CMD_STOP);
1887 audio_close_recording();
1889 #ifdef HAVE_FMRADIO_REC
1890 if (radio_status != FMRADIO_OFF)
1891 /* Restore radio playback - radio_status should be unchanged if started
1892 through fm radio screen (barring usb connect) */
1893 rec_set_source(AUDIO_SRC_FMRADIO, (radio_status & FMRADIO_PAUSED) ?
1894 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
1895 else
1896 #endif
1897 /* Go back to playback mode */
1898 rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
1900 /* restore talking */
1901 talk_disable(false);
1902 #else /* !SWCODEC */
1903 audio_init_playback();
1904 #endif /* CONFIG_CODEC == SWCODEC */
1906 /* make sure the trigger is really turned off */
1907 peak_meter_trigger(false);
1908 peak_meter_set_trigger_listener(NULL);
1910 rec_status &= ~RCSTAT_IN_RECSCREEN;
1911 sound_settings_apply();
1913 FOR_NB_SCREENS(i)
1914 screens[i].setfont(FONT_UI);
1917 /* if the directory was created or recording happened, make sure the
1918 browser is updated */
1919 if (rec_status & (RCSTAT_CREATED_DIRECTORY | RCSTAT_HAVE_RECORDED))
1920 reload_directory();
1922 #if (CONFIG_STORAGE & STORAGE_ATA) && (CONFIG_LED == LED_REAL) \
1923 && !defined(SIMULATOR)
1924 ata_set_led_enabled(true);
1925 #endif
1927 settings_save();
1929 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
1930 } /* recording_screen */
1932 #if CONFIG_KEYPAD == RECORDER_PAD
1933 static bool f2_rec_screen(void)
1935 static const char* const freq_str[6] =
1937 "44.1kHz",
1938 "48kHz",
1939 "32kHz",
1940 "22.05kHz",
1941 "24kHz",
1942 "16kHz"
1945 bool exit = false;
1946 bool used = false;
1947 int w, h, i;
1948 char buf[32];
1949 int button;
1950 struct audio_recording_options rec_options;
1952 FOR_NB_SCREENS(i)
1954 screens[i].setfont(FONT_SYSFIXED);
1955 screens[i].getstringsize("A",&w,&h);
1958 while (!exit) {
1959 const char* ptr;
1961 FOR_NB_SCREENS(i)
1963 screens[i].clear_display();
1965 /* Recording quality */
1966 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
1967 str(LANG_SYSFONT_RECORDING_QUALITY));
1970 snprintf(buf, sizeof(buf), "%d", global_settings.rec_quality);
1971 FOR_NB_SCREENS(i)
1973 screens[i].putsxy(0, LCD_HEIGHT/2-h, buf);
1974 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
1975 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
1978 /* Frequency */
1979 snprintf(buf, sizeof buf, "%s:", str(LANG_SYSFONT_RECORDING_FREQUENCY));
1980 ptr = freq_str[global_settings.rec_frequency];
1981 FOR_NB_SCREENS(i)
1983 screens[i].getstringsize(buf,&w,&h);
1984 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
1985 screens[i].getstringsize(ptr, &w, &h);
1986 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
1987 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
1988 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
1991 /* Channel mode */
1992 switch ( global_settings.rec_channels ) {
1993 case 0:
1994 ptr = str(LANG_SYSFONT_CHANNEL_STEREO);
1995 break;
1997 case 1:
1998 ptr = str(LANG_SYSFONT_CHANNEL_MONO);
1999 break;
2002 FOR_NB_SCREENS(i)
2004 screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h);
2005 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
2006 str(LANG_SYSFONT_CHANNELS));
2007 screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h);
2008 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h,
2009 str(LANG_SYSFONT_MODE));
2010 screens[i].getstringsize(ptr, &w, &h);
2011 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
2012 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
2013 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
2015 screens[i].update();
2018 button = button_get(true);
2019 switch (button) {
2020 case BUTTON_LEFT:
2021 case BUTTON_F2 | BUTTON_LEFT:
2022 global_settings.rec_quality++;
2023 if(global_settings.rec_quality > 7)
2024 global_settings.rec_quality = 0;
2025 used = true;
2026 break;
2028 case BUTTON_DOWN:
2029 case BUTTON_F2 | BUTTON_DOWN:
2030 global_settings.rec_frequency++;
2031 if(global_settings.rec_frequency > 5)
2032 global_settings.rec_frequency = 0;
2033 used = true;
2034 break;
2036 case BUTTON_RIGHT:
2037 case BUTTON_F2 | BUTTON_RIGHT:
2038 global_settings.rec_channels++;
2039 if(global_settings.rec_channels > 1)
2040 global_settings.rec_channels = 0;
2041 used = true;
2042 break;
2044 case BUTTON_F2 | BUTTON_REL:
2045 if ( used )
2046 exit = true;
2047 used = true;
2048 break;
2050 case BUTTON_F2 | BUTTON_REPEAT:
2051 used = true;
2052 break;
2054 default:
2055 if(default_event_handler(button) == SYS_USB_CONNECTED)
2056 return true;
2057 break;
2061 rec_init_recording_options(&rec_options);
2062 rec_set_recording_options(&rec_options);
2064 set_gain();
2066 settings_save();
2067 FOR_NB_SCREENS(i)
2068 screens[i].setfont(FONT_UI);
2070 return false;
2073 static bool f3_rec_screen(void)
2075 bool exit = false;
2076 bool used = false;
2077 int w, h, i;
2078 int button;
2079 const char *src_str[] =
2081 str(LANG_SYSFONT_RECORDING_SRC_MIC),
2082 str(LANG_SYSFONT_LINE_IN),
2083 str(LANG_SYSFONT_RECORDING_SRC_DIGITAL)
2085 struct audio_recording_options rec_options;
2087 FOR_NB_SCREENS(i)
2089 screens[i].setfont(FONT_SYSFIXED);
2090 screens[i].getstringsize("A",&w,&h);
2093 while (!exit) {
2094 const char* ptr = src_str[global_settings.rec_source];
2095 FOR_NB_SCREENS(i)
2097 screens[i].clear_display();
2099 /* Recording source */
2100 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
2101 str(LANG_SYSFONT_RECORDING_SOURCE));
2103 screens[i].getstringsize(ptr, &w, &h);
2104 screens[i].putsxy(0, LCD_HEIGHT/2-h, ptr);
2105 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
2106 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
2109 /* trigger setup */
2110 ptr = str(LANG_SYSFONT_RECORD_TRIGGER);
2111 FOR_NB_SCREENS(i)
2113 screens[i].getstringsize(ptr,&w,&h);
2114 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr);
2115 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
2116 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
2118 screens[i].update();
2121 button = button_get(true);
2122 switch (button) {
2123 case BUTTON_DOWN:
2124 case BUTTON_F3 | BUTTON_DOWN:
2125 #ifndef SIMULATOR
2126 rectrigger();
2127 settings_apply_trigger();
2128 #endif
2129 exit = true;
2130 break;
2132 case BUTTON_LEFT:
2133 case BUTTON_F3 | BUTTON_LEFT:
2134 global_settings.rec_source++;
2135 if(global_settings.rec_source > AUDIO_SRC_MAX)
2136 global_settings.rec_source = 0;
2137 used = true;
2138 break;
2140 case BUTTON_F3 | BUTTON_REL:
2141 if ( used )
2142 exit = true;
2143 used = true;
2144 break;
2146 case BUTTON_F3 | BUTTON_REPEAT:
2147 used = true;
2148 break;
2150 default:
2151 if(default_event_handler(button) == SYS_USB_CONNECTED)
2152 return true;
2153 break;
2157 rec_init_recording_options(&rec_options);
2158 rec_set_recording_options(&rec_options);
2160 set_gain();
2162 settings_save();
2163 FOR_NB_SCREENS(i)
2164 screens[i].setfont(FONT_UI);
2166 return false;
2168 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
2170 #if CONFIG_CODEC == SWCODEC
2171 void audio_beep(int duration)
2173 /* dummy */
2174 (void)duration;
2177 #ifdef SIMULATOR
2178 /* stubs for recording sim */
2179 void audio_init_recording(unsigned int buffer_offset)
2181 buffer_offset = buffer_offset;
2184 void audio_close_recording(void)
2188 unsigned long pcm_rec_get_warnings(void)
2190 return 0;
2193 unsigned long pcm_rec_sample_rate(void)
2195 return 0;
2198 unsigned long audio_recorded_time(void)
2200 return 123;
2203 unsigned long audio_num_recorded_bytes(void)
2205 return 5 * 1024 * 1024;
2208 void rec_set_source(int source, unsigned flags)
2210 source = source;
2211 flags = flags;
2214 void audio_set_recording_options(struct audio_recording_options *options)
2216 options = options;
2219 void audio_set_recording_gain(int left, int right, int type)
2221 left = left;
2222 right = right;
2223 type = type;
2226 void audio_record(const char *filename)
2228 filename = filename;
2231 void audio_new_file(const char *filename)
2233 filename = filename;
2236 void audio_stop_recording(void)
2240 void audio_pause_recording(void)
2244 void audio_resume_recording(void)
2248 #endif /* #ifdef SIMULATOR */
2249 #endif /* #ifdef CONFIG_CODEC == SWCODEC */
2251 #endif /* HAVE_RECORDING */