? build ? play_rec_file.patch Index: apps/tree.c =================================================================== RCS file: /cvsroot/rockbox/apps/tree.c,v retrieving revision 1.353 diff -u -b -r1.353 tree.c --- apps/tree.c 2 Sep 2005 16:50:51 -0000 1.353 +++ apps/tree.c 4 Sep 2005 17:16:06 -0000 @@ -573,6 +573,28 @@ tagdb_shutdown(); } +/** + * If the user left the recording screen with a request to play the + * recording this function generates and starts a playlist with the file. + * @return: returns true when playback has started. Typically the caller + * uses this return value to set start_wps. + */ +static bool play_recording(void) +{ + bool retval = false; + if (rec_play_recording) + { + struct tree_context *tc = tree_get_context(); + set_current_file(rec_abs_filename); + + playlist_create(tc->currdir, NULL); + playlist_add(lastfile); /* has been set by set_current_file */ + playlist_start(0, 0); + retval = true; + } + return retval; +} + static bool dirbrowse(void) { int numentries=0; @@ -620,9 +642,16 @@ /* We fake being in the menu structure by calling the appropriate parent when we drop out of each screen */ recording_screen(); + if (rec_play_recording) + { + play_recording(); + } + else + { rec_menu(); main_menu(); } + } else #endif #endif @@ -964,7 +993,10 @@ { lcd_stop_scroll(); if (main_menu()) + { + start_wps = play_recording(); reload_dir = true; + } restore = true; id3db = check_changed_id3mode(id3db); @@ -1149,9 +1181,19 @@ if (start_wps) { + start_wps = false; lcd_stop_scroll(); - if (wps_show() == SYS_USB_CONNECTED) + + switch (wps_show()) + { + case true: + start_wps = play_recording(); + break; + + case SYS_USB_CONNECTED: reload_dir = true; + break; + } #ifdef HAVE_HOTSWAP else if (!id3db) /* Try reload to catch 'no longer valid' case. */ @@ -1162,7 +1204,6 @@ #endif id3db = check_changed_id3mode(id3db); restore = true; - start_wps=false; } check_rescan: Index: apps/recorder/recording.c =================================================================== RCS file: /cvsroot/rockbox/apps/recorder/recording.c,v retrieving revision 1.87 diff -u -b -r1.87 recording.c --- apps/recorder/recording.c 2 Sep 2005 01:15:35 -0000 1.87 +++ apps/recorder/recording.c 4 Sep 2005 17:16:10 -0000 @@ -58,6 +58,7 @@ #if CONFIG_KEYPAD == RECORDER_PAD #define REC_STOPEXIT BUTTON_OFF +#define REC_PLAYEXIT BUTTON_ON #define REC_RECPAUSE BUTTON_PLAY #define REC_INC BUTTON_RIGHT #define REC_DEC BUTTON_LEFT @@ -94,6 +95,12 @@ #define MAX_FILE_SIZE 0x7FF00000 /* 2 GB - 1 MB */ +/* contains the absolute file name of the last recording */ +char rec_abs_filename[MAX_PATH]; + +/* request to play the new recording after user quits recording screen*/ +bool rec_play_recording = false; + const char* const freq_str[6] = { "44.1kHz", @@ -203,8 +210,6 @@ return 0; } -static char path_buffer[MAX_PATH]; - /* used in trigger_listerner and recording_screen */ static unsigned int last_seconds = 0; @@ -221,7 +226,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(rec_abs_filename)); /* give control to mpeg thread so that it can start recording */ yield(); yield(); yield(); @@ -230,7 +235,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(rec_abs_filename)); /* tell recording_screen to reset the time */ last_seconds = 0; } @@ -263,7 +268,6 @@ bool have_recorded = false; unsigned int seconds; int hours, minutes; - char path_buffer[MAX_PATH]; bool been_in_usb_mode = false; int last_audio_stat = -1; #if CONFIG_LED == LED_REAL @@ -283,6 +287,7 @@ ata_set_led_enabled(false); #endif mpeg_init_recording(); + rec_play_recording = false; sound_set(SOUND_VOLUME, global_settings.volume); @@ -394,6 +399,18 @@ update_countdown = 1; /* Update immediately */ break; + case REC_PLAYEXIT: + if (((audio_stat & AUDIO_STATUS_RECORD) != AUDIO_STATUS_RECORD) + && have_recorded) + { + rec_play_recording = true; + /* abuse usb_mode to indicate that the user doesn't want to + return to the menu but wants play the new recording */ + been_in_usb_mode = true; + done = true; + } + break; + case REC_RECPAUSE: /* Only act if the mpeg is stopped */ if(!(audio_stat & AUDIO_STATUS_RECORD)) @@ -405,7 +422,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(rec_abs_filename)); last_seconds = 0; if (global_settings.talk_menu) { /* no voice possible here, but a beep */ @@ -585,7 +602,7 @@ case REC_F3: if(audio_stat & AUDIO_STATUS_RECORD) { - mpeg_new_file(rec_create_filename(path_buffer)); + mpeg_new_file(rec_create_filename(rec_abs_filename)); last_seconds = 0; } else @@ -686,7 +703,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(rec_abs_filename)); update_countdown = 1; last_seconds = 0; } Index: apps/recorder/recording.h =================================================================== RCS file: /cvsroot/rockbox/apps/recorder/recording.h,v retrieving revision 1.4 diff -u -b -r1.4 recording.h --- apps/recorder/recording.h 4 Jun 2004 12:34:29 -0000 1.4 +++ apps/recorder/recording.h 4 Sep 2005 17:16:10 -0000 @@ -19,6 +19,12 @@ #ifndef RECORDING_H #define RECORDING_H +/* contains the absolute file name of the last recording */ +extern char rec_abs_filename[MAX_PATH]; + +/* request to play the new recording after user quits recording screen*/ +extern bool rec_play_recording; + bool recording_screen(void); char *rec_create_filename(char *buf); int rec_create_directory(void);