autodetection: convert path to native separators before displaying it.
[Rockbox.git] / apps / recorder / recording.c
blobc2b2360df1a35b28013631a579ba9507efa39fe1
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
22 #include <stdio.h>
23 #include <stdbool.h>
24 #include <stdlib.h>
26 #include "system.h"
27 #include "power.h"
28 #include "powermgmt.h"
29 #include "lcd.h"
30 #include "led.h"
31 #include "mpeg.h"
32 #include "audio.h"
33 #if CONFIG_CODEC == SWCODEC
34 #include "thread.h"
35 #include "playback.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 "recording.h"
42 #include "mp3_playback.h"
43 #include "mas.h"
44 #include "button.h"
45 #include "kernel.h"
46 #include "settings.h"
47 #include "lang.h"
48 #include "font.h"
49 #include "icons.h"
50 #include "icon.h"
51 #include "screens.h"
52 #include "peakmeter.h"
53 #include "statusbar.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 "ata.h"
66 #include "splash.h"
67 #include "screen_access.h"
68 #include "action.h"
69 #include "radio.h"
70 #include "sound_menu.h"
72 #ifdef HAVE_RECORDING
73 /* This array holds the record timer interval lengths, in seconds */
74 static const unsigned long rec_timer_seconds[] =
76 0, /* 0 means OFF */
77 5*60, /* 00:05 */
78 10*60, /* 00:10 */
79 15*60, /* 00:15 */
80 30*60, /* 00:30 */
81 60*60, /* 01:00 */
82 74*60, /* 74:00 */
83 80*60, /* 80:00 */
84 2*60*60, /* 02:00 */
85 4*60*60, /* 04:00 */
86 6*60*60, /* 06:00 */
87 8*60*60, /* 08:00 */
88 10L*60*60, /* 10:00 */
89 12L*60*60, /* 12:00 */
90 18L*60*60, /* 18:00 */
91 24L*60*60 /* 24:00 */
94 static unsigned int rec_timesplit_seconds(void)
96 return rec_timer_seconds[global_settings.rec_timesplit];
99 /* This array holds the record size interval lengths, in bytes */
100 static const unsigned long rec_size_bytes[] =
102 0, /* 0 means OFF */
103 5*1024*1024, /* 5MB */
104 10*1024*1024, /* 10MB */
105 15*1024*1024, /* 15MB */
106 32*1024*1024, /* 32MB */
107 64*1024*1024, /* 64MB */
108 75*1024*1024, /* 75MB */
109 100*1024*1024, /* 100MB */
110 128*1024*1024, /* 128MB */
111 256*1024*1024, /* 256MB */
112 512*1024*1024, /* 512MB */
113 650*1024*1024, /* 650MB */
114 700*1024*1024, /* 700MB */
115 1024*1024*1024, /* 1GB */
116 1536*1024*1024, /* 1.5GB */
117 1792*1024*1024, /* 1.75GB */
120 static unsigned long rec_sizesplit_bytes(void)
122 return rec_size_bytes[global_settings.rec_sizesplit];
125 * Time strings used for the trigger durations.
126 * Keep synchronous to trigger_times in settings_apply_trigger
128 const struct opt_items trig_durations[TRIG_DURATION_COUNT] =
130 #define TS(x) { (unsigned char *)(#x "s"), TALK_ID(x, UNIT_SEC) }
131 #define TM(x) { (unsigned char *)(#x "min"), TALK_ID(x, UNIT_MIN) }
132 TS(0), TS(1), TS(2), TS(5),
133 TS(10), TS(15), TS(20), TS(25), TS(30),
134 TM(1), TM(2), TM(5), TM(10)
135 #undef TS
136 #undef TM
139 void settings_apply_trigger(void)
141 /* Keep synchronous to trig_durations and trig_durations_conf*/
142 static const long trigger_times[TRIG_DURATION_COUNT] = {
143 0, HZ, 2*HZ, 5*HZ,
144 10*HZ, 15*HZ, 20*HZ, 25*HZ, 30*HZ,
145 60*HZ, 2*60*HZ, 5*60*HZ, 10*60*HZ
148 peak_meter_define_trigger(
149 global_settings.rec_start_thres,
150 trigger_times[global_settings.rec_start_duration],
151 MIN(trigger_times[global_settings.rec_start_duration] / 2, 2*HZ),
152 global_settings.rec_stop_thres,
153 trigger_times[global_settings.rec_stop_postrec],
154 trigger_times[global_settings.rec_stop_gap]
157 /* recording screen status flags */
158 enum rec_status_flags
160 RCSTAT_IN_RECSCREEN = 0x00000001,
161 RCSTAT_BEEN_IN_USB_MODE = 0x00000002,
162 RCSTAT_CREATED_DIRECTORY = 0x00000004,
163 RCSTAT_HAVE_RECORDED = 0x00000008,
166 static int rec_status = 0;
168 bool in_recording_screen(void)
170 return (rec_status & RCSTAT_IN_RECSCREEN) != 0;
173 #define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
175 #if CONFIG_KEYPAD == RECORDER_PAD
176 static bool f2_rec_screen(void);
177 static bool f3_rec_screen(void);
178 #endif
180 #define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */
182 #ifndef HAVE_REMOTE_LCD
183 static const int screen_update = NB_SCREENS;
184 #else
185 static int screen_update = NB_SCREENS;
186 static bool remote_display_on = true;
187 #endif
189 /** File name creation **/
190 #if CONFIG_RTC == 0
191 /* current file number to assist in creating unique numbered filenames
192 without actually having to create the file on disk */
193 static int file_number = -1;
194 #endif /* CONFIG_RTC */
196 #if CONFIG_CODEC == SWCODEC
198 #define REC_FILE_ENDING(rec_format) \
199 (audio_formats[rec_format_afmt[rec_format]].ext_list)
201 #else /* CONFIG_CODEC != SWCODEC */
203 /* default record file extension for HWCODEC */
204 #define REC_FILE_ENDING(rec_format) \
205 (audio_formats[AFMT_MPA_L3].ext_list)
207 #endif /* CONFIG_CODEC == SWCODEC */
209 /* path for current file */
210 static char path_buffer[MAX_PATH];
212 /** Automatic Gain Control (AGC) **/
213 #ifdef HAVE_AGC
214 /* Timing counters:
215 * peak_time is incremented every 0.2s, every 2nd run of record screen loop.
216 * hist_time is incremented every 0.5s, display update.
217 * peak_time is the counter of the peak hold read and agc process,
218 * overflow every 13 years 8-)
220 static long peak_time = 0;
221 static long hist_time = 0;
223 static short peak_valid_mem[4];
224 #define BAL_MEM_SIZE 24
225 static short balance_mem[BAL_MEM_SIZE];
227 /* Automatic Gain Control */
228 #define AGC_MODE_SIZE 5
229 #define AGC_SAFETY_MODE 0
231 static const char* agc_preset_str[] =
232 { "Off", "S", "L", "D", "M", "V" };
233 /* "Off",
234 "Safety (clip)",
235 "Live (slow)",
236 "DJ-Set (slow)",
237 "Medium",
238 "Voice (fast)" */
239 #define AGC_CLIP 32766
240 #define AGC_PEAK 29883 /* fast gain reduction threshold -0.8dB */
241 #define AGC_HIGH 27254 /* accelerated gain reduction threshold -1.6dB */
242 #define AGC_IMG 823 /* threshold for balance control -32dB */
243 /* autogain high level thresholds (-3dB, -7dB, -4dB, -5dB, -5dB) */
244 static const short agc_th_hi[AGC_MODE_SIZE] =
245 { 23197, 14637, 21156, 18428, 18426 };
246 /* autogain low level thresholds (-14dB, -11dB, -6dB, -7dB, -8dB) */
247 static const short agc_th_lo[AGC_MODE_SIZE] =
248 { 6538, 9235, 16422, 14636, 13045 };
249 /* autogain threshold times [1/5s] or [200ms] */
250 static const short agc_tdrop[AGC_MODE_SIZE] =
251 { 900, 225, 150, 60, 8 };
252 static const short agc_trise[AGC_MODE_SIZE] =
253 { 9000, 750, 400, 150, 20 };
254 static const short agc_tbal[AGC_MODE_SIZE] =
255 { 4500, 500, 300, 100, 15 };
256 /* AGC operation */
257 static bool agc_enable = true;
258 static short agc_preset;
259 /* AGC levels */
260 static int agc_left = 0;
261 static int agc_right = 0;
262 /* AGC time since high target volume was exceeded */
263 static short agc_droptime = 0;
264 /* AGC time since volume fallen below low target */
265 static short agc_risetime = 0;
266 /* AGC balance time exceeding +/- 0.7dB */
267 static short agc_baltime = 0;
268 /* AGC maximum gain */
269 static short agc_maxgain;
270 #endif /* HAVE_AGC */
272 static void set_gain(void)
274 if(global_settings.rec_source == AUDIO_SRC_MIC)
276 audio_set_recording_gain(global_settings.rec_mic_gain,
277 0, AUDIO_GAIN_MIC);
279 else
281 /* AUDIO_SRC_LINEIN, AUDIO_SRC_FMRADIO, AUDIO_SRC_SPDIF */
282 audio_set_recording_gain(global_settings.rec_left_gain,
283 global_settings.rec_right_gain,
284 AUDIO_GAIN_LINEIN);
286 /* reset the clipping indicators */
287 peak_meter_set_clip_hold(global_settings.peak_meter_clip_hold);
290 #ifdef HAVE_AGC
291 /* Read peak meter values & calculate balance.
292 * Returns validity of peak values.
293 * Used for automatic gain control and history diagram.
295 static bool read_peak_levels(int *peak_l, int *peak_r, int *balance)
297 peak_meter_get_peakhold(peak_l, peak_r);
298 peak_valid_mem[peak_time % 3] = *peak_l;
299 if (((peak_valid_mem[0] == peak_valid_mem[1]) &&
300 (peak_valid_mem[1] == peak_valid_mem[2])) &&
301 ((*peak_l < 32767)
302 #ifndef SIMULATOR
303 || ata_disk_is_active()
304 #endif
306 return false;
308 if (*peak_r > *peak_l)
309 balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_l ?
310 MIN((10000 * *peak_r) / *peak_l - 10000, 15118) : 15118);
311 else
312 balance_mem[peak_time % BAL_MEM_SIZE] = (*peak_r ?
313 MAX(10000 - (10000 * *peak_l) / *peak_r, -15118) : -15118);
314 *balance = 0;
315 int i;
316 for (i = 0; i < BAL_MEM_SIZE; i++)
317 *balance += balance_mem[i];
318 *balance = *balance / BAL_MEM_SIZE;
320 return true;
323 /* AGC helper function to check if maximum gain is reached */
324 static bool agc_gain_is_max(bool left, bool right)
326 /* range -128...+108 [0.5dB] */
327 short gain_current_l;
328 short gain_current_r;
330 if (agc_preset == 0)
331 return false;
333 switch (global_settings.rec_source)
335 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
336 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
337 gain_current_l = global_settings.rec_left_gain;
338 gain_current_r = global_settings.rec_right_gain;
339 break;
340 case AUDIO_SRC_MIC:
341 default:
342 gain_current_l = global_settings.rec_mic_gain;
343 gain_current_r = global_settings.rec_mic_gain;
346 return ((left && (gain_current_l >= agc_maxgain)) ||
347 (right && (gain_current_r >= agc_maxgain)));
350 static void change_recording_gain(bool increment, bool left, bool right)
352 int factor = (increment ? 1 : -1);
354 switch (global_settings.rec_source)
356 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
357 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
358 if (left) global_settings.rec_left_gain += factor;
359 if (right) global_settings.rec_right_gain += factor;
360 break;
361 case AUDIO_SRC_MIC:
362 global_settings.rec_mic_gain += factor;
367 * Handle automatic gain control (AGC).
368 * Change recording gain if peak_x levels are above or below
369 * target volume for specified timeouts.
371 static void auto_gain_control(int *peak_l, int *peak_r, int *balance)
373 int agc_mono;
374 short agc_mode;
375 bool increment;
377 if (*peak_l > agc_left)
378 agc_left = *peak_l;
379 else
380 agc_left -= (agc_left - *peak_l + 3) >> 2;
381 if (*peak_r > agc_right)
382 agc_right = *peak_r;
383 else
384 agc_right -= (agc_right - *peak_r + 3) >> 2;
385 agc_mono = (agc_left + agc_right) / 2;
387 agc_mode = abs(agc_preset) - 1;
388 if (agc_mode < 0) {
389 agc_enable = false;
390 return;
393 if (agc_mode != AGC_SAFETY_MODE) {
394 /* Automatic balance control - only if not in safety mode */
395 if ((agc_left > AGC_IMG) && (agc_right > AGC_IMG))
397 if (*balance < -556)
399 if (*balance > -900)
400 agc_baltime -= !(peak_time % 4); /* 0.47 - 0.75dB */
401 else if (*balance > -4125)
402 agc_baltime--; /* 0.75 - 3.00dB */
403 else if (*balance > -7579)
404 agc_baltime -= 2; /* 3.00 - 4.90dB */
405 else
406 agc_baltime -= !(peak_time % 8); /* 4.90 - inf dB */
407 if (agc_baltime > 0)
408 agc_baltime -= (peak_time % 2);
410 else if (*balance > 556)
412 if (*balance < 900)
413 agc_baltime += !(peak_time % 4);
414 else if (*balance < 4125)
415 agc_baltime++;
416 else if (*balance < 7579)
417 agc_baltime += 2;
418 else
419 agc_baltime += !(peak_time % 8);
420 if (agc_baltime < 0)
421 agc_baltime += (peak_time % 2);
424 if ((*balance * agc_baltime) < 0)
426 if (*balance < 0)
427 agc_baltime -= peak_time % 2;
428 else
429 agc_baltime += peak_time % 2;
432 increment = ((agc_risetime / 2) > agc_droptime);
434 if (agc_baltime < -agc_tbal[agc_mode])
436 if (!increment || !agc_gain_is_max(!increment, increment)) {
437 change_recording_gain(increment, !increment, increment);
438 set_gain();
440 agc_baltime = 0;
442 else if (agc_baltime > +agc_tbal[agc_mode])
444 if (!increment || !agc_gain_is_max(increment, !increment)) {
445 change_recording_gain(increment, increment, !increment);
446 set_gain();
448 agc_baltime = 0;
451 else if (!(hist_time % 4))
453 if (agc_baltime < 0)
454 agc_baltime++;
455 else
456 agc_baltime--;
460 /* Automatic gain control */
461 if ((agc_left > agc_th_hi[agc_mode]) || (agc_right > agc_th_hi[agc_mode]))
463 if ((agc_left > AGC_CLIP) || (agc_right > AGC_CLIP))
464 agc_droptime += agc_tdrop[agc_mode] /
465 (global_settings.rec_agc_cliptime + 1);
466 if (agc_left > AGC_HIGH) {
467 agc_droptime++;
468 agc_risetime=0;
469 if (agc_left > AGC_PEAK)
470 agc_droptime += 2;
472 if (agc_right > AGC_HIGH) {
473 agc_droptime++;
474 agc_risetime=0;
475 if (agc_right > AGC_PEAK)
476 agc_droptime += 2;
478 if (agc_mono > agc_th_hi[agc_mode])
479 agc_droptime++;
480 else
481 agc_droptime += !(peak_time % 2);
483 if (agc_droptime >= agc_tdrop[agc_mode])
485 change_recording_gain(false, true, true);
486 agc_droptime = 0;
487 agc_risetime = 0;
488 set_gain();
490 agc_risetime = MAX(agc_risetime - 1, 0);
492 else if (agc_mono < agc_th_lo[agc_mode])
494 if (agc_mono < (agc_th_lo[agc_mode] / 8))
495 agc_risetime += !(peak_time % 5);
496 else if (agc_mono < (agc_th_lo[agc_mode] / 2))
497 agc_risetime += 2;
498 else
499 agc_risetime++;
501 if (agc_risetime >= agc_trise[agc_mode]) {
502 if ((agc_mode != AGC_SAFETY_MODE) &&
503 (!agc_gain_is_max(true, true))) {
504 change_recording_gain(true, true, true);
505 set_gain();
507 agc_risetime = 0;
508 agc_droptime = 0;
510 agc_droptime = MAX(agc_droptime - 1, 0);
512 else if (!(peak_time % 6)) /* on target level every 1.2 sec */
514 agc_risetime = MAX(agc_risetime - 1, 0);
515 agc_droptime = MAX(agc_droptime - 1, 0);
518 #endif /* HAVE_AGC */
520 static const char* const fmtstr[] =
522 "%c%d %s", /* no decimals */
523 "%c%d.%d %s ", /* 1 decimal */
524 "%c%d.%02d %s " /* 2 decimals */
527 static char *fmt_gain(int snd, int val, char *str, int len)
529 int i, d, numdec;
530 const char *unit;
531 char sign = ' ';
533 val = sound_val2phys(snd, val);
534 if(val < 0)
536 sign = '-';
537 val = -val;
539 numdec = sound_numdecimals(snd);
540 unit = sound_unit(snd);
542 if(numdec)
544 i = val / (10*numdec);
545 d = val % (10*numdec);
546 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
548 else
549 snprintf(str, len, fmtstr[numdec], sign, val, unit);
551 return str;
554 static int cursor;
556 static void adjust_cursor(void)
558 int max_cursor;
560 if(cursor < 0)
561 cursor = 0;
563 #ifdef HAVE_AGC
564 switch(global_settings.rec_source)
566 case REC_SRC_MIC:
567 if(cursor == 2)
568 cursor = 4;
569 else if(cursor == 3)
570 cursor = 1;
571 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
572 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
573 max_cursor = 5;
574 break;
575 default:
576 max_cursor = 0;
577 break;
579 #else /* !HAVE_AGC */
580 switch(global_settings.rec_source)
582 case AUDIO_SRC_MIC:
583 max_cursor = 1;
584 break;
585 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
586 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
587 max_cursor = 3;
588 break;
589 default:
590 max_cursor = 0;
591 break;
593 #endif /* HAVE_AGC */
595 if(cursor > max_cursor)
596 cursor = max_cursor;
599 /* the list below must match enum audio_sources in audio.h */
600 static const char* const prestr[] =
602 HAVE_MIC_IN_([AUDIO_SRC_MIC] = "R_MIC_",)
603 HAVE_LINE_REC_([AUDIO_SRC_LINEIN] = "R_LINE_",)
604 HAVE_SPDIF_IN_([AUDIO_SRC_SPDIF] = "R_SPDIF_",)
605 HAVE_FMRADIO_REC_([AUDIO_SRC_FMRADIO] = "R_FM_",)
608 char *rec_create_filename(char *buffer)
610 char ext[16];
611 const char *pref = "R_";
613 /* Directory existence and writeablility should have already been
614 * verified - do not pass NULL pointers to pcmrec */
616 if((unsigned)global_settings.rec_source < AUDIO_NUM_SOURCES)
618 pref = prestr[global_settings.rec_source];
621 strcpy(buffer, global_settings.rec_directory);
623 snprintf(ext, sizeof(ext), ".%s",
624 REC_FILE_ENDING(global_settings.rec_format));
626 #if CONFIG_RTC == 0
627 return create_numbered_filename(buffer, buffer, pref, ext, 4,
628 &file_number);
629 #else
630 /* We'll wait at least up to the start of the next second so no duplicate
631 names are created */
632 return create_datetime_filename(buffer, buffer, pref, ext, true);
633 #endif
636 #if CONFIG_RTC == 0
637 /* Hit disk to get a starting filename for the type */
638 static void rec_init_filename(void)
640 file_number = -1;
641 rec_create_filename(path_buffer);
642 file_number--;
644 #endif
646 int rec_create_directory(void)
648 int rc = 0;
649 const char * const folder = global_settings.rec_directory;
651 if (strcmp(folder, "/") && !dir_exists(folder))
653 rc = mkdir(folder);
655 if(rc < 0)
657 while (action_userabort(HZ) == false)
659 gui_syncsplash(0, "%s %s",
660 str(LANG_REC_DIR_NOT_WRITABLE),
661 str(LANG_OFF_ABORT));
664 else
666 rec_status |= RCSTAT_CREATED_DIRECTORY;
667 rc = 1;
671 return rc;
674 void rec_init_recording_options(struct audio_recording_options *options)
676 options->rec_source = global_settings.rec_source;
677 options->rec_frequency = global_settings.rec_frequency;
678 options->rec_channels = global_settings.rec_channels;
679 options->rec_prerecord_time = global_settings.rec_prerecord_time;
680 #if CONFIG_CODEC == SWCODEC
681 options->rec_source_flags = 0;
682 options->enc_config.rec_format = global_settings.rec_format;
683 global_to_encoder_config(&options->enc_config);
684 #else
685 options->rec_quality = global_settings.rec_quality;
686 options->rec_editable = global_settings.rec_editable;
687 #endif
690 #if CONFIG_CODEC == SWCODEC && !defined (SIMULATOR)
691 void rec_set_source(int source, unsigned flags)
693 /* Set audio input source, power up/down devices */
694 audio_set_input_source(source, flags);
696 /* Set peakmeters for recording or reset to playback */
697 peak_meter_playback((flags & SRCF_RECORDING) == 0);
698 peak_meter_enabled = true;
700 #endif /* CONFIG_CODEC == SWCODEC && !defined (SIMULATOR) */
702 void rec_set_recording_options(struct audio_recording_options *options)
704 #if CONFIG_CODEC != SWCODEC
705 if (global_settings.rec_prerecord_time)
707 talk_buffer_steal(); /* will use the mp3 buffer */
709 #else /* == SWCODEC */
710 rec_set_source(options->rec_source,
711 options->rec_source_flags | SRCF_RECORDING);
712 #endif /* CONFIG_CODEC != SWCODEC */
714 audio_set_recording_options(options);
717 void rec_command(enum recording_command cmd)
719 switch(cmd)
721 case RECORDING_CMD_STOP_SHUTDOWN:
722 pm_activate_clipcount(false);
723 audio_stop_recording();
724 #if CONFIG_CODEC == SWCODEC
725 audio_close_recording();
726 #endif
727 sys_poweroff();
728 break;
729 case RECORDING_CMD_STOP:
730 pm_activate_clipcount(false);
731 audio_stop_recording();
732 break;
733 case RECORDING_CMD_START:
734 /* steal mp3 buffer, create unique filename and start recording */
735 pm_reset_clipcount();
736 pm_activate_clipcount(true);
737 #if CONFIG_CODEC != SWCODEC
738 talk_buffer_steal(); /* we use the mp3 buffer */
739 #endif
740 audio_record(rec_create_filename(path_buffer));
741 break;
742 case RECORDING_CMD_START_NEWFILE:
743 /* create unique filename and start recording*/
744 pm_reset_clipcount();
745 pm_activate_clipcount(true); /* just to be sure */
746 audio_new_file(rec_create_filename(path_buffer));
747 break;
748 case RECORDING_CMD_PAUSE:
749 pm_activate_clipcount(false);
750 audio_pause_recording();
751 break;
752 case RECORDING_CMD_RESUME:
753 pm_activate_clipcount(true);
754 audio_resume_recording();
755 break;
759 /* used in trigger_listerner and recording_screen */
760 static unsigned int last_seconds = 0;
763 * Callback function so that the peak meter code can send an event
764 * to this application. This function can be passed to
765 * peak_meter_set_trigger_listener in order to activate the trigger.
767 static void trigger_listener(int trigger_status)
769 switch (trigger_status)
771 case TRIG_GO:
772 if(!(audio_status() & AUDIO_STATUS_RECORD))
774 rec_status |= RCSTAT_HAVE_RECORDED;
775 rec_command(RECORDING_CMD_START);
776 #if CONFIG_CODEC != SWCODEC
777 /* give control to mpeg thread so that it can start
778 recording */
779 yield(); yield(); yield();
780 #endif
783 /* if we're already recording this is a retrigger */
784 else
786 if((audio_status() & AUDIO_STATUS_PAUSE) &&
787 (global_settings.rec_trigger_type == 1))
789 rec_command(RECORDING_CMD_RESUME);
791 /* New file on trig start*/
792 else if (global_settings.rec_trigger_type != 2)
794 rec_command(RECORDING_CMD_START_NEWFILE);
795 /* tell recording_screen to reset the time */
796 last_seconds = 0;
799 break;
801 /* A _change_ to TRIG_READY means the current recording has stopped */
802 case TRIG_READY:
803 if(audio_status() & AUDIO_STATUS_RECORD)
805 switch(global_settings.rec_trigger_type)
807 case 0: /* Stop */
808 rec_command(RECORDING_CMD_STOP);
809 break;
811 case 1: /* Pause */
812 rec_command(RECORDING_CMD_PAUSE);
813 break;
815 case 2: /* New file on trig stop*/
816 rec_command(RECORDING_CMD_START_NEWFILE);
817 /* tell recording_screen to reset the time */
818 last_seconds = 0;
819 break;
821 case 3: /* Stop and shutdown */
822 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
823 break;
826 if (global_settings.rec_trigger_mode != TRIG_MODE_REARM)
828 peak_meter_set_trigger_listener(NULL);
829 peak_meter_trigger(false);
832 break;
836 bool recording_start_automatic = false;
838 bool recording_screen(bool no_source)
840 long button;
841 bool done = false;
842 char buf[32];
843 char buf2[32];
844 int w, h;
845 int update_countdown = 1;
846 unsigned int seconds;
847 int hours, minutes;
848 char filename[13];
849 int last_audio_stat = -1;
850 int audio_stat;
851 #if CONFIG_CODEC == SWCODEC
852 int warning_counter = 0;
853 #define WARNING_PERIOD 7
854 #endif
855 #ifdef HAVE_FMRADIO_REC
856 /* Radio is left on if:
857 * 1) Is was on at the start and the initial source is FM Radio
858 * 2) 1) and the source was never changed to something else
860 int radio_status = (global_settings.rec_source != AUDIO_SRC_FMRADIO) ?
861 FMRADIO_OFF : get_radio_status();
862 #endif
863 #if (CONFIG_LED == LED_REAL)
864 bool led_state = false;
865 int led_countdown = 2;
866 #endif
867 #ifdef HAVE_AGC
868 bool peak_read = false;
869 bool peak_valid = false;
870 int peak_l, peak_r;
871 int balance = 0;
872 bool display_agc[NB_SCREENS];
873 #endif
874 int line[NB_SCREENS];
875 int i;
876 int filename_offset[NB_SCREENS];
877 int pm_y[NB_SCREENS];
878 int trig_xpos[NB_SCREENS];
879 int trig_ypos[NB_SCREENS];
880 int trig_width[NB_SCREENS];
881 /* pm_x = offset pm to put clipcount in front.
882 Use lcd_getstringsize() when not using SYSFONT */
883 int pm_x = global_settings.peak_meter_clipcounter ? 30 : 0;
885 static const unsigned char *byte_units[] = {
886 ID2P(LANG_BYTE),
887 ID2P(LANG_KILOBYTE),
888 ID2P(LANG_MEGABYTE),
889 ID2P(LANG_GIGABYTE)
892 int base_style = STYLE_INVERT;
893 int style;
894 #ifdef HAVE_LCD_COLOR
895 if (global_settings.cursor_style == 2) {
896 base_style |= STYLE_COLORBAR;
898 else if (global_settings.cursor_style == 3) {
899 base_style |= STYLE_GRADIENT;
901 #endif
903 struct audio_recording_options rec_options;
904 rec_status = RCSTAT_IN_RECSCREEN;
906 if (rec_create_directory() < 0)
908 rec_status = 0;
909 return false;
912 cursor = 0;
913 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
914 ata_set_led_enabled(false);
915 #endif
917 #if CONFIG_CODEC == SWCODEC
918 /* recording_menu gets messed up: so prevent manus talking */
919 talk_disable(true);
920 /* audio_init_recording stops anything playing when it takes the audio
921 buffer */
922 #else
923 /* Yes, we use the D/A for monitoring */
924 peak_meter_enabled = true;
925 peak_meter_playback(true);
926 #endif
928 audio_init_recording(0);
929 sound_set_volume(global_settings.volume);
931 #ifdef HAVE_AGC
932 peak_meter_get_peakhold(&peak_l, &peak_r);
933 #endif
935 rec_init_recording_options(&rec_options);
936 rec_set_recording_options(&rec_options);
938 set_gain();
940 #if CONFIG_RTC == 0
941 /* Create new filename for recording start */
942 rec_init_filename();
943 #endif
945 pm_reset_clipcount();
946 pm_activate_clipcount(false);
947 settings_apply_trigger();
949 #ifdef HAVE_AGC
950 agc_preset_str[0] = str(LANG_SYSFONT_OFF);
951 agc_preset_str[1] = str(LANG_SYSFONT_AGC_SAFETY);
952 agc_preset_str[2] = str(LANG_SYSFONT_AGC_LIVE);
953 agc_preset_str[3] = str(LANG_SYSFONT_AGC_DJSET);
954 agc_preset_str[4] = str(LANG_SYSFONT_AGC_MEDIUM);
955 agc_preset_str[5] = str(LANG_SYSFONT_AGC_VOICE);
956 if (global_settings.rec_source == AUDIO_SRC_MIC) {
957 agc_preset = global_settings.rec_agc_preset_mic;
958 agc_maxgain = global_settings.rec_agc_maxgain_mic;
960 else {
961 agc_preset = global_settings.rec_agc_preset_line;
962 agc_maxgain = global_settings.rec_agc_maxgain_line;
964 #endif /* HAVE_AGC */
966 FOR_NB_SCREENS(i)
968 screens[i].setfont(FONT_SYSFIXED);
969 screens[i].getstringsize("M", &w, &h);
970 screens[i].setmargins(global_settings.cursor_style ? 0 : w, 8);
971 filename_offset[i] = ((screens[i].height >= 80) ? 1 : 0);
972 pm_y[i] = 8 + h * (2 + filename_offset[i]);
975 #ifdef HAVE_REMOTE_LCD
976 if (!remote_display_on)
978 screens[1].clear_display();
979 snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON));
980 screens[1].puts((screens[1].width/w - strlen(buf))/2 + 1,
981 screens[1].height/(h*2) + 1, buf);
982 screens[1].update();
983 gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF));
985 #endif
987 while(!done)
989 audio_stat = audio_status();
991 #if (CONFIG_LED == LED_REAL)
994 * Flash the LED while waiting to record. Turn it on while
995 * recording.
997 if(audio_stat & AUDIO_STATUS_RECORD)
999 if (audio_stat & AUDIO_STATUS_PAUSE)
1001 if (--led_countdown <= 0)
1003 led_state = !led_state;
1004 led(led_state);
1005 led_countdown = 2;
1008 else
1010 /* trigger is on in status TRIG_READY (no check needed) */
1011 led(true);
1014 else
1016 int trigStat = peak_meter_trigger_status();
1018 * other trigger stati than trig_off and trig_steady
1019 * already imply that we are recording.
1021 if (trigStat == TRIG_STEADY)
1023 if (--led_countdown <= 0)
1025 led_state = !led_state;
1026 led(led_state);
1027 led_countdown = 2;
1030 else
1032 /* trigger is on in status TRIG_READY (no check needed) */
1033 led(false);
1036 #endif /* CONFIG_LED */
1038 /* Wait for a button a while (HZ/10) drawing the peak meter */
1039 button = peak_meter_draw_get_btn(pm_x, pm_y, h * PM_HEIGHT,
1040 screen_update);
1042 if (last_audio_stat != audio_stat)
1044 if (audio_stat & AUDIO_STATUS_RECORD)
1046 rec_status |= RCSTAT_HAVE_RECORDED;
1048 last_audio_stat = audio_stat;
1052 if (recording_start_automatic)
1054 /* simulate a button press */
1055 button = ACTION_REC_PAUSE;
1056 recording_start_automatic = false;
1059 switch(button)
1061 #ifdef HAVE_REMOTE_LCD
1062 case ACTION_REC_LCD:
1063 if (remote_display_on)
1065 remote_display_on = false;
1066 screen_update = 1;
1067 screens[1].clear_display();
1068 snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON));
1069 screens[1].puts((screens[1].width/w - strlen(buf))/2 + 1,
1070 screens[1].height/(h*2) + 1, buf);
1071 screens[1].update();
1072 gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF));
1074 else
1076 remote_display_on = true;
1077 screen_update = NB_SCREENS;
1079 break;
1080 #endif
1081 case ACTION_STD_CANCEL:
1082 /* turn off the trigger */
1083 peak_meter_trigger(false);
1084 peak_meter_set_trigger_listener(NULL);
1086 if(audio_stat & AUDIO_STATUS_RECORD)
1088 rec_command(RECORDING_CMD_STOP);
1090 else
1092 #if CONFIG_CODEC != SWCODEC
1093 peak_meter_playback(true);
1094 peak_meter_enabled = false;
1095 #endif
1096 done = true;
1098 update_countdown = 1; /* Update immediately */
1099 break;
1101 case ACTION_REC_PAUSE:
1102 case ACTION_REC_NEWFILE:
1103 /* Only act if the mpeg is stopped */
1104 if(!(audio_stat & AUDIO_STATUS_RECORD))
1106 /* is this manual or triggered recording? */
1107 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1108 (peak_meter_trigger_status() != TRIG_OFF))
1110 /* manual recording */
1111 rec_status |= RCSTAT_HAVE_RECORDED;
1112 rec_command(RECORDING_CMD_START);
1113 last_seconds = 0;
1114 if (global_settings.talk_menu)
1116 /* no voice possible here, but a beep */
1117 audio_beep(HZ/2); /* longer beep on start */
1120 /* this is triggered recording */
1121 else
1123 /* we don't start recording now, but enable the
1124 trigger and let the callback function
1125 trigger_listener control when the recording starts */
1126 peak_meter_trigger(true);
1127 peak_meter_set_trigger_listener(&trigger_listener);
1130 else
1132 /*if new file button pressed, start new file */
1133 if (button == ACTION_REC_NEWFILE)
1135 rec_command(RECORDING_CMD_START_NEWFILE);
1136 last_seconds = 0;
1138 else
1139 /* if pause button pressed, pause or resume */
1141 if(audio_stat & AUDIO_STATUS_PAUSE)
1143 rec_command(RECORDING_CMD_RESUME);
1144 if (global_settings.talk_menu)
1146 /* no voice possible here, but a beep */
1147 audio_beep(HZ/4); /* short beep on resume */
1150 else
1152 rec_command(RECORDING_CMD_PAUSE);
1156 update_countdown = 1; /* Update immediately */
1157 break;
1159 case ACTION_STD_PREV:
1160 cursor--;
1161 adjust_cursor();
1162 update_countdown = 1; /* Update immediately */
1163 break;
1165 case ACTION_STD_NEXT:
1166 cursor++;
1167 adjust_cursor();
1168 update_countdown = 1; /* Update immediately */
1169 break;
1171 case ACTION_SETTINGS_INC:
1172 case ACTION_SETTINGS_INCREPEAT:
1173 switch(cursor)
1175 case 0:
1176 global_settings.volume++;
1177 setvol();
1178 break;
1179 case 1:
1180 if(global_settings.rec_source == AUDIO_SRC_MIC)
1182 if(global_settings.rec_mic_gain <
1183 sound_max(SOUND_MIC_GAIN))
1184 global_settings.rec_mic_gain++;
1186 else
1188 if(global_settings.rec_left_gain <
1189 sound_max(SOUND_LEFT_GAIN))
1190 global_settings.rec_left_gain++;
1191 if(global_settings.rec_right_gain <
1192 sound_max(SOUND_RIGHT_GAIN))
1193 global_settings.rec_right_gain++;
1195 break;
1196 case 2:
1197 if(global_settings.rec_left_gain <
1198 sound_max(SOUND_LEFT_GAIN))
1199 global_settings.rec_left_gain++;
1200 break;
1201 case 3:
1202 if(global_settings.rec_right_gain <
1203 sound_max(SOUND_RIGHT_GAIN))
1204 global_settings.rec_right_gain++;
1205 break;
1206 #ifdef HAVE_AGC
1207 case 4:
1208 agc_preset = MIN(agc_preset + 1, AGC_MODE_SIZE);
1209 agc_enable = (agc_preset != 0);
1210 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1211 global_settings.rec_agc_preset_mic = agc_preset;
1212 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1213 } else {
1214 global_settings.rec_agc_preset_line = agc_preset;
1215 agc_maxgain = global_settings.rec_agc_maxgain_line;
1217 break;
1218 case 5:
1219 if (global_settings.rec_source == AUDIO_SRC_MIC)
1221 agc_maxgain = MIN(agc_maxgain + 1,
1222 sound_max(SOUND_MIC_GAIN));
1223 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1225 else
1227 agc_maxgain = MIN(agc_maxgain + 1,
1228 sound_max(SOUND_LEFT_GAIN));
1229 global_settings.rec_agc_maxgain_line = agc_maxgain;
1231 break;
1232 #endif /* HAVE_AGC */
1234 set_gain();
1235 update_countdown = 1; /* Update immediately */
1236 break;
1238 case ACTION_SETTINGS_DEC:
1239 case ACTION_SETTINGS_DECREPEAT:
1240 switch(cursor)
1242 case 0:
1243 global_settings.volume--;
1244 setvol();
1245 break;
1246 case 1:
1247 if(global_settings.rec_source == AUDIO_SRC_MIC)
1249 if(global_settings.rec_mic_gain >
1250 sound_min(SOUND_MIC_GAIN))
1251 global_settings.rec_mic_gain--;
1253 else
1255 if(global_settings.rec_left_gain >
1256 sound_min(SOUND_LEFT_GAIN))
1257 global_settings.rec_left_gain--;
1258 if(global_settings.rec_right_gain >
1259 sound_min(SOUND_RIGHT_GAIN))
1260 global_settings.rec_right_gain--;
1262 break;
1263 case 2:
1264 if(global_settings.rec_left_gain >
1265 sound_min(SOUND_LEFT_GAIN))
1266 global_settings.rec_left_gain--;
1267 break;
1268 case 3:
1269 if(global_settings.rec_right_gain >
1270 sound_min(SOUND_RIGHT_GAIN))
1271 global_settings.rec_right_gain--;
1272 break;
1273 #ifdef HAVE_AGC
1274 case 4:
1275 agc_preset = MAX(agc_preset - 1, 0);
1276 agc_enable = (agc_preset != 0);
1277 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1278 global_settings.rec_agc_preset_mic = agc_preset;
1279 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1280 } else {
1281 global_settings.rec_agc_preset_line = agc_preset;
1282 agc_maxgain = global_settings.rec_agc_maxgain_line;
1284 break;
1285 case 5:
1286 if (global_settings.rec_source == AUDIO_SRC_MIC)
1288 agc_maxgain = MAX(agc_maxgain - 1,
1289 sound_min(SOUND_MIC_GAIN));
1290 global_settings.rec_agc_maxgain_mic = agc_maxgain;
1292 else
1294 agc_maxgain = MAX(agc_maxgain - 1,
1295 sound_min(SOUND_LEFT_GAIN));
1296 global_settings.rec_agc_maxgain_line = agc_maxgain;
1298 break;
1299 #endif /* HAVE_AGC */
1301 set_gain();
1302 update_countdown = 1; /* Update immediately */
1303 break;
1305 case ACTION_STD_MENU:
1306 #if CONFIG_CODEC == SWCODEC
1307 if(!(audio_stat & AUDIO_STATUS_RECORD))
1308 #else
1309 if(audio_stat != AUDIO_STATUS_RECORD)
1310 #endif
1312 #ifdef HAVE_FMRADIO_REC
1313 const int prev_rec_source = global_settings.rec_source;
1314 #endif
1316 #if (CONFIG_LED == LED_REAL)
1317 /* led is restored at begin of loop / end of function */
1318 led(false);
1319 #endif
1320 if (recording_menu(no_source))
1322 done = true;
1323 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1324 #ifdef HAVE_FMRADIO_REC
1325 radio_status = FMRADIO_OFF;
1326 #endif
1328 else
1330 #ifdef HAVE_FMRADIO_REC
1331 /* If input changes away from FM Radio, radio will
1332 remain off when recording screen closes. */
1333 if (global_settings.rec_source != prev_rec_source
1334 && prev_rec_source == AUDIO_SRC_FMRADIO)
1335 radio_status = FMRADIO_OFF;
1336 #endif
1338 #if CONFIG_CODEC == SWCODEC
1339 /* reinit after submenu exit */
1340 audio_close_recording();
1341 audio_init_recording(0);
1342 #endif
1344 rec_init_recording_options(&rec_options);
1345 rec_set_recording_options(&rec_options);
1347 if(rec_create_directory() < 0)
1349 goto rec_abort;
1352 #if CONFIG_CODEC == SWCODEC && CONFIG_RTC == 0
1353 /* If format changed, a new number is required */
1354 rec_init_filename();
1355 #endif
1357 #ifdef HAVE_AGC
1358 if (global_settings.rec_source == AUDIO_SRC_MIC) {
1359 agc_preset = global_settings.rec_agc_preset_mic;
1360 agc_maxgain = global_settings.rec_agc_maxgain_mic;
1362 else {
1363 agc_preset = global_settings.rec_agc_preset_line;
1364 agc_maxgain = global_settings.rec_agc_maxgain_line;
1366 #endif
1368 adjust_cursor();
1369 set_gain();
1370 update_countdown = 1; /* Update immediately */
1372 FOR_NB_SCREENS(i)
1374 screens[i].setfont(FONT_SYSFIXED);
1375 screens[i].setmargins(
1376 global_settings.cursor_style ? 0 : w, 8);
1380 break;
1382 #if CONFIG_KEYPAD == RECORDER_PAD
1383 case ACTION_REC_F2:
1384 if(audio_stat != AUDIO_STATUS_RECORD)
1386 #if (CONFIG_LED == LED_REAL)
1387 /* led is restored at begin of loop / end of function */
1388 led(false);
1389 #endif
1390 if (f2_rec_screen())
1392 rec_status |= RCSTAT_HAVE_RECORDED;
1393 done = true;
1395 else
1396 update_countdown = 1; /* Update immediately */
1398 break;
1400 case ACTION_REC_F3:
1401 if(audio_stat & AUDIO_STATUS_RECORD)
1403 rec_command(RECORDING_CMD_START_NEWFILE);
1404 last_seconds = 0;
1406 else
1408 #if (CONFIG_LED == LED_REAL)
1409 /* led is restored at begin of loop / end of function */
1410 led(false);
1411 #endif
1412 if (f3_rec_screen())
1414 rec_status |= RCSTAT_HAVE_RECORDED;
1415 done = true;
1417 else
1418 update_countdown = 1; /* Update immediately */
1420 break;
1421 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
1423 case SYS_USB_CONNECTED:
1424 /* Only accept USB connection when not recording */
1425 if(!(audio_stat & AUDIO_STATUS_RECORD))
1427 default_event_handler(SYS_USB_CONNECTED);
1428 done = true;
1429 rec_status |= RCSTAT_BEEN_IN_USB_MODE;
1430 #ifdef HAVE_FMRADIO_REC
1431 radio_status = FMRADIO_OFF;
1432 #endif
1434 break;
1436 default:
1437 default_event_handler(button);
1438 break;
1439 } /* end switch */
1441 #ifdef HAVE_AGC
1442 peak_read = !peak_read;
1443 if (peak_read) { /* every 2nd run of loop */
1444 peak_time++;
1445 peak_valid = read_peak_levels(&peak_l, &peak_r, &balance);
1448 /* Handle AGC every 200ms when enabled and peak data is valid */
1449 if (peak_read && agc_enable && peak_valid)
1450 auto_gain_control(&peak_l, &peak_r, &balance);
1451 #endif
1453 FOR_NB_SCREENS(i)
1454 screens[i].setfont(FONT_SYSFIXED);
1456 seconds = audio_recorded_time() / HZ;
1458 update_countdown--;
1459 if(update_countdown == 0 || seconds > last_seconds)
1461 unsigned int dseconds, dhours, dminutes;
1462 unsigned long num_recorded_bytes, dsize, dmb;
1463 int pos = 0;
1465 update_countdown = 5;
1466 last_seconds = seconds;
1468 dseconds = rec_timesplit_seconds();
1469 dsize = rec_sizesplit_bytes();
1470 num_recorded_bytes = audio_num_recorded_bytes();
1472 for(i = 0; i < screen_update; i++)
1473 screens[i].clear_display();
1475 style = base_style;
1477 #ifdef HAVE_LCD_COLOR
1478 /* special action for gradient - set default for 1 line gradient */
1479 if(global_settings.cursor_style == 3)
1480 style = base_style | CURLN_PACK(0) | NUMLN_PACK(1);
1481 #endif /* HAVE_LCD_COLOR */
1483 #if CONFIG_CODEC == SWCODEC
1484 if ((audio_stat & AUDIO_STATUS_WARNING)
1485 && (warning_counter++ % WARNING_PERIOD) < WARNING_PERIOD/2)
1487 /* Switch back and forth displaying warning on first available
1488 line to ensure visibility - the motion should also help
1489 draw attention */
1490 /* Don't use language string unless agreed upon to make this
1491 method permanent - could do something in the statusbar */
1492 snprintf(buf, sizeof(buf), "Warning: %08X",
1493 pcm_rec_get_warnings());
1495 else
1496 #endif /* CONFIG_CODEC == SWCODEC */
1497 if ((global_settings.rec_sizesplit) &&
1498 (global_settings.rec_split_method))
1500 dmb = dsize/1024/1024;
1501 snprintf(buf, sizeof(buf), "%s %dMB",
1502 str(LANG_SYSFONT_SPLIT_SIZE), dmb);
1504 else
1506 hours = seconds / 3600;
1507 minutes = (seconds - (hours * 3600)) / 60;
1508 snprintf(buf, sizeof(buf), "%s %02d:%02d:%02d",
1509 str(LANG_SYSFONT_RECORDING_TIME),
1510 hours, minutes, seconds%60);
1513 for(i = 0; i < screen_update; i++)
1514 screens[i].puts(0, 0, buf);
1516 if(audio_stat & AUDIO_STATUS_PRERECORD)
1518 snprintf(buf, sizeof(buf), "%s...",
1519 str(LANG_SYSFONT_RECORD_PRERECORD));
1521 else
1523 /* Display the split interval if the record timesplit
1524 is active */
1525 if ((global_settings.rec_timesplit) &&
1526 !(global_settings.rec_split_method))
1528 /* Display the record timesplit interval rather
1529 than the file size if the record timer is
1530 active */
1531 dhours = dseconds / 3600;
1532 dminutes = (dseconds - (dhours * 3600)) / 60;
1533 snprintf(buf, sizeof(buf), "%s %02d:%02d",
1534 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC),
1535 dhours, dminutes);
1537 else
1539 output_dyn_value(buf2, sizeof buf2,
1540 num_recorded_bytes,
1541 byte_units, true);
1542 snprintf(buf, sizeof(buf), "%s %s",
1543 str(LANG_SYSFONT_RECORDING_SIZE), buf2);
1546 for(i = 0; i < screen_update; i++)
1547 screens[i].puts(0, 1, buf);
1549 for(i = 0; i < screen_update; i++)
1551 if (filename_offset[i] > 0)
1553 *filename = '\0';
1554 if (audio_stat & AUDIO_STATUS_RECORD)
1556 strncpy(filename, path_buffer +
1557 strlen(path_buffer) - 12, 13);
1558 filename[12]='\0';
1561 snprintf(buf, sizeof(buf), "%s %s",
1562 str(LANG_SYSFONT_RECORDING_FILENAME), filename);
1563 screens[i].puts(0, 2, buf);
1567 /* We will do file splitting regardless, either at the end of
1568 a split interval, or when the filesize approaches the 2GB
1569 FAT file size (compatibility) limit. */
1570 if ((audio_stat && !(global_settings.rec_split_method)
1571 && global_settings.rec_timesplit && (seconds >= dseconds))
1572 || (audio_stat && global_settings.rec_split_method
1573 && global_settings.rec_sizesplit
1574 && (num_recorded_bytes >= dsize))
1575 || (num_recorded_bytes >= MAX_FILE_SIZE))
1577 if (!(global_settings.rec_split_type)
1578 || (num_recorded_bytes >= MAX_FILE_SIZE))
1580 rec_command(RECORDING_CMD_START_NEWFILE);
1581 last_seconds = 0;
1583 else
1585 peak_meter_trigger(false);
1586 peak_meter_set_trigger_listener(NULL);
1587 if( global_settings.rec_split_type == 1)
1588 rec_command(RECORDING_CMD_STOP);
1589 else
1590 rec_command(RECORDING_CMD_STOP_SHUTDOWN);
1592 update_countdown = 1;
1595 /* draw the clipcounter just in front of the peakmeter */
1596 if(global_settings.peak_meter_clipcounter)
1598 char clpstr[32];
1599 snprintf(clpstr, 32, "%4d", pm_get_clipcount());
1600 for(i = 0; i < screen_update; i++)
1602 if(PM_HEIGHT > 1)
1603 screens[i].puts(0, 2 + filename_offset[i],
1604 str(LANG_SYSFONT_PM_CLIPCOUNT));
1605 screens[i].puts(0, 1 + PM_HEIGHT + filename_offset[i],
1606 clpstr);
1610 snprintf(buf, sizeof(buf), "%s: %s", str(LANG_SYSFONT_VOLUME),
1611 fmt_gain(SOUND_VOLUME,
1612 global_settings.volume,
1613 buf2, sizeof(buf2)));
1615 if (global_settings.cursor_style && (pos++ == cursor))
1617 for(i = 0; i < screen_update; i++)
1618 screens[i].puts_style_offset(0, filename_offset[i] +
1619 PM_HEIGHT + 2, buf, style,0);
1621 else
1623 for(i = 0; i < screen_update; i++)
1624 screens[i].puts(0, filename_offset[i] + 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].puts(0, filename_offset[i] +
1644 PM_HEIGHT + 3, buf);
1647 else if(0
1648 HAVE_LINE_REC_( || global_settings.rec_source ==
1649 AUDIO_SRC_LINEIN)
1650 HAVE_FMRADIO_REC_( || global_settings.rec_source ==
1651 AUDIO_SRC_FMRADIO)
1654 /* Draw LINE or FMRADIO recording gain */
1655 snprintf(buf, sizeof(buf), "%s:%s",
1656 str(LANG_SYSFONT_RECORDING_LEFT),
1657 fmt_gain(SOUND_LEFT_GAIN,
1658 global_settings.rec_left_gain,
1659 buf2, sizeof(buf2)));
1660 #ifdef HAVE_LCD_COLOR
1661 /* special action for gradient - double line gradient - line1 */
1662 if((global_settings.cursor_style == 3) &&
1663 (1==cursor))
1664 style = base_style | CURLN_PACK(0) | NUMLN_PACK(2);
1665 #endif /* HAVE_LCD_COLOR */
1666 if(global_settings.cursor_style && ((1==cursor)||(2==cursor)))
1668 for(i = 0; i < screen_update; i++)
1669 screens[i].puts_style_offset(0, filename_offset[i] +
1670 PM_HEIGHT + 3, buf, style,0);
1672 else
1674 for(i = 0; i < screen_update; i++)
1675 screens[i].puts(0, filename_offset[i] +
1676 PM_HEIGHT + 3, buf);
1679 snprintf(buf, sizeof(buf), "%s:%s",
1680 str(LANG_SYSFONT_RECORDING_RIGHT),
1681 fmt_gain(SOUND_RIGHT_GAIN,
1682 global_settings.rec_right_gain,
1683 buf2, sizeof(buf2)));
1684 #ifdef HAVE_LCD_COLOR
1685 /* special action for gradient - double line gradient - line2 */
1686 if((global_settings.cursor_style == 3) &&
1687 (1==cursor))
1688 style = base_style | CURLN_PACK(1) | NUMLN_PACK(2);
1689 #endif /* HAVE_LCD_COLOR */
1690 if(global_settings.cursor_style && ((1==cursor)||(3==cursor)))
1692 for(i = 0; i < screen_update; i++)
1693 screens[i].puts_style_offset(0, filename_offset[i] +
1694 PM_HEIGHT + 4, buf, style,0);
1696 else
1698 for(i = 0; i < screen_update; i++)
1699 screens[i].puts(0, filename_offset[i] +
1700 PM_HEIGHT + 4, buf);
1703 #ifdef HAVE_LCD_COLOR
1704 /* special action for gradient - back to single line gradient */
1705 if(global_settings.cursor_style == 3)
1706 style = base_style | CURLN_PACK(0) | NUMLN_PACK(1);
1707 #endif /* HAVE_LCD_COLOR */
1709 FOR_NB_SCREENS(i)
1711 switch (global_settings.rec_source)
1713 HAVE_LINE_REC_(case AUDIO_SRC_LINEIN:)
1714 HAVE_FMRADIO_REC_(case AUDIO_SRC_FMRADIO:)
1715 line[i] = 5;
1716 break;
1718 case AUDIO_SRC_MIC:
1719 line[i] = 4;
1720 break;
1721 #ifdef HAVE_SPDIF_REC
1722 case AUDIO_SRC_SPDIF:
1723 line[i] = 3;
1724 break;
1725 #endif
1726 default:
1727 line[i] = 5; /* to prevent uninitialisation
1728 warnings for line[0] */
1729 break;
1730 } /* end switch */
1731 #ifdef HAVE_AGC
1732 if (screens[i].height < h * (2 + filename_offset[i] +
1733 PM_HEIGHT + line[i]))
1735 line[i] -= 1;
1736 display_agc[i] = false;
1738 else
1739 display_agc[i] = true;
1741 if ((cursor==4) || (cursor==5))
1742 display_agc[i] = true;
1745 /************** AGC test info ******************
1746 snprintf(buf, sizeof(buf), "D:%d U:%d",
1747 (agc_droptime+2)/5, (agc_risetime+2)/5);
1748 lcd_putsxy(1, LCD_HEIGHT - 8, buf);
1749 snprintf(buf, sizeof(buf), "B:%d",
1750 (agc_baltime+2)/5);
1751 lcd_putsxy(LCD_WIDTH/2 + 3, LCD_HEIGHT - 8, buf);
1752 ***********************************************/
1754 if (cursor == 5)
1755 snprintf(buf, sizeof(buf), "%s: %s",
1756 str(LANG_SYSFONT_RECORDING_AGC_MAXGAIN),
1757 fmt_gain(SOUND_LEFT_GAIN,
1758 agc_maxgain, buf2, sizeof(buf2)));
1759 else if (agc_preset == 0)
1760 snprintf(buf, sizeof(buf), "%s: %s",
1761 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1762 agc_preset_str[agc_preset]);
1763 else if (global_settings.rec_source == AUDIO_SRC_MIC)
1764 snprintf(buf, sizeof(buf), "%s: %s%s",
1765 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1766 agc_preset_str[agc_preset],
1767 fmt_gain(SOUND_LEFT_GAIN,
1768 agc_maxgain -
1769 global_settings.rec_mic_gain,
1770 buf2, sizeof(buf2)));
1771 else
1772 snprintf(buf, sizeof(buf), "%s: %s%s",
1773 str(LANG_SYSFONT_RECORDING_AGC_PRESET),
1774 agc_preset_str[agc_preset],
1775 fmt_gain(SOUND_LEFT_GAIN,
1776 agc_maxgain -
1777 (global_settings.rec_left_gain +
1778 global_settings.rec_right_gain)/2,
1779 buf2, sizeof(buf2)));
1781 if(global_settings.cursor_style && ((cursor==4) || (cursor==5)))
1783 for(i = 0; i < screen_update; i++)
1784 screens[i].puts_style_offset(0, filename_offset[i] +
1785 PM_HEIGHT + line[i], buf, style,0);
1787 else if (global_settings.rec_source == AUDIO_SRC_MIC
1788 HAVE_LINE_REC_(|| global_settings.rec_source ==
1789 AUDIO_SRC_LINEIN)
1790 HAVE_FMRADIO_REC_(|| global_settings.rec_source ==
1791 AUDIO_SRC_FMRADIO)
1794 for(i = 0; i < screen_update; i++) {
1795 if (display_agc[i]) {
1796 screens[i].puts(0, filename_offset[i] +
1797 PM_HEIGHT + line[i], buf);
1802 if (global_settings.rec_source == AUDIO_SRC_MIC)
1804 if(agc_maxgain < (global_settings.rec_mic_gain))
1805 change_recording_gain(false, true, true);
1807 else
1809 if(agc_maxgain < (global_settings.rec_left_gain))
1810 change_recording_gain(false, true, false);
1811 if(agc_maxgain < (global_settings.rec_right_gain))
1812 change_recording_gain(false, false, true);
1814 #else /* !HAVE_AGC */
1816 #endif /* HAVE_AGC */
1818 if(!global_settings.cursor_style) {
1819 switch(cursor)
1821 case 1:
1822 for(i = 0; i < screen_update; i++)
1823 screen_put_cursorxy(&screens[i], 0,
1824 filename_offset[i] +
1825 PM_HEIGHT + 3, true);
1827 if(global_settings.rec_source != AUDIO_SRC_MIC)
1829 for(i = 0; i < screen_update; i++)
1830 screen_put_cursorxy(&screens[i], 0,
1831 filename_offset[i] +
1832 PM_HEIGHT + 4, true);
1834 break;
1835 case 2:
1836 for(i = 0; i < screen_update; i++)
1837 screen_put_cursorxy(&screens[i], 0,
1838 filename_offset[i] +
1839 PM_HEIGHT + 3, true);
1840 break;
1841 case 3:
1842 for(i = 0; i < screen_update; i++)
1843 screen_put_cursorxy(&screens[i], 0,
1844 filename_offset[i] +
1845 PM_HEIGHT + 4, true);
1846 break;
1847 #ifdef HAVE_AGC
1848 case 4:
1849 case 5:
1850 for(i = 0; i < screen_update; i++)
1851 screen_put_cursorxy(&screens[i], 0,
1852 filename_offset[i] +
1853 PM_HEIGHT + line[i], true);
1854 break;
1855 #endif /* HAVE_AGC */
1856 default:
1857 for(i = 0; i < screen_update; i++)
1858 screen_put_cursorxy(&screens[i], 0,
1859 filename_offset[i] +
1860 PM_HEIGHT + 2, true);
1864 #ifdef HAVE_AGC
1865 hist_time++;
1866 #endif
1868 for(i = 0; i < screen_update; i++)
1870 gui_statusbar_draw(&(statusbars.statusbars[i]), true);
1871 peak_meter_screen(&screens[i], pm_x, pm_y[i], h*PM_HEIGHT);
1872 screens[i].update();
1875 /* draw the trigger status */
1876 FOR_NB_SCREENS(i)
1878 trig_width[i] = ((screens[i].height < 64) ||
1879 ((screens[i].height < 72) && (PM_HEIGHT > 1))) ?
1880 screens[i].width - 14 * w : screens[i].width;
1881 trig_xpos[i] = screens[i].width - trig_width[i];
1882 trig_ypos[i] = ((screens[i].height < 72) && (PM_HEIGHT > 1)) ?
1883 h*2 :
1884 h*(1 + filename_offset[i] + PM_HEIGHT +
1885 line[i]
1886 #ifdef HAVE_AGC
1888 #endif
1892 if (peak_meter_trigger_status() != TRIG_OFF)
1894 peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width,
1895 screen_update);
1896 for(i = 0; i < screen_update; i++){
1897 screens[i].update_rect(trig_xpos[i], trig_ypos[i],
1898 trig_width[i] + 2, TRIG_HEIGHT);
1903 if(audio_stat & AUDIO_STATUS_ERROR)
1905 done = true;
1907 } /* end while(!done) */
1909 audio_stat = audio_status();
1910 if (audio_stat & AUDIO_STATUS_ERROR)
1912 gui_syncsplash(0, str(LANG_SYSFONT_DISK_FULL));
1913 gui_syncstatusbar_draw(&statusbars, true);
1915 FOR_NB_SCREENS(i)
1916 screens[i].update();
1918 #if CONFIG_CODEC == SWCODEC
1919 /* stop recording - some players like H10 freeze otherwise
1920 TO DO: find out why it freezes and fix properly */
1921 rec_command(RECORDING_CMD_STOP);
1922 audio_close_recording();
1923 #endif
1925 audio_error_clear();
1927 while(1)
1929 if (action_userabort(TIMEOUT_NOBLOCK))
1930 break;
1934 rec_abort:
1936 #if CONFIG_CODEC == SWCODEC
1937 rec_command(RECORDING_CMD_STOP);
1938 audio_close_recording();
1940 #ifdef HAVE_FMRADIO_REC
1941 if (radio_status != FMRADIO_OFF)
1942 /* Restore radio playback - radio_status should be unchanged if started
1943 through fm radio screen (barring usb connect) */
1944 rec_set_source(AUDIO_SRC_FMRADIO, (radio_status & FMRADIO_PAUSED) ?
1945 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
1946 else
1947 #endif
1948 /* Go back to playback mode */
1949 rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
1951 /* restore talking */
1952 talk_disable(false);
1953 #else /* !SWCODEC */
1954 audio_init_playback();
1955 #endif /* CONFIG_CODEC == SWCODEC */
1957 /* make sure the trigger is really turned off */
1958 peak_meter_trigger(false);
1959 peak_meter_set_trigger_listener(NULL);
1961 rec_status &= ~RCSTAT_IN_RECSCREEN;
1962 sound_settings_apply();
1964 FOR_NB_SCREENS(i)
1965 screens[i].setfont(FONT_UI);
1967 /* if the directory was created or recording happened, make sure the
1968 browser is updated */
1969 if (rec_status & (RCSTAT_CREATED_DIRECTORY | RCSTAT_HAVE_RECORDED))
1970 reload_directory();
1972 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
1973 ata_set_led_enabled(true);
1974 #endif
1976 settings_save();
1978 return (rec_status & RCSTAT_BEEN_IN_USB_MODE) != 0;
1979 } /* recording_screen */
1981 #if CONFIG_KEYPAD == RECORDER_PAD
1982 static bool f2_rec_screen(void)
1984 static const char* const freq_str[6] =
1986 "44.1kHz",
1987 "48kHz",
1988 "32kHz",
1989 "22.05kHz",
1990 "24kHz",
1991 "16kHz"
1994 bool exit = false;
1995 bool used = false;
1996 int w, h, i;
1997 char buf[32];
1998 int button;
1999 struct audio_recording_options rec_options;
2001 FOR_NB_SCREENS(i)
2003 screens[i].setfont(FONT_SYSFIXED);
2004 screens[i].getstringsize("A",&w,&h);
2007 while (!exit) {
2008 const char* ptr=NULL;
2010 FOR_NB_SCREENS(i)
2012 screens[i].clear_display();
2014 /* Recording quality */
2015 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
2016 str(LANG_SYSFONT_RECORDING_QUALITY));
2019 snprintf(buf, sizeof(buf), "%d", global_settings.rec_quality);
2020 FOR_NB_SCREENS(i)
2022 screens[i].putsxy(0, LCD_HEIGHT/2-h, buf);
2023 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
2024 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
2027 /* Frequency */
2028 snprintf(buf, sizeof buf, "%s:", str(LANG_SYSFONT_RECORDING_FREQUENCY));
2029 ptr = freq_str[global_settings.rec_frequency];
2030 FOR_NB_SCREENS(i)
2032 screens[i].getstringsize(buf,&w,&h);
2033 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, buf);
2034 screens[i].getstringsize(ptr, &w, &h);
2035 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr);
2036 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
2037 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
2040 /* Channel mode */
2041 switch ( global_settings.rec_channels ) {
2042 case 0:
2043 ptr = str(LANG_SYSFONT_CHANNEL_STEREO);
2044 break;
2046 case 1:
2047 ptr = str(LANG_SYSFONT_CHANNEL_MONO);
2048 break;
2051 FOR_NB_SCREENS(i)
2053 screens[i].getstringsize(str(LANG_SYSFONT_CHANNELS), &w, &h);
2054 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2,
2055 str(LANG_SYSFONT_CHANNELS));
2056 screens[i].getstringsize(str(LANG_SYSFONT_MODE), &w, &h);
2057 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h,
2058 str(LANG_SYSFONT_MODE));
2059 screens[i].getstringsize(ptr, &w, &h);
2060 screens[i].putsxy(LCD_WIDTH - w, LCD_HEIGHT/2, ptr);
2061 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastForward],
2062 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8);
2064 screens[i].update();
2067 button = button_get(true);
2068 switch (button) {
2069 case BUTTON_LEFT:
2070 case BUTTON_F2 | BUTTON_LEFT:
2071 global_settings.rec_quality++;
2072 if(global_settings.rec_quality > 7)
2073 global_settings.rec_quality = 0;
2074 used = true;
2075 break;
2077 case BUTTON_DOWN:
2078 case BUTTON_F2 | BUTTON_DOWN:
2079 global_settings.rec_frequency++;
2080 if(global_settings.rec_frequency > 5)
2081 global_settings.rec_frequency = 0;
2082 used = true;
2083 break;
2085 case BUTTON_RIGHT:
2086 case BUTTON_F2 | BUTTON_RIGHT:
2087 global_settings.rec_channels++;
2088 if(global_settings.rec_channels > 1)
2089 global_settings.rec_channels = 0;
2090 used = true;
2091 break;
2093 case BUTTON_F2 | BUTTON_REL:
2094 if ( used )
2095 exit = true;
2096 used = true;
2097 break;
2099 case BUTTON_F2 | BUTTON_REPEAT:
2100 used = true;
2101 break;
2103 default:
2104 if(default_event_handler(button) == SYS_USB_CONNECTED)
2105 return true;
2106 break;
2110 rec_init_recording_options(&rec_options);
2111 rec_set_recording_options(&rec_options);
2113 set_gain();
2115 settings_save();
2116 FOR_NB_SCREENS(i)
2117 screens[i].setfont(FONT_UI);
2119 return false;
2122 static bool f3_rec_screen(void)
2124 bool exit = false;
2125 bool used = false;
2126 int w, h, i;
2127 int button;
2128 char *src_str[] =
2130 str(LANG_SYSFONT_RECORDING_SRC_MIC),
2131 str(LANG_SYSFONT_LINE_IN),
2132 str(LANG_SYSFONT_RECORDING_SRC_DIGITAL)
2134 struct audio_recording_options rec_options;
2136 FOR_NB_SCREENS(i)
2138 screens[i].setfont(FONT_SYSFIXED);
2139 screens[i].getstringsize("A",&w,&h);
2142 while (!exit) {
2143 char* ptr=NULL;
2144 ptr = src_str[global_settings.rec_source];
2145 FOR_NB_SCREENS(i)
2147 screens[i].clear_display();
2149 /* Recording source */
2150 screens[i].putsxy(0, LCD_HEIGHT/2 - h*2,
2151 str(LANG_SYSFONT_RECORDING_SOURCE));
2153 screens[i].getstringsize(ptr, &w, &h);
2154 screens[i].putsxy(0, LCD_HEIGHT/2-h, ptr);
2155 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_FastBackward],
2156 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8);
2159 /* trigger setup */
2160 ptr = str(LANG_SYSFONT_RECORD_TRIGGER);
2161 FOR_NB_SCREENS(i)
2163 screens[i].getstringsize(ptr,&w,&h);
2164 screens[i].putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h*2, ptr);
2165 screens[i].mono_bitmap(bitmap_icons_7x8[Icon_DownArrow],
2166 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8);
2168 screens[i].update();
2171 button = button_get(true);
2172 switch (button) {
2173 case BUTTON_DOWN:
2174 case BUTTON_F3 | BUTTON_DOWN:
2175 #ifndef SIMULATOR
2176 rectrigger();
2177 settings_apply_trigger();
2178 #endif
2179 exit = true;
2180 break;
2182 case BUTTON_LEFT:
2183 case BUTTON_F3 | BUTTON_LEFT:
2184 global_settings.rec_source++;
2185 if(global_settings.rec_source > AUDIO_SRC_MAX)
2186 global_settings.rec_source = 0;
2187 used = true;
2188 break;
2190 case BUTTON_F3 | BUTTON_REL:
2191 if ( used )
2192 exit = true;
2193 used = true;
2194 break;
2196 case BUTTON_F3 | BUTTON_REPEAT:
2197 used = true;
2198 break;
2200 default:
2201 if(default_event_handler(button) == SYS_USB_CONNECTED)
2202 return true;
2203 break;
2207 rec_init_recording_options(&rec_options);
2208 rec_set_recording_options(&rec_options);
2210 set_gain();
2212 settings_save();
2213 FOR_NB_SCREENS(i)
2214 screens[i].setfont(FONT_UI);
2216 return false;
2218 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
2220 #if CONFIG_CODEC == SWCODEC
2221 void audio_beep(int duration)
2223 /* dummy */
2224 (void)duration;
2227 #ifdef SIMULATOR
2228 /* stubs for recording sim */
2229 void audio_init_recording(unsigned int buffer_offset)
2231 buffer_offset = buffer_offset;
2234 void audio_close_recording(void)
2238 unsigned long pcm_rec_get_warnings(void)
2240 return 0;
2243 unsigned long audio_recorded_time(void)
2245 return 123;
2248 unsigned long audio_num_recorded_bytes(void)
2250 return 5 * 1024 * 1024;
2253 void rec_set_source(int source, unsigned flags)
2255 source = source;
2256 flags = flags;
2259 void audio_set_recording_options(struct audio_recording_options *options)
2261 options = options;
2264 void audio_set_recording_gain(int left, int right, int type)
2266 left = left;
2267 right = right;
2268 type = type;
2271 void audio_record(const char *filename)
2273 filename = filename;
2276 void audio_new_file(const char *filename)
2278 filename = filename;
2281 void audio_stop_recording(void)
2285 void audio_pause_recording(void)
2289 void audio_resume_recording(void)
2293 #endif /* #ifdef SIMULATOR */
2294 #endif /* #ifdef CONFIG_CODEC == SWCODEC */
2296 #endif /* HAVE_RECORDING */