diff --strip-trailing-cr -u -r rockbox-bleeding_20050905/apps/misc.c rockbox-patched/apps/misc.c --- rockbox-bleeding_20050905/apps/misc.c 2005-09-02 07:39:42.000000000 +0200 +++ rockbox-patched/apps/misc.c 2005-09-05 10:36:38.000000000 +0200 @@ -43,6 +43,7 @@ #include "atoi.h" #include "version.h" #include "font.h" +#include "tree.h" #ifdef HAVE_MMC #include "ata_mmc.h" #endif @@ -535,3 +536,46 @@ return 0; } + +#if defined(HAVE_RECORDING) || (CONFIG_CODEC == SWCODEC) +char *rec_create_filename(char *buffer, char *suffix) +{ + if(global_settings.rec_directory) + getcwd(buffer, MAX_PATH); + else + strncpy(buffer, REC_BASE_DIR, MAX_PATH); + +#ifdef HAVE_RTC + create_datetime_filename(buffer, buffer, "R", suffix); +#else + create_numbered_filename(buffer, buffer, "rec_", suffix, 4); +#endif + return buffer; +} + +int rec_create_directory(void) +{ + int rc; + + /* Try to create the base directory if needed */ + if(global_settings.rec_directory == 0) + { + rc = mkdir(REC_BASE_DIR, 0); + if(rc < 0 && errno != EEXIST) + { + splash(HZ * 2, true, + "Can't create the %s directory. Error code %d.", + REC_BASE_DIR, rc); + return -1; + } + else + { + /* If we have created the directory, we want the dir browser to + be refreshed even if we haven't recorded anything */ + if(errno != EEXIST) + return 1; + } + } + return 0; +} +#endif diff --strip-trailing-cr -u -r rockbox-bleeding_20050905/apps/recorder/radio.c rockbox-patched/apps/recorder/radio.c --- rockbox-bleeding_20050905/apps/recorder/radio.c 2005-08-29 23:16:12.000000000 +0200 +++ rockbox-patched/apps/recorder/radio.c 2005-09-05 11:48:48.000000000 +0200 @@ -52,6 +52,8 @@ #include "hwcompat.h" #include "power.h" #include "sound.h" +#include "tree.h" +#include "dir.h" #ifdef CONFIG_TUNER @@ -71,6 +73,7 @@ #define FM_PRESET_ACTION BUTTON_F3 #elif CONFIG_KEYPAD == IRIVER_H100_PAD #define FM_MENU BUTTON_MODE +#define FM_RECORD BUTTON_REC #define FM_STOP BUTTON_OFF #define FM_EXIT_PRE BUTTON_SELECT #define FM_EXIT (BUTTON_SELECT | BUTTON_REL) @@ -105,7 +108,7 @@ #ifdef SIMULATOR void radio_set(int setting, int value); -int radio_get(int setting); +int radio_get(int setting); #else #if CONFIG_TUNER == S1A0903X01 /* FM recorder */ #define radio_set samsung_set @@ -115,7 +118,7 @@ #define radio_get philips_get #elif CONFIG_TUNER == (S1A0903X01 | TEA5767) /* OndioFM */ void (*radio_set)(int setting, int value); -int (*radio_get)(int setting); +int (*radio_get)(int setting); #endif #endif @@ -177,6 +180,36 @@ settings_save(); } +#if !defined(SIMULATOR) && (CONFIG_CODEC == SWCODEC) + +#define audio_stop pcm_stop +#define audio_status pcm_status + +extern void pcm_new_file(const char *filename); + +void pcm__record(char *fname) +{ + int rec_gain, rec_vol, rec_source, rec_waveform; + + rec_source = 0; // Line-in + rec_gain = 0; // 0-15 + rec_vol = 28; // 0-255 + rec_waveform = 0; + + pcm_open_recording(); + pcm_set_recording_options(rec_source, rec_waveform); + pcm_set_recording_gain(rec_gain, rec_vol); + pcm_record(fname); +} + +void pcm_stop(void) +{ + pcm_stop_recording(); + pcm_close_recording(); + uda1380_enable_recording(false); +} +#endif + bool radio_screen(void) { char buf[MAX_PATH]; @@ -213,10 +246,8 @@ radio_load_presets(); #ifndef SIMULATOR -#if CONFIG_CODEC != SWCODEC if(rec_create_directory() > 0) have_recorded = true; -#endif audio_stop(); @@ -326,14 +357,22 @@ #ifndef SIMULATOR if(audio_status() == AUDIO_STATUS_RECORD) { - mpeg_new_file(rec_create_filename(buf)); +#if CONFIG_CODEC == SWCODEC + pcm_new_file(rec_create_filename(buf, ".wav")); +#else + mpeg_new_file(rec_create_filename(buf, ".mp3")); +#endif update_screen = true; } else { have_recorded = true; talk_buffer_steal(); /* we use the mp3 buffer */ - mpeg_record(rec_create_filename(buf)); +#if CONFIG_CODEC == SWCODEC + pcm__record(rec_create_filename(buf, ".wav")); +#else + mpeg_record(rec_create_filename(buf, ".mp3")); +#endif update_screen = true; } #endif @@ -497,7 +536,9 @@ } #ifndef SIMULATOR -#if CONFIG_CODEC != SWCODEC +#if (CONFIG_CODEC == SWCODEC) + seconds = pcm_recorded_time() / HZ; +#else seconds = mpeg_recorded_time() / HZ; #endif #endif diff --strip-trailing-cr -u -r rockbox-bleeding_20050905/apps/recorder/recording.c rockbox-patched/apps/recorder/recording.c --- rockbox-bleeding_20050905/apps/recorder/recording.c 2005-09-02 03:16:06.000000000 +0200 +++ rockbox-patched/apps/recorder/recording.c 2005-09-05 10:26:06.000000000 +0200 @@ -52,6 +52,7 @@ #include "atoi.h" #include "sound.h" #include "ata.h" +#include "recording.h" #ifdef HAVE_RECORDING @@ -162,47 +163,6 @@ } } -char *rec_create_filename(char *buffer) -{ - if(global_settings.rec_directory) - getcwd(buffer, MAX_PATH); - else - strncpy(buffer, rec_base_directory, MAX_PATH); - -#ifdef HAVE_RTC - create_datetime_filename(buffer, buffer, "R", ".mp3"); -#else - create_numbered_filename(buffer, buffer, "rec_", ".mp3", 4); -#endif - return buffer; -} - -int rec_create_directory(void) -{ - int rc; - - /* Try to create the base directory if needed */ - if(global_settings.rec_directory == 0) - { - rc = mkdir(rec_base_directory, 0); - if(rc < 0 && errno != EEXIST) - { - splash(HZ * 2, true, - "Can't create the %s directory. Error code %d.", - rec_base_directory, rc); - return -1; - } - else - { - /* If we have created the directory, we want the dir browser to - be refreshed even if we haven't recorded anything */ - if(errno != EEXIST) - return 1; - } - } - return 0; -} - static char path_buffer[MAX_PATH]; /* used in trigger_listerner and recording_screen */ @@ -221,7 +181,7 @@ if((audio_status() & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD) { talk_buffer_steal(); /* we use the mp3 buffer */ - mpeg_record(rec_create_filename(path_buffer)); + mpeg_record(rec_create_filename(path_buffer, ".mp3")); /* give control to mpeg thread so that it can start recording */ yield(); yield(); yield(); @@ -230,7 +190,7 @@ /* if we're already recording this is a retrigger */ else { - mpeg_new_file(rec_create_filename(path_buffer)); + mpeg_new_file(rec_create_filename(path_buffer, ".mp3")); /* tell recording_screen to reset the time */ last_seconds = 0; } @@ -405,7 +365,7 @@ /* manual recording */ have_recorded = true; talk_buffer_steal(); /* we use the mp3 buffer */ - mpeg_record(rec_create_filename(path_buffer)); + mpeg_record(rec_create_filename(path_buffer, ".mp3")); last_seconds = 0; if (global_settings.talk_menu) { /* no voice possible here, but a beep */ @@ -585,7 +545,7 @@ case REC_F3: if(audio_stat & AUDIO_STATUS_RECORD) { - mpeg_new_file(rec_create_filename(path_buffer)); + mpeg_new_file(rec_create_filename(path_buffer, ".mp3")); last_seconds = 0; } else @@ -686,7 +646,7 @@ ((global_settings.rec_timesplit && (seconds >= dseconds)) || (num_recorded_bytes >= MAX_FILE_SIZE))) { - mpeg_new_file(rec_create_filename(path_buffer)); + mpeg_new_file(rec_create_filename(path_buffer, ".mp3")); update_countdown = 1; last_seconds = 0; } diff --strip-trailing-cr -u -r rockbox-bleeding_20050905/apps/recorder/recording.h rockbox-patched/apps/recorder/recording.h --- rockbox-bleeding_20050905/apps/recorder/recording.h 2004-06-04 14:40:00.000000000 +0200 +++ rockbox-patched/apps/recorder/recording.h 2005-09-03 19:42:48.000000000 +0200 @@ -20,7 +20,7 @@ #define RECORDING_H bool recording_screen(void); -char *rec_create_filename(char *buf); +char *rec_create_filename(char *buf, char *suffix); int rec_create_directory(void); #endif Only in rockbox-patched: build Only in rockbox-patched: build_h100 Only in rockbox-patched: build_h100_sim Only in rockbox-patched: build_ondio Only in rockbox-patched: build_ondio_sim Only in rockbox-patched: build_sim Only in rockbox-patched: buildd diff --strip-trailing-cr -u -r rockbox-bleeding_20050905/docs/CREDITS rockbox-patched/docs/CREDITS --- rockbox-bleeding_20050905/docs/CREDITS 2005-09-04 14:02:38.000000000 +0200 +++ rockbox-patched/docs/CREDITS 2005-08-23 23:53:18.000000000 +0200 @@ -133,4 +133,3 @@ Naftali Goldstein David Dent Frank Dischner -Liberman Shachar diff --strip-trailing-cr -u -r rockbox-bleeding_20050905/firmware/pcm_record.c rockbox-patched/firmware/pcm_record.c --- rockbox-bleeding_20050905/firmware/pcm_record.c 2005-08-13 19:29:24.000000000 +0200 +++ rockbox-patched/firmware/pcm_record.c 2005-09-05 09:34:44.000000000 +0200 @@ -53,20 +53,19 @@ /***************************************************************************/ -static volatile bool is_recording; /* We are recording */ -static volatile bool is_stopping; /* Are we going to stop */ -static volatile bool is_paused; /* We have paused */ - -static volatile int num_rec_bytes; -static volatile int int_count; /* Number of DMA completed interrupts */ -static volatile int error_count; /* Number of DMA errors */ +static bool is_recording; /* We are recording */ +static bool is_stopping; /* Are we going to stop */ +static bool is_paused; /* We have paused */ +static bool is_closed; /* We have rec closed */ +static int num_rec_bytes; +static int error_count; /* Number of DMA errors */ static unsigned long record_start_time; /* Value of current_tick when recording was started */ static unsigned long pause_start_time; /* Value of current_tick when pause was started */ static int rec_gain, rec_volume; static bool show_waveform; -static int init_done = 0; +static bool init_done = 0; static int wav_file; static char recording_filename[MAX_PATH]; @@ -122,9 +121,26 @@ /* Functions that are not executing in the pcmrec_thread first */ /*******************************************************************/ +/* wait a maximum of 2s for state change */ +void pcm_wait(bool *state, bool newstate, const char *message) +{ + int cnt; + + for(cnt=0; cnt<200 && *state!=newstate; cnt++) + { + sleep(HZ/100); + } + + if(cnt == 200) + { + (void)message; + logf(message); + } +} + + void pcm_init_recording(void) { - int_count = 0; error_count = 0; show_waveform = 0; @@ -147,10 +163,7 @@ queue_post(&pcmrec_queue, PCMREC_OPEN, 0); - while (init_done) - { - sleep(HZ >> 8); - } + pcm_wait(&init_done, true, "OpenRecord Failed"); logf("pcm_open_rec done"); } @@ -158,7 +171,11 @@ void pcm_close_recording(void) { /* todo: synchronize completion with pcmrec thread */ + is_closed = false; + queue_post(&pcmrec_queue, PCMREC_CLOSE, 0); + + pcm_wait(&is_closed, true, "CloseRecord Failed"); } @@ -267,18 +284,17 @@ void pcm_stop_recording(void) { if (is_recording) - is_stopping = 1; + { + is_stopping = 1; - queue_post(&pcmrec_queue, PCMREC_STOP, 0); + logf("pcm_stop_recording"); - logf("pcm_stop_recording"); + queue_post(&pcmrec_queue, PCMREC_STOP, 0); - while (is_stopping) - { - sleep(HZ >> 4); - } + pcm_wait(&is_stopping, false, "StopRecord Failed"); - logf("pcm_stop_recording done"); + logf("pcm_stop_recording done"); + } } @@ -347,7 +363,7 @@ /* that if it's closing time which mean we have to save.. */ if (wav_file != -1) { - if (num_ready >= WRITE_THRESHOLD || flush) + if (num_ready >= WRITE_THRESHOLD || (flush && num_ready)) { unsigned long *ptr = (unsigned long*)rec_buffers[read_index]; int i; @@ -379,9 +395,9 @@ void pcmrec_dma_start(void) { - DAR1 = (unsigned long)rec_buffers[write_index++]; /* Destination address */ - SAR1 = (unsigned long)&PDIR2; /* Source address */ - BCR1 = EACH_BUFFER_SIZE; /* Bytes to transfer */ + DAR1 = (unsigned long)rec_buffers[write_index]; /* Destination address */ + SAR1 = (unsigned long)&PDIR2; /* Source address */ + BCR1 = EACH_BUFFER_SIZE; /* Bytes to transfer */ /* Start the DMA transfer.. */ DCR1 = DMA_INT | DMA_EEXT | DMA_CS | DMA_DINC | DMA_START; @@ -398,8 +414,6 @@ DSR1 = 1; /* Clear interrupt */ - int_count++; - if (res & 0x70) { DCR1 = 0; /* Stop DMA transfer */ @@ -439,8 +453,6 @@ } } - - IPR |= (1<<15); /* Clear pending interrupt request */ } static int start_wave(void) @@ -526,10 +538,7 @@ logf("pcmrec_stop"); - while (is_recording) - { - sleep(HZ >> 4); - } + pcm_wait(&is_recording, false, "StopRecord Failed"); logf("pcmrec_stop done"); @@ -587,7 +596,7 @@ DMAROUTE = (DMAROUTE & 0xffff00ff); ICR4 = (ICR4 & 0xffffff00); /* Disable interrupt */ IMR |= (1<<15); /* bit 15 is DMA1 */ - + is_closed = true; } static void pcmrec_thread(void) Only in rockbox-patched/tools: bmp2rb.exe Only in rockbox-patched/tools: convbdf.exe Only in rockbox-patched/tools: descramble.exe Only in rockbox-patched/tools: descramble.o Only in rockbox-patched/tools: generate_rocklatin.exe Only in rockbox-patched/tools: iaudio.exe Only in rockbox-patched/tools: iaudio.o Only in rockbox-patched/tools: iriver.o Only in rockbox-patched/tools: mkboot.exe Only in rockbox-patched/tools: rdf2binary.exe Only in rockbox-patched/tools: scramble.exe Only in rockbox-patched/tools: scramble.o Only in rockbox-patched/tools: sh2d.exe