diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-07-10 07:41:37 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-07-10 07:41:37 +0000 |
commit | 415e9d78cce1c07f17b4c643eb1b0d2ef1622706 (patch) | |
tree | 46ccafcbfc4003b145704a39bbdb270b3a65cded | |
parent | 1c2de0a45e17fbd5af3cab98ad2b1bc70a801d84 (diff) |
User configurable recording path (my patch in FS#7201). path defaults to / and can be changed in the folder context menu (cleared in the recording settings menu)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13838 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/lang/english.lang | 42 | ||||
-rw-r--r-- | apps/menus/recording_menu.c | 22 | ||||
-rw-r--r-- | apps/onplay.c | 19 | ||||
-rw-r--r-- | apps/plugin.h | 4 | ||||
-rw-r--r-- | apps/recorder/recording.c | 58 | ||||
-rw-r--r-- | apps/settings.c | 3 | ||||
-rw-r--r-- | apps/settings.h | 10 | ||||
-rw-r--r-- | apps/settings_list.c | 11 |
8 files changed, 111 insertions, 58 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index aa664c1886..f4577d9b2d 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -11006,3 +11006,45 @@ *: "Use File .talk Clips" </voice> </phrase> +<phrase> + id: LANG_SET_AS_REC_DIR + desc: + user: + <source> + *: "Set As Recording Directory" + </source> + <dest> + *: "Set As Recording Directory" + </dest> + <voice> + *: "Set As Recording Directory" + </voice> +</phrase> +<phrase> + id: LANG_CLEAR_REC_DIR + desc: + user: + <source> + *: "Clear Recording Directory" + </source> + <dest> + *: "Clear Recording Directory" + </dest> + <voice> + *: "Clear Recording Directory" + </voice> +</phrase> +<phrase> + id: LANG_REC_DIR_NOT_WRITABLE + desc: + user: + <source> + *: "Can't write to recording directory" + </source> + <dest> + *: "Can't write to recording directory" + </dest> + <voice> + *: "Can't write to recording directory" + </voice> +</phrase> diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c index da2007a5e2..4126b9e22a 100644 --- a/apps/menus/recording_menu.c +++ b/apps/menus/recording_menu.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> +#include "string.h" #include "system.h" #include "kernel.h" #include "lcd.h" @@ -313,19 +314,16 @@ MAKE_MENU(filesplitoptionsmenu, ID2P(LANG_RECORD_TIMESPLIT), NULL, Icon_NOICON, MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL); -static int recdirectory_func(void) + +static int clear_rec_directory(void) { - static const struct opt_items names[] = { - { rec_base_directory, -1 }, - { STR(LANG_RECORD_CURRENT_DIR) } - }; - return set_option(str(LANG_RECORD_DIRECTORY), - &global_settings.rec_directory, INT, - names, 2, NULL ); + strcpy(global_settings.rec_directory, REC_BASE_DIR); + gui_syncsplash(HZ, str(LANG_RESET_DONE_CLEAR)); + return false; } -MENUITEM_FUNCTION(recdirectory, 0, ID2P(LANG_RECORD_DIRECTORY), - recdirectory_func, NULL, NULL, Icon_Menu_setting); - +MENUITEM_FUNCTION(clear_rec_directory_item, 0, ID2P(LANG_CLEAR_REC_DIR), + clear_rec_directory, NULL, NULL, Icon_Folder); + MENUITEM_SETTING(cliplight, &global_settings.cliplight, NULL); #ifdef HAVE_AGC @@ -835,7 +833,7 @@ MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS), #endif &filesplitoptionsmenu, &rec_prerecord_time, - &recdirectory, + &clear_rec_directory_item, #ifdef HAVE_BACKLIGHT &cliplight, #endif diff --git a/apps/onplay.c b/apps/onplay.c index d1098b7719..cba03733fd 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -1043,6 +1043,16 @@ MENUITEM_FUNCTION(list_viewers_item, 0, ID2P(LANG_ONPLAY_OPEN_WITH), MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP), set_backdrop, NULL, clipboard_callback, Icon_NOICON); #endif +#ifdef HAVE_RECORDING +static bool set_recdir(void) +{ + strncpy(global_settings.rec_directory, + selected_file, MAX_FILENAME+1); + return false; +} +MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR), + set_recdir, NULL, clipboard_callback, Icon_Recording); +#endif @@ -1090,6 +1100,10 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item) if ((this_item == &delete_dir_item) ) return action; +#ifdef HAVE_RECORDING + else if (this_item == &set_recdir_item) + return action; +#endif } else if (selected_file #ifdef HAVE_MULTIVOLUME @@ -1135,7 +1149,10 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE), #if LCD_DEPTH > 1 &set_backdrop_item, #endif - &list_viewers_item, &create_dir_item, &properties_item + &list_viewers_item, &create_dir_item, &properties_item, +#ifdef HAVE_RECORDING + &set_recdir_item, +#endif ); int onplay(char* file, int attr, int from) { diff --git a/apps/plugin.h b/apps/plugin.h index 3b9ca03e32..10dce4dce6 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -115,12 +115,12 @@ #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 60 +#define PLUGIN_API_VERSION 61 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 60 +#define PLUGIN_MIN_API_VERSION 61 /* plugin return codes */ enum plugin_status { diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 17ed1052cb..a085bbbc03 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -508,15 +508,27 @@ static void adjust_cursor(void) cursor = max_cursor; } +static bool check_dir(char *folder) +{ + DIR *dir = opendir(folder); + if (!dir && strcmp(folder, "/")) + { + int rc = mkdir(folder); + if(rc < 0) + return false; + return true; + } + closedir(dir); + return true; +} + char *rec_create_filename(char *buffer) { char ext[16]; - - if(global_settings.rec_directory) - getcwd(buffer, MAX_PATH); - else - strncpy(buffer, rec_base_directory, MAX_PATH); - + strcpy(buffer,global_settings.rec_directory); + if (!check_dir(buffer)) + return NULL; + snprintf(ext, sizeof(ext), ".%s", REC_FILE_ENDING(global_settings.rec_format)); @@ -542,28 +554,7 @@ void rec_init_filename(void) 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); - if(rc < 0 && errno != EEXIST) - { - gui_syncsplash(HZ * 2, - "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; + return check_dir(global_settings.rec_directory)?1:0; } void rec_init_recording_options(struct audio_recording_options *options) @@ -747,7 +738,16 @@ bool recording_screen(bool no_source) }; struct audio_recording_options rec_options; - + if (check_dir(global_settings.rec_directory) == false) + { + do { + gui_syncsplash(0, "%s %s", + str(LANG_REC_DIR_NOT_WRITABLE), + str(LANG_OFF_ABORT)); + } while (action_userabort(HZ) == false); + return false; + } + rec_status = RCSTAT_IN_RECSCREEN; cursor = 0; #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) diff --git a/apps/settings.c b/apps/settings.c index 8adc9637d8..cad5f9206c 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -77,9 +77,6 @@ void dac_line_in(bool enable); struct user_settings global_settings; struct system_status global_status; -#ifdef HAVE_RECORDING -const char rec_base_directory[] = REC_BASE_DIR; -#endif #if CONFIG_CODEC == SWCODEC #include "pcmbuf.h" #include "pcm_playback.h" diff --git a/apps/settings.h b/apps/settings.h index 05e3ada41d..ef3b1ae85f 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -59,7 +59,7 @@ #define PLUGIN_DIR ROCKBOX_DIR "/rocks" #define VIEWERS_DIR ROCKBOX_DIR "/viewers" #define BACKDROP_DIR ROCKBOX_DIR "/backdrops" -#define REC_BASE_DIR "/recordings" +#define REC_BASE_DIR "/" #define EQS_DIR ROCKBOX_DIR "/eqs" #define CODECS_DIR ROCKBOX_DIR "/codecs" #define RECPRESETS_DIR ROCKBOX_DIR "/recpresets" @@ -336,7 +336,7 @@ struct user_settings int crossfade_fade_out_duration; /* Fade out duration (0-15s) */ int crossfade_fade_out_mixmode; /* Fade out mode (0=crossfade,1=mix) */ #endif - +#ifdef HAVE_RECORDING #if CONFIG_CODEC == SWCODEC int rec_format; /* record format index */ #else @@ -370,7 +370,7 @@ struct user_settings int rec_split_method; /* time/filesize */ int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */ - int rec_directory; /* 0=base dir, 1=current dir */ + char rec_directory[MAX_FILENAME+1]; int cliplight; /* 0 = off 1 = main lcd 2 = main and remote lcd @@ -403,7 +403,7 @@ struct user_settings int rec_agc_maxgain_line; /* AGC maximum line-in gain */ int rec_agc_cliptime; /* 0.2, 0.4, 0.6, 0.8, 1s */ #endif - +#endif /* HAVE_RECORDING */ /* device settings */ #ifdef HAVE_LCD_CONTRAST @@ -740,8 +740,6 @@ struct user_settings /** global variables **/ extern long lasttime; -/* Recording base directory */ -extern const char rec_base_directory[]; /* global settings */ extern struct user_settings global_settings; /* global status */ diff --git a/apps/settings_list.c b/apps/settings_list.c index 6c388f7e6b..f4292cf0cb 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -773,11 +773,12 @@ const struct settings_list settings[] = { HAVE_SPDIF_REC_(",spdif") HAVE_FMRADIO_REC_(",fmradio")[1] ,UNUSED}, - INT_SETTING(F_RECSETTING, rec_prerecord_time, LANG_RECORD_PRERECORD_TIME, - 0, "prerecording time", - UNIT_SEC, 0, 30, 1, rectime_formatter, rectime_getlang, NULL), - {F_T_INT|F_RECSETTING,&global_settings.rec_directory,LANG_RECORD_DIRECTORY, - INT(0),"rec directory",REC_BASE_DIR ",current",UNUSED}, + INT_SETTING(F_RECSETTING, rec_prerecord_time, LANG_RECORD_PRERECORD_TIME, + 0, "prerecording time", + UNIT_SEC, 0, 30, 1, rectime_formatter, rectime_getlang, NULL), + + FILENAME_SETTING(F_RECSETTING, rec_directory, "rec path", + REC_BASE_DIR, NULL, NULL, MAX_FILENAME+1), #ifdef HAVE_BACKLIGHT CHOICE_SETTING(F_RECSETTING, cliplight, LANG_CLIP_LIGHT, 0 , "cliplight", "off,main,both,remote", NULL, |