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
This commit is contained in:
Jonathan Gordon 2007-07-10 07:41:37 +00:00
parent 1c2de0a45e
commit 415e9d78cc
8 changed files with 112 additions and 59 deletions

View file

@ -11006,3 +11006,45 @@
*: "Use File .talk Clips" *: "Use File .talk Clips"
</voice> </voice>
</phrase> </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>

View file

@ -21,6 +21,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include "string.h"
#include "system.h" #include "system.h"
#include "kernel.h" #include "kernel.h"
#include "lcd.h" #include "lcd.h"
@ -313,18 +314,15 @@ MAKE_MENU(filesplitoptionsmenu, ID2P(LANG_RECORD_TIMESPLIT), NULL, Icon_NOICON,
MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL); 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[] = { strcpy(global_settings.rec_directory, REC_BASE_DIR);
{ rec_base_directory, -1 }, gui_syncsplash(HZ, str(LANG_RESET_DONE_CLEAR));
{ STR(LANG_RECORD_CURRENT_DIR) } return false;
};
return set_option(str(LANG_RECORD_DIRECTORY),
&global_settings.rec_directory, INT,
names, 2, NULL );
} }
MENUITEM_FUNCTION(recdirectory, 0, ID2P(LANG_RECORD_DIRECTORY), MENUITEM_FUNCTION(clear_rec_directory_item, 0, ID2P(LANG_CLEAR_REC_DIR),
recdirectory_func, NULL, NULL, Icon_Menu_setting); clear_rec_directory, NULL, NULL, Icon_Folder);
MENUITEM_SETTING(cliplight, &global_settings.cliplight, NULL); MENUITEM_SETTING(cliplight, &global_settings.cliplight, NULL);
@ -835,7 +833,7 @@ MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS),
#endif #endif
&filesplitoptionsmenu, &filesplitoptionsmenu,
&rec_prerecord_time, &rec_prerecord_time,
&recdirectory, &clear_rec_directory_item,
#ifdef HAVE_BACKLIGHT #ifdef HAVE_BACKLIGHT
&cliplight, &cliplight,
#endif #endif

View file

@ -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), MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP),
set_backdrop, NULL, clipboard_callback, Icon_NOICON); set_backdrop, NULL, clipboard_callback, Icon_NOICON);
#endif #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) if ((this_item == &delete_dir_item)
) )
return action; return action;
#ifdef HAVE_RECORDING
else if (this_item == &set_recdir_item)
return action;
#endif
} }
else if (selected_file else if (selected_file
#ifdef HAVE_MULTIVOLUME #ifdef HAVE_MULTIVOLUME
@ -1135,7 +1149,10 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
&set_backdrop_item, &set_backdrop_item,
#endif #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) int onplay(char* file, int attr, int from)
{ {

View file

@ -115,12 +115,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* 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 /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ 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 */ /* plugin return codes */
enum plugin_status { enum plugin_status {

View file

@ -508,14 +508,26 @@ static void adjust_cursor(void)
cursor = max_cursor; 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 *rec_create_filename(char *buffer)
{ {
char ext[16]; char ext[16];
strcpy(buffer,global_settings.rec_directory);
if(global_settings.rec_directory) if (!check_dir(buffer))
getcwd(buffer, MAX_PATH); return NULL;
else
strncpy(buffer, rec_base_directory, MAX_PATH);
snprintf(ext, sizeof(ext), ".%s", snprintf(ext, sizeof(ext), ".%s",
REC_FILE_ENDING(global_settings.rec_format)); REC_FILE_ENDING(global_settings.rec_format));
@ -542,28 +554,7 @@ void rec_init_filename(void)
int rec_create_directory(void) int rec_create_directory(void)
{ {
int rc; return check_dir(global_settings.rec_directory)?1:0;
/* 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;
} }
void rec_init_recording_options(struct audio_recording_options *options) void rec_init_recording_options(struct audio_recording_options *options)
@ -747,6 +738,15 @@ bool recording_screen(bool no_source)
}; };
struct audio_recording_options rec_options; 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; rec_status = RCSTAT_IN_RECSCREEN;
cursor = 0; cursor = 0;

View file

@ -77,9 +77,6 @@ void dac_line_in(bool enable);
struct user_settings global_settings; struct user_settings global_settings;
struct system_status global_status; struct system_status global_status;
#ifdef HAVE_RECORDING
const char rec_base_directory[] = REC_BASE_DIR;
#endif
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
#include "pcmbuf.h" #include "pcmbuf.h"
#include "pcm_playback.h" #include "pcm_playback.h"

View file

@ -59,7 +59,7 @@
#define PLUGIN_DIR ROCKBOX_DIR "/rocks" #define PLUGIN_DIR ROCKBOX_DIR "/rocks"
#define VIEWERS_DIR ROCKBOX_DIR "/viewers" #define VIEWERS_DIR ROCKBOX_DIR "/viewers"
#define BACKDROP_DIR ROCKBOX_DIR "/backdrops" #define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
#define REC_BASE_DIR "/recordings" #define REC_BASE_DIR "/"
#define EQS_DIR ROCKBOX_DIR "/eqs" #define EQS_DIR ROCKBOX_DIR "/eqs"
#define CODECS_DIR ROCKBOX_DIR "/codecs" #define CODECS_DIR ROCKBOX_DIR "/codecs"
#define RECPRESETS_DIR ROCKBOX_DIR "/recpresets" #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_duration; /* Fade out duration (0-15s) */
int crossfade_fade_out_mixmode; /* Fade out mode (0=crossfade,1=mix) */ int crossfade_fade_out_mixmode; /* Fade out mode (0=crossfade,1=mix) */
#endif #endif
#ifdef HAVE_RECORDING
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
int rec_format; /* record format index */ int rec_format; /* record format index */
#else #else
@ -370,7 +370,7 @@ struct user_settings
int rec_split_method; /* time/filesize */ int rec_split_method; /* time/filesize */
int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */ 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 int cliplight; /* 0 = off
1 = main lcd 1 = main lcd
2 = main and remote 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_maxgain_line; /* AGC maximum line-in gain */
int rec_agc_cliptime; /* 0.2, 0.4, 0.6, 0.8, 1s */ int rec_agc_cliptime; /* 0.2, 0.4, 0.6, 0.8, 1s */
#endif #endif
#endif /* HAVE_RECORDING */
/* device settings */ /* device settings */
#ifdef HAVE_LCD_CONTRAST #ifdef HAVE_LCD_CONTRAST
@ -740,8 +740,6 @@ struct user_settings
/** global variables **/ /** global variables **/
extern long lasttime; extern long lasttime;
/* Recording base directory */
extern const char rec_base_directory[];
/* global settings */ /* global settings */
extern struct user_settings global_settings; extern struct user_settings global_settings;
/* global status */ /* global status */

View file

@ -773,11 +773,12 @@ const struct settings_list settings[] = {
HAVE_SPDIF_REC_(",spdif") HAVE_SPDIF_REC_(",spdif")
HAVE_FMRADIO_REC_(",fmradio")[1] HAVE_FMRADIO_REC_(",fmradio")[1]
,UNUSED}, ,UNUSED},
INT_SETTING(F_RECSETTING, rec_prerecord_time, LANG_RECORD_PRERECORD_TIME, INT_SETTING(F_RECSETTING, rec_prerecord_time, LANG_RECORD_PRERECORD_TIME,
0, "prerecording time", 0, "prerecording time",
UNIT_SEC, 0, 30, 1, rectime_formatter, rectime_getlang, NULL), 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}, FILENAME_SETTING(F_RECSETTING, rec_directory, "rec path",
REC_BASE_DIR, NULL, NULL, MAX_FILENAME+1),
#ifdef HAVE_BACKLIGHT #ifdef HAVE_BACKLIGHT
CHOICE_SETTING(F_RECSETTING, cliplight, LANG_CLIP_LIGHT, 0 , CHOICE_SETTING(F_RECSETTING, cliplight, LANG_CLIP_LIGHT, 0 ,
"cliplight", "off,main,both,remote", NULL, "cliplight", "off,main,both,remote", NULL,