Index: apps/recorder/recording.c
===================================================================
--- apps/recorder/recording.c (revision 13605)
+++ apps/recorder/recording.c (working copy)
@@ -499,15 +499,27 @@
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));
@@ -523,28 +535,7 @@
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)
@@ -734,6 +725,16 @@
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;
+ }
+
in_screen = true;
cursor = 0;
#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang (revision 13605)
+++ apps/lang/english.lang (working copy)
@@ -11006,3 +11006,45 @@
*: "Use File .talk Clips"
+
+ id: LANG_SET_AS_REC_DIR
+ desc:
+ user:
+
+ *: "Set As Recording Directory"
+
+
+ *: "Set As Recording Directory"
+
+
+ *: "Set As Recording Directory"
+
+
+
+ id: LANG_CLEAR_REC_DIR
+ desc:
+ user:
+
+ *: "Clear Recording Directory"
+
+
+ *: "Clear Recording Directory"
+
+
+ *: "Clear Recording Directory"
+
+
+
+ id: LANG_REC_DIR_NOT_WRITABLE
+ desc:
+ user:
+
+ *: "Can't write to recording directory"
+
+
+ *: "Can't write to recording directory"
+
+
+ *: "Can't write to recording directory"
+
+
Index: apps/settings.c
===================================================================
--- apps/settings.c (revision 13605)
+++ apps/settings.c (working copy)
@@ -76,9 +76,6 @@
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"
Index: apps/onplay.c
===================================================================
--- apps/onplay.c (revision 13605)
+++ apps/onplay.c (working copy)
@@ -1043,6 +1043,16 @@
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 @@
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 @@
#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)
{
Index: apps/settings.h
===================================================================
--- apps/settings.h (revision 13605)
+++ apps/settings.h (working copy)
@@ -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 @@
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 @@
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 @@
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
@@ -737,8 +737,6 @@
/** global variables **/
extern long lasttime;
-/* Recording base directory */
-extern const char rec_base_directory[];
/* global settings */
extern struct user_settings global_settings;
/* global status */
Index: apps/menus/recording_menu.c
===================================================================
--- apps/menus/recording_menu.c (revision 13605)
+++ apps/menus/recording_menu.c (working copy)
@@ -21,6 +21,7 @@
#include
#include
#include
+#include "string.h"
#include "system.h"
#include "kernel.h"
#include "lcd.h"
@@ -313,19 +314,16 @@
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 @@
#endif
&filesplitoptionsmenu,
&rec_prerecord_time,
- &recdirectory,
+ &clear_rec_directory_item,
#ifdef HAVE_BACKLIGHT
&cliplight,
#endif
Index: apps/settings_list.c
===================================================================
--- apps/settings_list.c (revision 13605)
+++ apps/settings_list.c (working copy)
@@ -773,11 +773,12 @@
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,
Index: apps/plugin.h
===================================================================
--- apps/plugin.h (revision 13605)
+++ apps/plugin.h (working copy)
@@ -114,12 +114,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 57
+#define PLUGIN_API_VERSION 58
/* 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 56
+#define PLUGIN_MIN_API_VERSION 58
/* plugin return codes */
enum plugin_status {