From 3bf321ff1c515da30357f830c435f3cb1c8d899e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hohensohn?= Date: Tue, 21 Dec 2004 23:49:43 +0000 Subject: [PATCH] aid for blind recorders: longer beep when starting a recording, short beep when resuming it (you may disable the voice UI to get rid of it) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5502 a1c6a512-1295-4272-9138-f99709370657 --- apps/recorder/recording.c | 8 ++++++++ firmware/export/mpeg.h | 1 + firmware/mpeg.c | 30 +++++++++++++++++++++++------- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index d67124a6cf..71cd20d797 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -322,6 +322,10 @@ bool recording_screen(void) /* Only act if the mpeg is stopped */ if(!(mpeg_status() & MPEG_STATUS_RECORD)) { + if (global_settings.talk_menu) + { /* no voice possible here, but a beep */ + mpeg_beep(0,HZ/4); /* longer beep on start */ + } have_recorded = true; talk_buffer_steal(); /* we use the mp3 buffer */ mpeg_record(rec_create_filename(path_buffer)); @@ -332,6 +336,10 @@ bool recording_screen(void) { if(mpeg_status() & MPEG_STATUS_PAUSE) { + if (global_settings.talk_menu) + { /* no voice possible here, but a beep */ + mpeg_beep(0,HZ/8); /* short beep on resume */ + } mpeg_resume_recording(); } else diff --git a/firmware/export/mpeg.h b/firmware/export/mpeg.h index f24664edc9..d61789c26e 100644 --- a/firmware/export/mpeg.h +++ b/firmware/export/mpeg.h @@ -99,6 +99,7 @@ unsigned int mpeg_error(void); void mpeg_error_clear(void); int mpeg_get_file_pos(void); unsigned long mpeg_get_last_header(void); +void mpeg_beep(int freq, int duration); /* in order to keep the recording here, I have to expose this */ void rec_tick(void); diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 5a199a4169..26bfbc0dc3 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -53,6 +53,7 @@ static void stop_recording(void); static int get_unsaved_space(void); static void pause_recording(void); static void resume_recording(void); +static int shadow_codec_reg0; #endif /* #if CONFIG_HWCODEC == MAS3587F */ #ifndef SIMULATOR @@ -2090,7 +2091,8 @@ static void init_recording(void) } /* Enable A/D Converters */ - mas_codec_writereg(0x0, 0xcccd); + shadow_codec_reg0 = 0xcccd; + mas_codec_writereg(0x0, shadow_codec_reg0); /* Copy left channel to right (mono mode) */ mas_codec_writereg(8, 0x8000); @@ -2366,12 +2368,26 @@ void mpeg_set_recording_options(int frequency, int quality, void mpeg_set_recording_gain(int left, int right, bool use_mic) { /* Enable both left and right A/D */ - mas_codec_writereg(0x0, - (left << 12) | - (right << 8) | - (left << 4) | - (use_mic?0x0008:0) | /* Connect left A/D to mic */ - 0x0007); + shadow_codec_reg0 = (left << 12) | + (right << 8) | + (left << 4) | + (use_mic?0x0008:0) | /* Connect left A/D to mic */ + 0x0007; + mas_codec_writereg(0x0, shadow_codec_reg0); +} + +/* try to make some kind of beep, also in recording mode */ +void mpeg_beep(int freq, int duration) +{ + (void)freq; /* not used yet */ + long starttick = current_tick; + do + { + mas_codec_writereg(0, 0); /* some little-understood sequence, */ + mas_codec_writereg(0, 1); /* there may be better ways */ + } + while (current_tick - starttick < duration); + mas_codec_writereg(0, shadow_codec_reg0); /* restore it */ } void mpeg_new_file(const char *filename)