Fix FS #9128: invalidate the peakmeter scales when switching between playback and...
[Rockbox.git] / apps / recorder / recording.c
blobde4a2e6805e6ec960a8ce1834a91f5c86a18e768
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 "recording.h"
44 #include "mp3_playback.h"
45 #include "mas.h"
46 #include "button.h"
47 #include "kernel.h"
48 #include "settings.h"
49 #include "lang.h"
50 #include "font.h"
51 #include "icons.h"
52 #include "icon.h"
53 #include "screens.h"
54 #include "peakmeter.h"
55 #include "statusbar.h"
56 #include "menu.h"
57 #include "sound_menu.h"
58 #include "timefuncs.h"
59 #include "debug.h"
60 #include "misc.h"
61 #include "tree.h"
62 #include "string.h"
63 #include "dir.h"
64 #include "errno.h"
65 #include "talk.h"
66 #include "sound.h"
67 #include "ata.h"
68 #include "splash.h"
69 #include "screen_access.h"
70 #include "action.h"
71 #include "radio.h"
72 #include "sound_menu.h"
73 #include "viewport.h"
75 #ifdef HAVE_RECORDING
76 /* This array holds the record timer interval lengths, in seconds */
77 static const unsigned long rec_timer_seconds[] =
79 0, /* 0 means OFF */
80 5*60, /* 00:05 */
81 10*60, /* 00:10 */
82 15*60, /* 00:15 */
83 30*60, /* 00:30 */
84 60*60, /* 01:00 */
85 74*60, /* 74:00 */
86 80*60, /* 80:00 */
87 2*60*60, /* 02:00 */
88 4*60*60, /* 04:00 */
89 6*60*60, /* 06:00 */
90 8*60*60, /* 08:00 */
91 10L*60*60, /* 10:00 */
92 12L*60*60, /* 12:00 */
93 18L*60*60, /* 18:00 */
94 24L*60*60 /* 24:00 */
97 static unsigned int rec_timesplit_seconds(void)
99 return rec_timer_seconds[global_settings.rec_timesplit];
102 /* This array holds the record size interval lengths, in bytes */
103 static const unsigned long rec_size_bytes[] =
105 0, /* 0 means OFF */
106 5*1024*1024, /* 5MB */
107 10*1024*1024, /* 10MB */
108 15*1024*1024, /* 15MB */
109 32*1024*1024, /* 32MB */
110 64*1024*1024, /* 64MB */
111 75*1024*1024, /* 75MB */
112 100*1024*1024, /* 100MB */
113 128*1024*1024, /* 128MB */
114 256*1024*1024, /* 256MB */
115 512*1024*1024, /* 512MB */
116 650*1024*1024, /* 650MB */
117 700*1024*1024, /* 700MB */
118 1024*1024*1024, /* 1GB */
119 1536*1024*1024, /* 1.5GB */
120 1792*1024*1024, /* 1.75GB */
123 static unsigned long rec_sizesplit_bytes(void)
125 return rec_size_bytes[global_settings.rec_sizesplit];
128 void settings_apply_trigger(void)
130 int start_thres, stop_thres;
131 if (global_settings.peak_meter_dbfs)
133 start_thres = global_settings.rec_start_thres_db - 1;
134 stop_thres = global_settings.rec_stop_thres_db - 1;
136 else
138 start_thres = global_settings.rec_start_thres_linear;
139 stop_thres = global_settings.rec_stop_thres_linear;
142 peak_meter_define_trigger(
143 start_thres,
144 global_settings.rec_start_duration*HZ,
145 MIN(global_settings.rec_start_duration*HZ / 2, 2*HZ),
146 stop_thres,
147 global_settings.rec_stop_postrec*HZ,
148 global_settings.rec_stop_gap*HZ
151 /* recording screen status flags */
152 enum rec_status_flags
154 RCSTAT_IN_RECSCREEN = 0x00000001,
155 RCSTAT_BEEN_IN_USB_MODE = 0x00000002,
156 RCSTAT_CREATED_DIRECTORY = 0x00000004,
157 RCSTAT_HAVE_RECORDED = 0x00000008,
160 static int rec_status = 0;
162 bool in_recording_screen(void)
164 return (rec_status & RCSTAT_IN_RECSCREEN) != 0;
167 #define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
169 #if CONFIG_KEYPAD == RECORDER_PAD
170 static bool f2_rec_screen(void);
171 static bool f3_rec_screen(void);
172 #endif
174 #define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */
176 #ifndef HAVE_REMOTE_LCD
177 static const int screen_update = NB_SCREENS;
178 #else
179 static int screen_update = NB_SCREENS;
180 static bool remote_display_on = true;
181 #endif
183 /** File name creation **/
184 #if CONFIG_RTC == 0
185 /* current file number to assist in creating unique numbered filenames
186 without actually having to create the file on disk */
187 static int file_number = -1;
188 #endif /* CONFIG_RTC */
190 #if CONFIG_CODEC == SWCODEC
192 #define REC_FILE_ENDING(rec_format) \
193 (audio_formats[rec_format_afmt[rec_format]].ext_list)
195 #else /* CONFIG_CODEC != SWCODEC */
197 /* default record file extension for HWCODEC */
198 #define REC_FILE_ENDING(rec_format) \
199 (audio_formats[AFMT_MPA_L3].ext_list)
201 #endif /* CONFIG_CODEC == SWCODEC */
203 /* path for current file */
204 static char path_buffer[MAX_PATH];
206 /** Automatic Gain Control (AGC) **/
207 #ifdef HAVE_AGC
208 /* Timing counters:
209 * peak_time is incremented every 0.2s, every 2nd run of record screen loop.
210 * hist_time is incremented every 0.5s, display update.
211 * peak_time is the counter of the peak hold read and agc process,
212 * overflow every 13 years 8-)
214 static long peak_time = 0;
215 static long hist_time = 0;
217 static short peak_valid_mem[4];
218 #define BAL_MEM_SIZE 24
219 static short balance_mem[BAL_MEM_SIZE];
221 /* Automatic Gain Control */
222 #define AGC_MODE_SIZE 5
223 #define AGC_SAFETY_MODE 0
225 static const char* agc_preset_str[] =
226 { "Off", "S", "L", "D", "M", "V" };
227 /* "Off",
228 "Safety (clip)",
229 "Live (slow)",
230 "DJ-Set (slow)",
231 "Medium",
232 "Voice (fast)" */
233 #define AGC_CLIP 32766
234 #define AGC_PEAK 29883 /* fast gain reduction threshold -0.8dB */
235 #define AGC_HIGH 27254 /* accelerated gain reduction threshold -1.6dB */
236 #define AGC_IMG 823 /* threshold for balance control -32dB */
237 /* autogain high level thresholds (-3dB, -7dB, -4dB, -5dB, -5dB) */
238 static const short agc_th_hi[AGC_MODE_SIZE] =
239 { 23197, 14637, 21156, 18428, 18426 };
240 /* autogain low level thresholds (-14dB, -11dB, -6dB, -7dB, -8dB) */
241 static const short agc_th_lo[AGC_MODE_SIZE] =
242 { 6538, 9235, 16422, 14636, 13045 };
243 /* autogain threshold times [1/5s] or [200ms] */
244 static const short agc_tdrop[AGC_MODE_SIZE] =
245 { 900, 225, 150, 60, 8 };
246 static const short agc_trise[AGC_MODE_SIZE] =
247 { 9000, 750, 400, 150, 20 };
248 static const short agc_tbal[AGC_MODE_SIZE] =
249 { 4500, 500, 300, 100, 15 };
250 /* AGC operation */
251 static bool agc_enable = true;
252 static short agc_preset;
253 /* AGC levels */
254 static int agc_left = 0;
255 static int agc_right = 0;
256 /* AGC time since high target volume was exceeded */
257 static short agc_droptime = 0;
258 /* AGC time since volume fallen below low target */
259 static short agc_risetime = 0;
260 /* AGC balance time exceeding +/- 0.7dB */
261 static short agc_baltime = 0;
262 /* AGC maximum gain */
263 static short agc_maxgain;
264 #endif /* HAVE_AGC */
266 static void set_gain(void)
268 if(global_settings.rec_source == AUDIO_SRC_MIC)
270 audio_set_recording_gain(global_settings.rec_mic_gain,
271 0, AUDIO_GAIN_MIC);
273 else
275 /* AUDIO_SRC_LINEIN, AUDIO_SRC_FMRADIO, AUDIO_SRC_SPDIF */
276 audio_set_recording_gain(global_settings.rec_left_gain,
277 global_settings.rec_right_gain,
278 AUDIO_GAIN_LINEIN);
280 /* reset the clipping indicators */
281 peak_meter_set_clip_hold(global_settings.peak_meter_clip_hold);
284 #ifdef HAVE_AGC
285 /* Read peak meter values & calculate balance.
286 * Returns validity of peak values.
287 * Used for automatic gain control and history diagram.
289 static bool read_peak_levels(int *peak_l, int *peak_r, int *balance)
291 peak_meter_get_peakhold(peak_l, peak_r);
292 peak_valid_mem[peak_time % 3] = *peak_l;
293 if (((peak_valid_mem[0] == peak_valid_mem[1]) &&
294 (peak_valid_mem[1] == peak_valid_mem[2])) &&
295 ((*peak_l < 32767)
296 #ifndef SIMULATOR
297 || ata_disk_is_active()
298 #endif
300 return false;
302 if (*peak_r > *peak_l)
303 balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_l ?
304 MIN((10000 * *peak_r) / *peak_l - 10000, 15118) : 15118);
305 else
306 balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_r ?
307 MAX(10000 - (10000 * *peak_l) / *peak_r, -15118) : -15118);
308 *balance = 0;
309 int i;
310 for (i = 0; i < BAL_MEM_SIZE; i++)
311 *balance += balance_mem[i];
312 *balance = *balance / BAL_MEM_SIZE;
314 return true;
317 /* AGC helper function to check if maximum gain is reached */
318 static bool agc_gain_is_max(bool left, bool right)
320 /* range -128...+108 [0.5dB] */
321 short gain_current_l;
322 short gain_current_r;
324 if (agc_preset == 0)
325 return false;
327 switch (global_settings.rec_source)
329 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
330 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
331 gain_current_l = global_settings.rec_left_gain;
332 gain_current_r = global_settings.rec_right_gain;
333 break;
334 case AUDIO_SRC_MIC:
335 default:
336 gain_current_l = global_settings.rec_mic_gain;
337 gain_current_r = global_settings.rec_mic_gain;
340 return ((left && (gain_current_l >= agc_maxgain)) ||
341 (right && (gain_current_r >= agc_maxgain)));
344 static void change_recording_gain(bool increment, bool left, bool right)
346 int factor = (increment ? 1 : -1);
348 switch (global_settings.rec_source)
350 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
351 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
352 if (left) global_settings.rec_left_gain += factor;
353 if (right) global_settings.rec_right_gain += factor;
354 break;
355 case AUDIO_SRC_MIC:
356 global_settings.rec_mic_gain += factor;
361 * Handle automatic gain control (AGC).
362 * Change recording gain if peak_x levels are above or below
363 * target volume for specified timeouts.
365 static void auto_gain_control(int *peak_l, int *peak_r, int *balance)
367 int agc_mono;
368 short agc_mode;
369 bool increment;
371 if (*peak_l > agc_left)
372 agc_left = *peak_l;
373 else
374 agc_left -= (agc_left - *peak_l + 3) >> 2;
375 if (*peak_r > agc_right)
376 agc_right = *peak_r;
377 else
378 agc_right -= (agc_right - *peak_r + 3) >> 2;
379 agc_mono = (agc_left + agc_right) / 2;
381 agc_mode = abs(agc_preset) - 1;
382 if (agc_mode < 0) {
383 agc_enable = false;
384 return;
387 if (agc_mode != AGC_SAFETY_MODE) {
388 /* Automatic balance control - only if not in safety mode */
389 if ((agc_left > AGC_IMG) && (agc_right > AGC_IMG))
391 if (*balance < -556)
393 if (*balance > -900)
394 agc_baltime -= !(peak_time % 4); /* 0.47 - 0.75dB */
395 else if (*balance > -4125)
396 agc_baltime--; /* 0.75 - 3.00dB */
397 else if (*balance > -7579)
398 agc_baltime -= 2; /* 3.00 - 4.90dB */
399 else
400 agc_baltime -= !(peak_time % 8); /* 4.90 - inf dB */
401 if (agc_baltime > 0)
402 agc_baltime -= (peak_time % 2);
404 else if (*balance > 556)
406 if (*balance < 900)
407 agc_baltime += !(peak_time % 4);
408 else if (*balance < 4125)
409 agc_baltime++;
410 else if (*balance < 7579)
411 agc_baltime += 2;
412 else
413 agc_baltime += !(peak_time % 8);
414 if (agc_baltime < 0)
415 agc_baltime += (peak_time % 2);
418 if ((*balance * agc_baltime) < 0)
420 if (*balance < 0)
421 agc_baltime -= peak_time % 2;
422 else
423 agc_baltime += peak_time % 2;
426 increment = ((agc_risetime / 2) > agc_droptime);
428 if (agc_baltime < -agc_tbal[agc_mode])
430 if (!increment || !agc_gain_is_max(!increment, increment)) {
431 change_recording_gain(increment, !increment, increment);
432 set_gain();
434 agc_baltime = 0;
436 else if (agc_baltime > +agc_tbal[agc_mode])
438 if (!increment || !agc_gain_is_max(increment, !increment)) {
439 change_recording_gain(increment, increment, !increment);
440 set_gain();
442 agc_baltime = 0;
445 else if (!(hist_time % 4))
447 if (agc_baltime < 0)
448 agc_baltime++;
449 else
450 agc_baltime--;
454 /* Automatic gain control */
455 if ((agc_left > agc_th_hi[agc_mode]) || (agc_right > agc_th_hi[agc_mode]))
457 if ((agc_left > AGC_CLIP) || (agc_right > AGC_CLIP))
458 agc_droptime += agc_tdrop[agc_mode] /
459 (global_settings.rec_agc_cliptime + 1);
460 if (agc_left > AGC_HIGH) {
461 agc_droptime++;
462 agc_risetime=0;
463 if (agc_left > AGC_PEAK)
464 agc_droptime += 2;
466 if (agc_right > AGC_HIGH) {
467 agc_droptime++;
468 agc_risetime=0;
469 if (agc_right > AGC_PEAK)
470 agc_droptime += 2;
472 if (agc_mono > agc_th_hi[agc_mode])
473 agc_droptime++;
474 else
475 agc_droptime += !(peak_time % 2);
477 if (agc_droptime >= agc_tdrop[agc_mode])
479 change_recording_gain(false, true, true);
480 agc_droptime = 0;
481 agc_risetime = 0;
482 set_gain();
484 agc_risetime = MAX(agc_risetime - 1, 0);
486 else if (agc_mono < agc_th_lo[agc_mode])
488 if (agc_mono < (agc_th_lo[agc_mode] / 8))
489 agc_risetime += !(peak_time % 5);
490 else if (agc_mono < (agc_th_lo[agc_mode] / 2))
491 agc_risetime += 2;
492 else
493 agc_risetime++;
495 if (agc_risetime >= agc_trise[agc_mode]) {
496 if ((agc_mode != AGC_SAFETY_MODE) &&
497 (!agc_gain_is_max(true, true))) {
498 change_recording_gain(true, true, true);
499 set_gain();
501 agc_risetime = 0;
502 agc_droptime = 0;
504 agc_droptime = MAX(agc_droptime - 1, 0);
506 else if (!(peak_time % 6)) /* on target level every 1.2 sec */
508 agc_risetime = MAX(agc_risetime - 1, 0);
509 agc_droptime = MAX(agc_droptime - 1, 0);
512 #endif /* HAVE_AGC */
514 static const char* const fmtstr[] =
516 "%c%d %s", /* no decimals */
517 "%c%d.%d %s ", /* 1 decimal */
518 "%c%d.%02d %s " /* 2 decimals */
521 static char *fmt_gain(int snd, int val, char *str, int len)
523 int i, d, numdec;
524 const char *unit;
525 char sign = ' ';
527 val = sound_val2phys(snd, val);
528 if(val < 0)
530 sign = '-';
531 val = -val;
533 numdec = sound_numdecimals(snd);
534 unit = sound_unit(snd);
536 if(numdec)
538 i = val / (10*numdec);
539 d = val % (10*numdec);
540 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
542 else
543 snprintf(str, len, fmtstr[numdec], sign, val, unit);
545 return str;
548 static int cursor;
550 static void adjust_cursor(void)
552 int max_cursor;
554 if(cursor < 0)
555 cursor = 0;
557 #ifdef HAVE_AGC
558 switch(global_settings.rec_source)
560 case REC_SRC_MIC:
561 if(cursor == 2)
562 cursor = 4;
563 else if(cursor == 3)
564 cursor = 1;
565 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
566 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
567 max_cursor = 5;
568 break;
569 default:
570 max_cursor = 0;
571 break;
573 #else /* !HAVE_AGC */
574 switch(global_settings.rec_source)
576 case AUDIO_SRC_MIC:
577 max_cursor = 1;
578 break;
579 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
580 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
581 max_cursor = 3;
582 break;
583 default:
584 max_cursor = 0;
585 break;
587 #endif /* HAVE_AGC */
589 if(cursor > max_cursor)
590 cursor = max_cursor;
593 /* the list below must match enum audio_sources in audio.h */
594 static const char* const prestr[] =
596 HAVE_MIC_IN_([AUDIO_SRC_MIC] = "R_MIC_",)
597 HAVE_LINE_REC_([AUDIO_SRC_LINEIN] = "R_LINE_",)
598 HAVE_SPDIF_IN_([AUDIO_SRC_SPDIF] = "R_SPDIF_",)
599 HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO] = "R_FM_",)
602 char *rec_create_filename(char *buffer)
604 char ext[16];
605 const char *pref = "R_";
607 /* Directory existence and writeablility should have already been
608 * verified - do not pass NULL pointers to pcmrec */
610 if((unsigned)global_settings.rec_source < AUDIO_NUM_SOURCES)
612 pref = prestr[global_settings.rec_source];
615 strcpy(buffer, global_settings.rec_directory);
617 snprintf(ext, sizeof(ext), ".%s",
618 REC_FILE_ENDING(global_settings.rec_format));
620 #if CONFIG_RTC == 0
621 return create_numbered_filename(buffer, buffer, pref, ext, 4,
622 &file_number);
623 #else
624 /* We'll wait at least up to the start of the next second so no duplicate
625 names are created */
626 return create_datetime_filename(buffer, buffer, pref, ext, true);
627 #endif
630 #if CONFIG_RTC == 0
631 /* Hit disk to get a starting filename for the type */
632 static void rec_init_filename(void)
634 file_number = -1;
635 rec_create_filename(path_buffer);
636 file_number--;
638 #endif
640 int rec_create_directory(void)
642 int rc = 0;
643 const char * const folder = global_settings.rec_directory;
645 if (strcmp(folder, "/") && !dir_exists(folder))
647 rc = mkdir(folder);
649 if(rc < 0)
651 while (action_userabort(HZ) == false)
653 gui_syncsplash(0, "%s %s",
654 str(LANG_REC_DIR_NOT_WRITABLE),
655 str(LANG_OFF_ABORT));
658 else
660 rec_status |= RCSTAT_CREATED_DIRECTORY;
661 rc = 1;
665 return rc;
668 void rec_init_recording_options(struct audio_recording_options *options)
670 options->rec_source = global_settings.rec_source;
671 options->rec_frequency = global_settings.rec_frequency;
672 options->rec_channels = global_settings.rec_channels;
673 options->rec_prerecord_time = global_settings.rec_prerecord_time;
674 #if CONFIG_CODEC == SWCODEC
675 options->rec_source_flags = 0;
676 options->enc_config.rec_format = global_settings.rec_format;
677 global_to_encoder_config(&options->enc_config);
678 #else
679 options->rec_quality = global_settings.rec_quality;
680 options->rec_editable = global_settings.rec_editable;
681 #endif
684 #if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
685 void rec_set_source(int source, unsigned flags)
687 /* Set audio input source, power up/down devices */
688 audio_set_input_source(source, flags);
690 /* Set peakmeters for recording or reset to playback */
691 peak_meter_playback((flags & SRCF_RECORDING) == 0);
692 peak_meter_enabled = true;
694 #endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
696 void rec_set_recording_options(struct audio_recording_options *options)
698 #if CONFIG_CODEC != SWCODEC
699 if (global_settings.rec_prerecord_time)
701 talk_buffer_steal(); /* will use the mp3 buffer */
703 #else /* == SWCODEC */
704 rec_set_source(options->rec_source,
705 options->rec_source_flags | SRCF_RECORDING);
706 #endif /* CONFIG_CODEC != SWCODEC */
708 audio_set_recording_options(options);
711 void rec_command(enum recording_command cmd)
713 switch(cmd)
715 case RECORDING_CMD_STOP_SHUTDOWN:
716 pm_activate_clipcount(false);
717 audio_stop_recording();
718 #if CONFIG_CODEC == SWCODEC
719 audio_close_recording();
720 #endif
721 sys_poweroff();
722 break;
723 case RECORDING_CMD_STOP:
724 pm_activate_clipcount(false);
725 audio_stop_recording();
726 break;
727 case RECORDING_CMD_START:
728 /* steal mp3 buffer, create unique filename and start recording */
729 pm_reset_clipcount();
730 pm_activate_clipcount(true);
731 #if CONFIG_CODEC != SWCODEC
732 talk_buffer_steal(); /* we use the mp3 buffer */
733 #endif
734 audio_record(rec_create_filename(path_buffer));
735 break;
736 case RECORDING_CMD_START_NEWFILE:
737 /* create unique filename and start recording*/
738 pm_reset_clipcount();
739 pm_activate_clipcount(true); /* just to be sure */
740 audio_new_file(rec_create_filename(path_buffer));
741 break;
742 case RECORDING_CMD_PAUSE:
743 pm_activate_clipcount(false);
744 audio_pause_recording();
745 break;
746 case RECORDING_CMD_RESUME:
747 pm_activate_clipcount(true);
748 audio_resume_recording();
749 break;
753 /* used in trigger_listerner and recording_screen */
754 static unsigned int last_seconds = 0;
757 * Callback function so that the peak meter code can send an event
758 * to this application. This function can be passed to
759 * peak_meter_set_trigger_listener in order to activate the trigger.
761 static void trigger_listener(int trigger_status)
763 switch (trigger_status)
765 case TRIG_GO:
766 if(!(audio_status() & AUDIO_STATUS_RECORD))
768 rec_status |= RCSTAT_HAVE_RECORDED;
769 rec_command(RECORDING_CMD_START);
770 #if CONFIG_CODEC != SWCODEC
771 /* give control to mpeg thread so that it can start
772 recording */
773 yield(); yield(); yield();
774 #endif
777 /* if we're already recording this is a retrigger */
778 else
780 if((audio_status() & AUDIO_STATUS_PAUSE) &&
781 (global_settings.rec_trigger_type == TRIG_TYPE_PAUSE))
783 rec_command(RECORDING_CMD_RESUME);
785 /* New file on trig start*/
786 else if (global_settings.rec_trigger_type != TRIG_TYPE_NEW_FILE)
788 rec_command(RECORDING_CMD_START_NEWFILE);
789 /* tell recording_screen to reset the time */
790 last_seconds = 0;
793 break;
795 /* A _change_ to TRIG_READY means the current recording has stopped */
796 case TRIG_READY:
797 if(audio_status() & AUDIO_STATUS_RECORD)
799 switch(global_settings.rec_trigger_type)
801 case TRIG_TYPE_STOP: /* Stop */
802 rec_command(RECORDING_CMD_STOP);
803 break;
805 case TRIG_TYPE_PAUSE: /* Pause */
806 rec_command(RECORDING_CMD_PAUSE);
807 break;
809 case TRIG_TYPE_NEW_FILE: /* New file on trig stop*/
810 rec_command(RECORDING_CMD_START_NEWFILE);
811 /* tell recording_screen to reset the time */
812 last_seconds = 0;
813 break;
815 case 3: /* Stop and shutdown */
816 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
817 break;
820 if (global_settings.rec_trigger_mode != TRIG_MODE_REARM)
822 peak_meter_set_trigger_listener(NULL);
823 peak_meter_trigger(false);
826 break;
830 bool recording_start_automatic = false;
832 bool recording_screen(bool no_source)
834 long button;
835 bool done = false;
836 char buf[32];
837 char buf2[32];
838 int w, h;
839 int update_countdown = 1;
840 unsigned int seconds;
841 int hours, minutes;
842 char filename[13];
843 int last_audio_stat = -1;
844 int audio_stat;
845 #if CONFIG_CODEC == SWCODEC
846 int warning_counter = 0;
847 #define WARNING_PERIOD 7
848 #endif
849 #ifdef HAVE_FMRADIO_REC
850 /* Radio is left on if:
851 * 1) Is was on at the start and the initial source is FM Radio
852 * 2) 1) and the source was never changed to something else
854 int radio_status = (global_settings.rec_source != AUDIO_SRC_FMRADIO) ?
855 FMRADIO_OFF : get_radio_status();
856 #endif
857 #if (CONFIG_LED == LED_REAL)
858 bool led_state = false;
859 int led_countdown = 2;
860 #endif
861 #ifdef HAVE_AGC
862 bool peak_read = false;
863 bool peak_valid = false;
864 int peak_l, peak_r;
865 int balance = 0;
866 bool display_agc[NB_SCREENS];
867 #endif
868 int line[NB_SCREENS];
869 int i;
870 int filename_offset[NB_SCREENS];
871 int pm_y[NB_SCREENS];
872 int trig_xpos[NB_SCREENS];
873 int trig_ypos[NB_SCREENS];
874 int trig_width[NB_SCREENS];
875 /* pm_x = offset pm to put clipcount in front.
876 Use lcd_getstringsize() when not using SYSFONT */
877 int pm_x = global_settings.peak_meter_clipcounter ? 30 : 0;
879 static const unsigned char *byte_units[] = {
880 ID2P(LANG_BYTE),
881 ID2P(LANG_KILOBYTE),
882 ID2P(LANG_MEGABYTE),
883 ID2P(LANG_GIGABYTE)
886 int base_style = STYLE_INVERT;
887 int style;
888 struct viewport vp[NB_SCREENS];
889 int ymargin = global_settings.cursor_style?0:10;
890 #ifdef HAVE_LCD_COLOR
891 if (global_settings.cursor_style == 2) {
892 base_style |= STYLE_COLORBAR;
894 else if (global_settings.cursor_style == 3) {
895 base_style |= STYLE_GRADIENT;
897 #endif
899 struct audio_recording_options rec_options;
900 rec_status = RCSTAT_IN_RECSCREEN;
902 if (rec_create_directory() < 0)
904 rec_status = 0;
905 return false;
908 cursor = 0;
909 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
910 ata_set_led_enabled(false);
911 #endif
913 #if CONFIG_CODEC == SWCODEC
914 /* recording_menu gets messed up: so prevent manus talking */
915 talk_disable(true);
916 /* audio_init_recording stops anything playing when it takes the audio
917 buffer */
918 #else
919 /* Yes, we use the D/A for monitoring */
920 peak_meter_enabled = true;
921 peak_meter_playback(true);
922 #endif
924 audio_init_recording(0);
925 sound_set_volume(global_settings.volume);
927 #ifdef HAVE_AGC
928 peak_meter_get_peakhold(&peak_l, &peak_r);
929 #endif
931 rec_init_recording_options(&rec_options);
932 rec_set_recording_options(&rec_options);
934 set_gain();
936 #if CONFIG_RTC == 0
937 /* Create new filename for recording start */
938 rec_init_filename();
939 #endif
941 pm_reset_clipcount();
942 pm_activate_clipcount(false);
943 settings_apply_trigger();
945 #ifdef HAVE_AGC
946 agc_preset_str[0] = str(LANG_SYSFONT_OFF);
947 agc_preset_str[1] = str(LANG_SYSFONT_AGC_SAFETY);
948 agc_preset_str[2] = str(LANG_SYSFONT_AGC_LIVE);
949 agc_preset_str[3] = str(LANG_SYSFONT_AGC_DJSET);
950 agc_preset_str[4] = str(LANG_SYSFONT_AGC_MEDIUM);
951 agc_preset_str[5] = str(LANG_SYSFONT_AGC_VOICE);
952 if (global_settings.rec_source == AUDIO_SRC_MIC) {
953 agc_preset = global_settings.rec_agc_preset_mic;
954 agc_maxgain = global_settings.rec_agc_maxgain_mic;
956 else {
957 agc_preset = global_settings.rec_agc_preset_line;
958 agc_maxgain = global_settings.rec_agc_maxgain_line;
960 #endif /* HAVE_AGC */
962 FOR_NB_SCREENS(i)
964 viewport_set_defaults(&vp[i], i);
965 vp[i].font = FONT_SYSFIXED;
966 screens[i].set_viewport(&vp[i]);
967 screens[i].getstringsize("M", &w, &h);
968 filename_offset[i] = ((vp[i].height >= 80) ? 1 : 0);
969 pm_y[i] = h * (2 + filename_offset[i]);
972 #ifdef HAVE_REMOTE_LCD
973 if (!remote_display_on)
975 screens[1].clear_display();
976 snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON));
977 screens[1].puts((vp[1].width/w - strlen(buf))/2 + 1,
978 vp[1].height/(h*2) + 1, buf);
979 screens[1].update();
980 gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF));
982 #endif
984 while(!done)
986 audio_stat = audio_status();
988 #if (CONFIG_LED == LED_REAL)
991 * Flash the LED while waiting to record. Turn it on while
992 * recording.
994 if(audio_stat & AUDIO_STATUS_RECORD)
996 if (audio_stat & AUDIO_STATUS_PAUSE)
998 if (--led_countdown <= 0)
1000 led_state = !led_state;
1001 led(led_state);
1002 led_countdown = 2;
1005 else
1007 /* trigger is on in status TRIG_READY (no check needed) */
1008 led(true);
1011 else
1013 int trigStat = peak_meter_trigger_status();
1015 * other trigger stati than trig_off and trig_steady
1016 * already imply that we are recording.
1018 if (trigStat == TRIG_STEADY)
1020 if (--led_countdown <= 0)
1022 led_state = !led_state;
1023 led(led_state);
1024 led_countdown = 2;
1027 else
1029 /* trigger is on in status TRIG_READY (no check needed) */
1030 led(false);
1033 #endif /* CONFIG_LED */
1035 /* Wait for a button a while (HZ/10) drawing the peak meter */
1036 button = peak_meter_draw_get_btn(CONTEXT_RECSCREEN,
1037 pm_x, pm_y, h * PM_HEIGHT,
1038 screen_update);
1040 if (last_audio_stat != audio_stat)
1042 if (audio_stat & AUDIO_STATUS_RECORD)
1044 rec_status |= RCSTAT_HAVE_RECORDED;
1046 last_audio_stat = audio_stat;
1050 if (recording_start_automatic)
1052 /* simulate a button press */
1053 button = ACTION_REC_PAUSE;
1054 recording_start_automatic = false;
1057 switch(button)
1059 #ifdef HAVE_REMOTE_LCD
1060 case ACTION_REC_LCD:
1061 if (remote_display_on)
1063 remote_display_on = false;
1064 screen_update = 1;
1065 screens[1].clear_display();
1066 snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON));
1067 screens[1].puts((screens[1].getwidth()/w - strlen(buf))/2 +
1069 screens[1].getheight()/(h*2) + 1, buf);
1070 screens[1].update();
1071 gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF));
1073 else
1075 remote_display_on = true;
1076 screen_update = NB_SCREENS;
1078 break;
1079 #endif
1080 case ACTION_STD_CANCEL:
1081 /* turn off the trigger */
1082 peak_meter_trigger(false);
1083 peak_meter_set_trigger_listener(NULL);
1085 if(audio_stat & AUDIO_STATUS_RECORD)
1087 rec_command(RECORDING_CMD_STOP);
1089 else
1091 #if CONFIG_CODEC != SWCODEC
1092 peak_meter_playback(true);
1093 peak_meter_enabled = false;
1094 #endif
1095 done = true;
1097 update_countdown = 1; /* Update immediately */
1098 break;
1100 case ACTION_REC_PAUSE:
1101 case ACTION_REC_NEWFILE:
1102 /* Only act if the mpeg is stopped */
1103 if(!(audio_stat & AUDIO_STATUS_RECORD))
1105 /* is this manual or triggered recording? */
1106 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1107 (peak_meter_trigger_status() != TRIG_OFF))
1109 /* manual recording */
1110 rec_status |= RCSTAT_HAVE_RECORDED;
1111 rec_command(RECORDING_CMD_START);
1112 last_seconds = 0;
1113 if (global_settings.talk_menu)
1115 /* no voice possible here, but a beep */
1116 audio_beep(HZ/2); /* longer beep on start */
1119 /* this is triggered recording */
1120 else
1122 /* we don't start recording now, but enable the
1123 trigger and let the callback function
1124 trigger_listener control when the recording starts */
1125 peak_meter_trigger(true);
1126 peak_meter_set_trigger_listener(&trigger_listener);
1129 else
1131 /*if new file button pressed, start new file */
1132 if (button == ACTION_REC_NEWFILE)
1134 rec_command(RECORDING_CMD_START_NEWFILE);
1135 last_seconds = 0;
1137 else
1138 /* if pause button pressed, pause or resume */
1140 if(audio_stat & AUDIO_STATUS_PAUSE)
1142 rec_command(RECORDING_CMD_RESUME);
1143 if (global_settings.talk_menu)
1145 /* no voice possible here, but a beep */
1146 audio_beep(HZ/4); /* short beep on resume */
1149 else
1151 rec_command(RECORDING_CMD_PAUSE);
1155 update_countdown = 1; /* Update immediately */
1156 break;
1158 case ACTION_STD_PREV:
1159 cursor--;
1160 adjust_cursor();
1161 update_countdown = 1; /* Update immediately */
1162 break;
1164 case ACTION_STD_NEXT:
1165 cursor++;
1166 adjust_cursor();
1167 update_countdown = 1; /* Update immediately */
1168 break;
1170 case ACTION_SETTINGS_INC:
1171 case ACTION_SETTINGS_INCREPEAT:
1172 switch(cursor)
1174 case 0:
1175 global_settings.volume++;
1176 setvol();
1177 break;
1178 case 1:
1179 if(global_settings.rec_source == AUDIO_SRC_MIC)
1181 if(global_settings.rec_mic_gain <
1182 sound_max(SOUND_MIC_GAIN))
1183 global_settings.rec_mic_gain++;
1185 else
1187 if(global_settings.rec_left_gain <
1188 sound_max(SOUND_LEFT_GAIN))
1189 global_settings.rec_left_gain++;
1190 if(global_settings.rec_right_gain <
1191 sound_max(SOUND_RIGHT_GAIN))
1192 global_settings.rec_right_gain++;
1194 break;
1195 case 2:
1196 if(global_settings.rec_left_gain <
1197 sound_max(SOUND_LEFT_GAIN))
1198 global_settings.rec_left_gain++;
1199 break;
1200 case 3:
1201 if(global_settings.rec_right_gain <
1202 sound_max(SOUND_RIGHT_GAIN))
1203 global_settings.rec_right_gain++;
1204 break;
1205 #ifdef HAVE_AGC
1206 case 4:
1207 agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE);
1208 agc_enable = (agc_preset != 0);
1209 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1210 global_settings.rec_agc_preset_mic = agc_preset;
1211 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1212 } else {
1213 global_settings.rec_agc_preset_line = agc_preset;
1214 agc_maxgain = global_settings.rec_agc_maxgain_line;
1216 break;
1217 case 5:
1218 if (global_settings.rec_source == AUDIO_SRC_MIC)
1220 agc_maxgain = MIN(agc_maxgain + 1,
1221 sound_max(SOUND_MIC_GAIN));
1222 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1224 else
1226 agc_maxgain = MIN(agc_maxgain + 1,
1227 sound_max(SOUND_LEFT_GAIN));
1228 global_settings.rec_agc_maxgain_line = agc_maxgain;
1230 break;
1231 #endif /* HAVE_AGC */
1233 set_gain();
1234 update_countdown = 1; /* Update immediately */
1235 break;
1237 case ACTION_SETTINGS_DEC:
1238 case ACTION_SETTINGS_DECREPEAT:
1239 switch(cursor)
1241 case 0:
1242 global_settings.volume--;
1243 setvol();
1244 break;
1245 case 1:
1246 if(global_settings.rec_source == AUDIO_SRC_MIC)
1248 if(global_settings.rec_mic_gain >
1249 sound_min(SOUND_MIC_GAIN))
1250 global_settings.rec_mic_gain--;
1252 else
1254 if(global_settings.rec_left_gain >
1255 sound_min(SOUND_LEFT_GAIN))
1256 global_settings.rec_left_gain--;
1257 if(global_settings.rec_right_gain >
1258 sound_min(SOUND_RIGHT_GAIN))
1259 global_settings.rec_right_gain--;
1261 break;
1262 case 2:
1263 if(global_settings.rec_left_gain >
1264 sound_min(SOUND_LEFT_GAIN))
1265 global_settings.rec_left_gain--;
1266 break;
1267 case 3:
1268 if(global_settings.rec_right_gain >
1269 sound_min(SOUND_RIGHT_GAIN))
1270 global_settings.rec_right_gain--;
1271 break;
1272 #ifdef HAVE_AGC
1273 case 4:
1274 agc_preset = MAX(agc_preset - 1, 0);
1275 agc_enable = (agc_preset != 0);
1276 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1277 global_settings.rec_agc_preset_mic = agc_preset;
1278 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1279 } else {
1280 global_settings.rec_agc_preset_line = agc_preset;
1281 agc_maxgain = global_settings.rec_agc_maxgain_line;
1283 break;
1284 case 5:
1285 if (global_settings.rec_source == AUDIO_SRC_MIC)
1287 agc_maxgain = MAX(agc_maxgain - 1,
1288 sound_min(SOUND_MIC_GAIN));
1289 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1291 else
1293 agc_maxgain = MAX(agc_maxgain - 1,
1294 sound_min(SOUND_LEFT_GAIN));
1295 global_settings.rec_agc_maxgain_line = agc_maxgain;
1297 break;
1298 #endif /* HAVE_AGC */
1300 set_gain();
1301 update_countdown = 1; /* Update immediately */
1302 break;
1304 case ACTION_STD_MENU:
1305 #if CONFIG_CODEC == SWCODEC
1306 if(!(audio_stat & AUDIO_STATUS_RECORD))
1307 #else
1308 if(audio_stat != AUDIO_STATUS_RECORD)
1309 #endif
1311 #ifdef HAVE_FMRADIO_REC
1312 const int prev_rec_source = global_settings.rec_source;
1313 #endif
1315 #if (CONFIG_LED == LED_REAL)
1316 /* led is restored at begin of loop / end of function */
1317 led(false);
1318 #endif
1319 if (recording_menu(no_source))
1321 done = true;
1322 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1323 #ifdef HAVE_FMRADIO_REC
1324 radio_status = FMRADIO_OFF;
1325 #endif
1327 else
1329 #ifdef HAVE_FMRADIO_REC
1330 /* If input changes away from FM Radio, radio will
1331 remain off when recording screen closes. */
1332 if (global_settings.rec_source != prev_rec_source
1333 && prev_rec_source == AUDIO_SRC_FMRADIO)
1334 radio_status = FMRADIO_OFF;
1335 #endif
1337 #if CONFIG_CODEC == SWCODEC
1338 /* reinit after submenu exit */
1339 audio_close_recording();
1340 audio_init_recording(0);
1341 #endif
1343 rec_init_recording_options(&rec_options);
1344 rec_set_recording_options(&rec_options);
1346 if(rec_create_directory() < 0)
1348 goto rec_abort;
1351 #if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
1352 /* If format changed, a new number is required */
1353 rec_init_filename();
1354 #endif
1356 #ifdef HAVE_AGC
1357 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1358 agc_preset = global_settings.rec_agc_preset_mic;
1359 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1361 else {
1362 agc_preset = global_settings.rec_agc_preset_line;
1363 agc_maxgain = global_settings.rec_agc_maxgain_line;
1365 #endif
1367 adjust_cursor();
1368 set_gain();
1369 update_countdown = 1; /* Update immediately */
1371 FOR_NB_SCREENS(i)
1373 screens[i].set_viewport(&vp[i]);
1374 screens[i].setfont(FONT_SYSFIXED);
1378 break;
1380 #if CONFIG_KEYPAD == RECORDER_PAD
1381 case ACTION_REC_F2:
1382 if(audio_stat != AUDIO_STATUS_RECORD)
1384 #if (CONFIG_LED == LED_REAL)
1385 /* led is restored at begin of loop / end of function */
1386 led(false);
1387 #endif
1388 if (f2_rec_screen())
1390 rec_status |= RCSTAT_HAVE_RECORDED;
1391 done = true;
1393 else
1394 update_countdown = 1; /* Update immediately */
1396 break;
1398 case ACTION_REC_F3:
1399 if(audio_stat & AUDIO_STATUS_RECORD)
1401 rec_command(RECORDING_CMD_START_NEWFILE);
1402 last_seconds = 0;
1404 else
1406 #if (CONFIG_LED == LED_REAL)
1407 /* led is restored at begin of loop / end of function */
1408 led(false);
1409 #endif
1410 if (f3_rec_screen())
1412 rec_status |= RCSTAT_HAVE_RECORDED;
1413 done = true;
1415 else
1416 update_countdown = 1; /* Update immediately */
1418 break;
1419 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
1421 case SYS_USB_CONNECTED:
1422 /* Only accept USB connection when not recording */
1423 if(!(audio_stat & AUDIO_STATUS_RECORD))
1425 default_event_handler(SYS_USB_CONNECTED);
1426 done = true;
1427 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1428 #ifdef HAVE_FMRADIO_REC
1429 radio_status = FMRADIO_OFF;
1430 #endif
1432 break;
1434 default:
1435 default_event_handler(button);
1436 break;
1437 } /* end switch */
1439 #ifdef HAVE_AGC
1440 peak_read = !peak_read;
1441 if (peak_read) { /* every 2nd run of loop */
1442 peak_time++;
1443 peak_valid = read_peak_levels(&peak_l, &peak_r, &balance);
1446 /* Handle AGC every 200ms when enabled and peak data is valid */
1447 if (peak_read && agc_enable && peak_valid)
1448 auto_gain_control(&peak_l, &peak_r, &balance);
1449 #endif
1451 FOR_NB_SCREENS(i)
1452 screens[i].setfont(FONT_SYSFIXED);
1454 seconds = audio_recorded_time() / HZ;
1456 update_countdown--;
1457 if(update_countdown == 0 || seconds > last_seconds)
1459 unsigned int dseconds, dhours, dminutes;
1460 unsigned long num_recorded_bytes, dsize, dmb;
1461 int pos = 0;
1463 update_countdown = 5;
1464 last_seconds = seconds;
1466 dseconds = rec_timesplit_seconds();
1467 dsize = rec_sizesplit_bytes();
1468 num_recorded_bytes = audio_num_recorded_bytes();
1470 for(i = 0; i < screen_update; i++)
1471 screens[i].clear_display();
1473 style = base_style;
1475 #ifdef HAVE_LCD_COLOR
1476 /* special action for gradient - set default for 1 line gradient */
1477 if(global_settings.cursor_style == 3)
1478 style = base_style | CURLN_PACK(0) | NUMLN_PACK(1);
1479 #endif /* HAVE_LCD_COLOR */
1481 #if CONFIG_CODEC == SWCODEC
1482 if ((audio_stat & AUDIO_STATUS_WARNING)
1483 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
1485 /* Switch back and forth displaying warning on first available
1486 line to ensure visibility - the motion should also help
1487 draw attention */
1488 /* Don't use language string unless agreed upon to make this
1489 method permanent - could do something in the statusbar */
1490 snprintf(buf, sizeof(buf), "Warning: %08X",
1491 pcm_rec_get_warnings());
1493 else
1494 #endif /* CONFIG_CODEC == SWCODEC */
1495 if ((global_settings.rec_sizesplit) &&
1496 (global_settings.rec_split_method))
1498 dmb = dsize/1024/1024;
1499 snprintf(buf, sizeof(buf), "%s %dMB",
1500 str(LANG_SYSFONT_SPLIT_SIZE), dmb);
1502 else
1504 hours = seconds / 3600;
1505 minutes = (seconds - (hours * 3600)) / 60;
1506 snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d",
1507 str(LANG_SYSFONT_RECORDING_TIME),
1508 hours, minutes, seconds%60);
1511 for(i = 0; i < screen_update; i++)
1512 screens[i].puts(0, 0, buf);
1514 if(audio_stat & AUDIO_STATUS_PRERECORD)
1516 snprintf(buf, sizeof(buf), "%s...",
1517 str(LANG_SYSFONT_RECORD_PRERECORD));
1519 else
1521 /* Display the split interval if the record timesplit
1522 is active */
1523 if ((global_settings.rec_timesplit) &&
1524 !(global_settings.rec_split_method))
1526 /* Display the record timesplit interval rather
1527 than the file size if the record timer is
1528 active */
1529 dhours = dseconds / 3600;
1530 dminutes = (dseconds - (dhours * 3600)) / 60;
1531 snprintf(buf, sizeof(buf), "%s %02d:%02d",
1532 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC),
1533 dhours, dminutes);
1535 else
1537 output_dyn_value(buf2, sizeof buf2,
1538 num_recorded_bytes,
1539 byte_units, true);
1540 snprintf(buf, sizeof(buf), "%s %s",
1541 str(LANG_SYSFONT_RECORDING_SIZE), buf2);
1544 for(i = 0; i < screen_update; i++)
1545 screens[i].puts(0, 1, buf);
1547 for(i = 0; i < screen_update; i++)
1549 if (filename_offset[i] > 0)
1551 *filename = '\0';
1552 if (audio_stat & AUDIO_STATUS_RECORD)
1554 strncpy(filename, path_buffer +
1555 strlen(path_buffer) - 12, 13);
1556 filename[12]='\0';
1559 snprintf(buf, sizeof(buf), "%s %s",
1560 str(LANG_SYSFONT_RECORDING_FILENAME), filename);
1561 screens[i].puts(0, 2, buf);
1565 /* We will do file splitting regardless, either at the end of
1566 a split interval, or when the filesize approaches the 2GB
1567 FAT file size (compatibility) limit. */
1568 if ((audio_stat && !(global_settings.rec_split_method)
1569 && global_settings.rec_timesplit && (seconds >= dseconds))
1570 || (audio_stat && global_settings.rec_split_method
1571 && global_settings.rec_sizesplit
1572 && (num_recorded_bytes >= dsize))
1573 || (num_recorded_bytes >= MAX_FILE_SIZE))
1575 if (!(global_settings.rec_split_type)
1576 || (num_recorded_bytes >= MAX_FILE_SIZE))
1578 rec_command(RECORDING_CMD_START_NEWFILE);
1579 last_seconds = 0;
1581 else
1583 peak_meter_trigger(false);
1584 peak_meter_set_trigger_listener(NULL);
1585 if( global_settings.rec_split_type == 1)
1586 rec_command(RECORDING_CMD_STOP);
1587 else
1588 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
1590 update_countdown = 1;
1593 /* draw the clipcounter just in front of the peakmeter */
1594 if(global_settings.peak_meter_clipcounter)
1596 char clpstr[32];
1597 snprintf(clpstr, 32, "%4d", pm_get_clipcount());
1598 for(i = 0; i < screen_update; i++)
1600 if(PM_HEIGHT > 1)
1601 screens[i].puts(0, 2 + filename_offset[i],
1602 str(LANG_SYSFONT_PM_CLIPCOUNT));
1603 screens[i].puts(0, 1 + PM_HEIGHT + filename_offset[i],
1604 clpstr);
1608 snprintf(buf, sizeof(buf), "%s: %s", str(LANG_SYSFONT_VOLUME),
1609 fmt_gain(SOUND_VOLUME,
1610 global_settings.volume,
1611 buf2, sizeof(buf2)));
1613 if (global_settings.cursor_style && (pos++ == cursor))
1615 for(i = 0; i < screen_update; i++)
1616 screens[i].puts_style_offset(0, filename_offset[i] +
1617 PM_HEIGHT + 2, buf, style,0);
1619 else
1621 for(i = 0; i < screen_update; i++)
1622 screens[i].putsxy(ymargin,
1623 SYSFONT_HEIGHT*(filename_offset[i]+
1624 PM_HEIGHT + 2), buf);
1627 if(global_settings.rec_source == AUDIO_SRC_MIC)
1629 /* Draw MIC recording gain */
1630 snprintf(buf, sizeof(buf), "%s:%s", str(LANG_SYSFONT_GAIN),
1631 fmt_gain(SOUND_MIC_GAIN,
1632 global_settings.rec_mic_gain,
1633 buf2, sizeof(buf2)));
1634 if(global_settings.cursor_style && ((1==cursor)||(2==cursor)))
1636 for(i = 0; i < screen_update; i++)
1637 screens[i].puts_style_offset(0, filename_offset[i] +
1638 PM_HEIGHT + 3, buf, style,0);
1640 else
1642 for(i = 0; i < screen_update; i++)
1643 screens[i].putsxy(ymargin,
1644 SYSFONT_HEIGHT*(filename_offset[i] +
1645 PM_HEIGHT + 3), buf);
1648 else if(0
1649 HAVE_LINE_REC_( || global_settings.rec_source ==
1650 AUDIO_SRC_LINEIN)
1651 HAVE_FMRADIO_REC_( || global_settings.rec_source ==
1652 AUDIO_SRC_FMRADIO)
1655 /* Draw LINE or FMRADIO recording gain */
1656 snprintf(buf, sizeof(buf), "%s:%s",
1657 str(LANG_SYSFONT_RECORDING_LEFT),
1658 fmt_gain(SOUND_LEFT_GAIN,
1659 global_settings.rec_left_gain,
1660 buf2, sizeof(buf2)));
1661 #ifdef HAVE_LCD_COLOR
1662 /* special action for gradient - double line gradient - line1 */
1663 if((global_settings.cursor_style == 3) &&
1664 (1==cursor))
1665 style = base_style | CURLN_PACK(0) | NUMLN_PACK(2);
1666 #endif /* HAVE_LCD_COLOR */
1667 if(global_settings.cursor_style && ((1==cursor)||(2==cursor)))
1669 for(i = 0; i < screen_update; i++)
1670 screens[i].puts_style_offset(0, filename_offset[i] +
1671 PM_HEIGHT + 3, buf, style,0);
1673 else
1675 for(i = 0; i < screen_update; i++)
1676 screens[i].putsxy(ymargin,
1677 SYSFONT_HEIGHT*(filename_offset[i] +
1678 PM_HEIGHT + 3), buf);
1681 snprintf(buf, sizeof(buf), "%s:%s",
1682 str(LANG_SYSFONT_RECORDING_RIGHT),
1683 fmt_gain(SOUND_RIGHT_GAIN,
1684 global_settings.rec_right_gain,
1685 buf2, sizeof(buf2)));
1686 #ifdef HAVE_LCD_COLOR
1687 /* special action for gradient - double line gradient - line2 */
1688 if((global_settings.cursor_style == 3) &&
1689 (1==cursor))
1690 style = base_style | CURLN_PACK(1) | NUMLN_PACK(2);
1691 #endif /* HAVE_LCD_COLOR */
1692 if(global_settings.cursor_style && ((1==cursor)||(3==cursor)))
1694 for(i = 0; i < screen_update; i++)
1695 screens[i].puts_style_offset(0, filename_offset[i] +
1696 PM_HEIGHT + 4, buf, style,0);
1698 else
1700 for(i = 0; i < screen_update; i++)
1701 screens[i].putsxy(ymargin,
1702 SYSFONT_HEIGHT*(filename_offset[i] +
1703 PM_HEIGHT + 4), buf);
1706 #ifdef HAVE_LCD_COLOR
1707 /* special action for gradient - back to single line gradient */
1708 if(global_settings.cursor_style == 3)
1709 style = base_style | CURLN_PACK(0) | NUMLN_PACK(1);
1710 #endif /* HAVE_LCD_COLOR */
1712 FOR_NB_SCREENS(i)
1714 switch (global_settings.rec_source)
1716 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
1717 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
1718 line[i] = 5;
1719 break;
1721 case AUDIO_SRC_MIC:
1722 line[i] = 4;
1723 break;
1724 #ifdef HAVE_SPDIF_REC
1725 case AUDIO_SRC_SPDIF:
1726 line[i] = 3;
1727 break;
1728 #endif
1729 default:
1730 line[i] = 5; /* to prevent uninitialisation
1731 warnings for line[0] */
1732 break;
1733 } /* end switch */
1734 #ifdef HAVE_AGC
1735 if (vp[i].height < h * (2 + filename_offset[i] +
1736 PM_HEIGHT + line[i]))
1738 line[i] -= 1;
1739 display_agc[i] = false;
1741 else
1742 display_agc[i] = true;
1744 if ((cursor==4) || (cursor==5))
1745 display_agc[i] = true;
1748 /************** AGC test info ******************
1749 snprintf(buf, sizeof(buf), "D:%d U:%d",
1750 (agc_droptime+2)/5, (agc_risetime+2)/5);
1751 lcd_putsxy(1, LCD_HEIGHT - 8, buf);
1752 snprintf(buf, sizeof(buf), "B:%d",
1753 (agc_baltime+2)/5);
1754 lcd_putsxy(LCD_WIDTH/2 + 3, LCD_HEIGHT - 8, buf);
1755 ***********************************************/
1757 if (cursor == 5)
1758 snprintf(buf, sizeof(buf), "%s: %s",
1759 str(LANG_SYSFONT_RECORDING_AGC_MAXGAIN),
1760 fmt_gain(SOUND_LEFT_GAIN,
1761 agc_maxgain, buf2, sizeof(buf2)));
1762 else if (agc_preset == 0)
1763 snprintf(buf, sizeof(buf), "%s: %s",
1764 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1765 agc_preset_str[agc_preset]);
1766 else if (global_settings.rec_source == AUDIO_SRC_MIC)
1767 snprintf(buf, sizeof(buf), "%s: %s%s",
1768 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1769 agc_preset_str[agc_preset],
1770 fmt_gain(SOUND_LEFT_GAIN,
1771 agc_maxgain -
1772 global_settings.rec_mic_gain,
1773 buf2, sizeof(buf2)));
1774 else
1775 snprintf(buf, sizeof(buf), "%s: %s%s",
1776 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1777 agc_preset_str[agc_preset],
1778 fmt_gain(SOUND_LEFT_GAIN,
1779 agc_maxgain -
1780 (global_settings.rec_left_gain +
1781 global_settings.rec_right_gain)/2,
1782 buf2, sizeof(buf2)));
1784 if(global_settings.cursor_style && ((cursor==4) || (cursor==5)))
1786 for(i = 0; i < screen_update; i++)
1787 screens[i].puts_style_offset(0, filename_offset[i] +
1788 PM_HEIGHT + line[i], buf, style,0);
1790 else if (global_settings.rec_source == AUDIO_SRC_MIC
1791 HAVE_LINE_REC_(|| global_settings.rec_source ==
1792 AUDIO_SRC_LINEIN)
1793 HAVE_FMRADIO_REC_(|| global_settings.rec_source ==
1794 AUDIO_SRC_FMRADIO)
1797 for(i = 0; i < screen_update; i++) {
1798 if (display_agc[i]) {
1799 screens[i].putsxy(ymargin,
1800 SYSFONT_HEIGHT*(filename_offset[i] +
1801 PM_HEIGHT + line[i]), buf);
1806 if (global_settings.rec_source == AUDIO_SRC_MIC)
1808 if(agc_maxgain < (global_settings.rec_mic_gain))
1809 change_recording_gain(false, true, true);
1811 else
1813 if(agc_maxgain < (global_settings.rec_left_gain))
1814 change_recording_gain(false, true, false);
1815 if(agc_maxgain < (global_settings.rec_right_gain))
1816 change_recording_gain(false, false, true);
1818 #else /* !HAVE_AGC */
1820 #endif /* HAVE_AGC */
1822 if(!global_settings.cursor_style) {
1823 switch(cursor)
1825 case 1:
1826 for(i = 0; i < screen_update; i++)
1827 screen_put_cursorxy(&screens[i], 0,
1828 filename_offset[i] +
1829 PM_HEIGHT + 3, true);
1831 if(global_settings.rec_source != AUDIO_SRC_MIC)
1833 for(i = 0; i < screen_update; i++)
1834 screen_put_cursorxy(&screens[i], 0,
1835 filename_offset[i] +
1836 PM_HEIGHT + 4, true);
1838 break;
1839 case 2:
1840 for(i = 0; i < screen_update; i++)
1841 screen_put_cursorxy(&screens[i], 0,
1842 filename_offset[i] +
1843 PM_HEIGHT + 3, true);
1844 break;
1845 case 3:
1846 for(i = 0; i < screen_update; i++)
1847 screen_put_cursorxy(&screens[i], 0,
1848 filename_offset[i] +
1849 PM_HEIGHT + 4, true);
1850 break;
1851 #ifdef HAVE_AGC
1852 case 4:
1853 case 5:
1854 for(i = 0; i < screen_update; i++)
1855 screen_put_cursorxy(&screens[i], 0,
1856 filename_offset[i] +
1857 PM_HEIGHT + line[i], true);
1858 break;
1859 #endif /* HAVE_AGC */
1860 default:
1861 for(i = 0; i < screen_update; i++)
1862 screen_put_cursorxy(&screens[i], 0,
1863 filename_offset[i] +
1864 PM_HEIGHT + 2, true);
1868 #ifdef HAVE_AGC
1869 hist_time++;
1870 #endif
1872 for(i = 0; i < screen_update; i++)
1874 screens[i].set_viewport(NULL);
1875 gui_statusbar_draw(&(statusbars.statusbars[i]), true);
1876 screens[i].set_viewport(&vp[i]);
1877 peak_meter_screen(&screens[i], pm_x, pm_y[i], h*PM_HEIGHT);
1878 screens[i].update();
1881 /* draw the trigger status */
1882 FOR_NB_SCREENS(i)
1884 /* NOTE: UGLY width setting based on height! To be fixed! */
1885 trig_width[i] = ((vp[i].height < 64) ||
1886 ((vp[i].height < 72) && (PM_HEIGHT > 1))) ?
1887 screens[i].getwidth() - 14 * w :
1888 screens[i].getwidth();
1889 trig_xpos[i] = screens[i].getwidth() - trig_width[i];
1890 trig_ypos[i] = ((vp[i].height < 72) && (PM_HEIGHT > 1)) ?
1891 h*2 :
1892 h*(1 + filename_offset[i] + PM_HEIGHT +
1893 line[i]
1894 #ifdef HAVE_AGC
1896 #endif
1900 if (peak_meter_trigger_status() != TRIG_OFF)
1902 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width,
1903 screen_update);
1904 for(i = 0; i < screen_update; i++){
1905 screens[i].update_rect(trig_xpos[i], trig_ypos[i],
1906 trig_width[i] + 2, TRIG_HEIGHT);
1911 if(audio_stat & AUDIO_STATUS_ERROR)
1913 done = true;
1915 } /* end while(!done) */
1917 audio_stat = audio_status();
1918 if (audio_stat & AUDIO_STATUS_ERROR)
1920 gui_syncsplash(0, str(LANG_SYSFONT_DISK_FULL));
1921 gui_syncstatusbar_draw(&statusbars, true);
1923 FOR_NB_SCREENS(i)
1924 screens[i].update();
1926 #if CONFIG_CODEC == SWCODEC
1927 /* stop recording - some players like H10 freeze otherwise
1928 TO DO: find out why it freezes and fix properly */
1929 rec_command(RECORDING_CMD_STOP);
1930 audio_close_recording();
1931 #endif
1933 audio_error_clear();
1935 while(1)
1937 if (action_userabort(TIMEOUT_NOBLOCK))
1938 break;
1942 rec_abort:
1944 #if CONFIG_CODEC == SWCODEC
1945 rec_command(RECORDING_CMD_STOP);
1946 audio_close_recording();
1948 #ifdef HAVE_FMRADIO_REC
1949 if (radio_status != FMRADIO_OFF)
1950 /* Restore radio playback - radio_status should be unchanged if started
1951 through fm radio screen (barring usb connect) */
1952 rec_set_source(AUDIO_SRC_FMRADIO, (radio_status & FMRADIO_PAUSED) ?
1953 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
1954 else
1955 #endif
1956 /* Go back to playback mode */
1957 rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
1959 /* restore talking */
1960 talk_disable(false);
1961 #else /* !SWCODEC */
1962 audio_init_playback();
1963 #endif /* CONFIG_CODEC == SWCODEC */
1965 /* make sure the trigger is really turned off */
1966 peak_meter_trigger(false);
1967 peak_meter_set_trigger_listener(NULL);
1969 rec_status &= ~RCSTAT_IN_RECSCREEN;
1970 sound_settings_apply();
1972 FOR_NB_SCREENS(i)
1973 screens[i].setfont(FONT_UI);
1975 /* if the directory was created or recording happened, make sure the
1976 browser is updated */
1977 if (rec_status & (RCSTAT_CREATED_DIRECTORY | RCSTAT_HAVE_RECORDED))
1978 reload_directory();
1980 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
1981 ata_set_led_enabled(true);
1982 #endif
1984 settings_save();
1986 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
1987 } /* recording_screen */
1989 #if CONFIG_KEYPAD == RECORDER_PAD
1990 static bool f2_rec_screen(void)
1992 static const char* const freq_str[6] =
1994 "44.1kHz",
1995 "48kHz",
1996 "32kHz",
1997 "22.05kHz",
1998 "24kHz",
1999 "16kHz"
2002 bool exit = false;
2003 bool used = false;
2004 int w, h, i;
2005 char buf[32];
2006 int button;
2007 struct audio_recording_options rec_options;
2009 FOR_NB_SCREENS(i)
2011 screens[i].setfont(FONT_SYSFIXED);
2012 screens[i].getstringsize("A",&w,&h);
2015 while (!exit) {
2016 const char* ptr=NULL;
2018 FOR_NB_SCREENS(i)
2020 screens[i].clear_display();
2022 /* Recording quality */
2023 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
2024 str(LANG_SYSFONT_RECORDING_QUALITY));
2027 snprintf(buf, sizeof(buf), "%d", global_settings.rec_quality);
2028 FOR_NB_SCREENS(i)
2030 screens[i].putsxy(0, LCD_HEIGHT/2-h, buf);
2031 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
2032 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
2035 /* Frequency */
2036 snprintf(buf, sizeof buf, "%s:", str(LANG_SYSFONT_RECORDING_FREQUENCY));
2037 ptr = freq_str[global_settings.rec_frequency];
2038 FOR_NB_SCREENS(i)
2040 screens[i].getstringsize(buf,&w,&h);
2041 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
2042 screens[i].getstringsize(ptr, &w, &h);
2043 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
2044 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
2045 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
2048 /* Channel mode */
2049 switch ( global_settings.rec_channels ) {
2050 case 0:
2051 ptr = str(LANG_SYSFONT_CHANNEL_STEREO);
2052 break;
2054 case 1:
2055 ptr = str(LANG_SYSFONT_CHANNEL_MONO);
2056 break;
2059 FOR_NB_SCREENS(i)
2061 screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h);
2062 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
2063 str(LANG_SYSFONT_CHANNELS));
2064 screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h);
2065 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h,
2066 str(LANG_SYSFONT_MODE));
2067 screens[i].getstringsize(ptr, &w, &h);
2068 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
2069 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
2070 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
2072 screens[i].update();
2075 button = button_get(true);
2076 switch (button) {
2077 case BUTTON_LEFT:
2078 case BUTTON_F2 | BUTTON_LEFT:
2079 global_settings.rec_quality++;
2080 if(global_settings.rec_quality > 7)
2081 global_settings.rec_quality = 0;
2082 used = true;
2083 break;
2085 case BUTTON_DOWN:
2086 case BUTTON_F2 | BUTTON_DOWN:
2087 global_settings.rec_frequency++;
2088 if(global_settings.rec_frequency > 5)
2089 global_settings.rec_frequency = 0;
2090 used = true;
2091 break;
2093 case BUTTON_RIGHT:
2094 case BUTTON_F2 | BUTTON_RIGHT:
2095 global_settings.rec_channels++;
2096 if(global_settings.rec_channels > 1)
2097 global_settings.rec_channels = 0;
2098 used = true;
2099 break;
2101 case BUTTON_F2 | BUTTON_REL:
2102 if ( used )
2103 exit = true;
2104 used = true;
2105 break;
2107 case BUTTON_F2 | BUTTON_REPEAT:
2108 used = true;
2109 break;
2111 default:
2112 if(default_event_handler(button) == SYS_USB_CONNECTED)
2113 return true;
2114 break;
2118 rec_init_recording_options(&rec_options);
2119 rec_set_recording_options(&rec_options);
2121 set_gain();
2123 settings_save();
2124 FOR_NB_SCREENS(i)
2125 screens[i].setfont(FONT_UI);
2127 return false;
2130 static bool f3_rec_screen(void)
2132 bool exit = false;
2133 bool used = false;
2134 int w, h, i;
2135 int button;
2136 char *src_str[] =
2138 str(LANG_SYSFONT_RECORDING_SRC_MIC),
2139 str(LANG_SYSFONT_LINE_IN),
2140 str(LANG_SYSFONT_RECORDING_SRC_DIGITAL)
2142 struct audio_recording_options rec_options;
2144 FOR_NB_SCREENS(i)
2146 screens[i].setfont(FONT_SYSFIXED);
2147 screens[i].getstringsize("A",&w,&h);
2150 while (!exit) {
2151 char* ptr=NULL;
2152 ptr = src_str[global_settings.rec_source];
2153 FOR_NB_SCREENS(i)
2155 screens[i].clear_display();
2157 /* Recording source */
2158 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
2159 str(LANG_SYSFONT_RECORDING_SOURCE));
2161 screens[i].getstringsize(ptr, &w, &h);
2162 screens[i].putsxy(0, LCD_HEIGHT/2-h, ptr);
2163 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
2164 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
2167 /* trigger setup */
2168 ptr = str(LANG_SYSFONT_RECORD_TRIGGER);
2169 FOR_NB_SCREENS(i)
2171 screens[i].getstringsize(ptr,&w,&h);
2172 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr);
2173 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
2174 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
2176 screens[i].update();
2179 button = button_get(true);
2180 switch (button) {
2181 case BUTTON_DOWN:
2182 case BUTTON_F3 | BUTTON_DOWN:
2183 #ifndef SIMULATOR
2184 rectrigger();
2185 settings_apply_trigger();
2186 #endif
2187 exit = true;
2188 break;
2190 case BUTTON_LEFT:
2191 case BUTTON_F3 | BUTTON_LEFT:
2192 global_settings.rec_source++;
2193 if(global_settings.rec_source > AUDIO_SRC_MAX)
2194 global_settings.rec_source = 0;
2195 used = true;
2196 break;
2198 case BUTTON_F3 | BUTTON_REL:
2199 if ( used )
2200 exit = true;
2201 used = true;
2202 break;
2204 case BUTTON_F3 | BUTTON_REPEAT:
2205 used = true;
2206 break;
2208 default:
2209 if(default_event_handler(button) == SYS_USB_CONNECTED)
2210 return true;
2211 break;
2215 rec_init_recording_options(&rec_options);
2216 rec_set_recording_options(&rec_options);
2218 set_gain();
2220 settings_save();
2221 FOR_NB_SCREENS(i)
2222 screens[i].setfont(FONT_UI);
2224 return false;
2226 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
2228 #if CONFIG_CODEC == SWCODEC
2229 void audio_beep(int duration)
2231 /* dummy */
2232 (void)duration;
2235 #ifdef SIMULATOR
2236 /* stubs for recording sim */
2237 void audio_init_recording(unsigned int buffer_offset)
2239 buffer_offset = buffer_offset;
2242 void audio_close_recording(void)
2246 unsigned long pcm_rec_get_warnings(void)
2248 return 0;
2251 unsigned long audio_recorded_time(void)
2253 return 123;
2256 unsigned long audio_num_recorded_bytes(void)
2258 return 5 * 1024 * 1024;
2261 void rec_set_source(int source, unsigned flags)
2263 source = source;
2264 flags = flags;
2267 void audio_set_recording_options(struct audio_recording_options *options)
2269 options = options;
2272 void audio_set_recording_gain(int left, int right, int type)
2274 left = left;
2275 right = right;
2276 type = type;
2279 void audio_record(const char *filename)
2281 filename = filename;
2284 void audio_new_file(const char *filename)
2286 filename = filename;
2289 void audio_stop_recording(void)
2293 void audio_pause_recording(void)
2297 void audio_resume_recording(void)
2301 #endif /* #ifdef SIMULATOR */
2302 #endif /* #ifdef CONFIG_CODEC == SWCODEC */
2304 #endif /* HAVE_RECORDING */