New feature: NOw you can store the recorded files in either /recordings (the directory will be created automatically) or in the current directory.
New feature: A "Create directory" menu option (untested in the simulator). Bug fix: The ON+Play menu could do nasty things if you pressed ON+Play in an empty dir. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4268 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
33acdef9db
commit
ef7293f0bc
|
@ -2030,3 +2030,18 @@ id: LANG_MANAGE_MENU
|
|||
desc: in the system sub menu
|
||||
eng: "Manage Settings"
|
||||
new:
|
||||
|
||||
id: LANG_RECORD_DIRECTORY
|
||||
desc: in recording settings_menu
|
||||
eng: "Directory"
|
||||
new:
|
||||
|
||||
id: LANG_RECORD_CURRENT_DIR
|
||||
desc: in recording directory options
|
||||
eng: "Current dir"
|
||||
new:
|
||||
|
||||
id: LANG_CREATE_DIR
|
||||
desc: in main menu
|
||||
eng: "Create directory"
|
||||
new:
|
||||
|
|
|
@ -304,7 +304,7 @@ bool main_menu(void)
|
|||
int i = 0;
|
||||
|
||||
/* main menu */
|
||||
struct menu_items items[8];
|
||||
struct menu_items items[9];
|
||||
|
||||
items[i].desc = str(LANG_BOOKMARK_MENU);
|
||||
items[i++].function = bookmark_menu;
|
||||
|
@ -336,6 +336,9 @@ bool main_menu(void)
|
|||
items[i].desc = str(LANG_INFO);
|
||||
items[i++].function = info_menu;
|
||||
|
||||
items[i].desc = str(LANG_CREATE_DIR);
|
||||
items[i++].function = create_dir;
|
||||
|
||||
m=menu_init( items, i );
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
status_set_param(true);
|
||||
|
|
|
@ -117,7 +117,7 @@ static int find_preset(int freq)
|
|||
|
||||
bool radio_screen(void)
|
||||
{
|
||||
char buf[128];
|
||||
char buf[MAX_PATH];
|
||||
bool done = false;
|
||||
int button;
|
||||
int val;
|
||||
|
@ -248,13 +248,13 @@ bool radio_screen(void)
|
|||
case BUTTON_F3:
|
||||
if(mpeg_status() == MPEG_STATUS_RECORD)
|
||||
{
|
||||
mpeg_new_file(rec_create_filename());
|
||||
mpeg_new_file(rec_create_filename(buf));
|
||||
update_screen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
have_recorded = true;
|
||||
mpeg_record(rec_create_filename());
|
||||
mpeg_record(rec_create_filename(buf));
|
||||
status_set_playmode(STATUS_RECORD);
|
||||
update_screen = true;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
#include "timefuncs.h"
|
||||
#include "debug.h"
|
||||
#include "misc.h"
|
||||
#include "tree.h"
|
||||
#include "string.h"
|
||||
#include "dir.h"
|
||||
#include "errno.h"
|
||||
|
||||
bool f2_rec_screen(void);
|
||||
bool f3_rec_screen(void);
|
||||
|
@ -114,20 +118,22 @@ void adjust_cursor(void)
|
|||
}
|
||||
}
|
||||
|
||||
char *rec_create_filename(void)
|
||||
char *rec_create_filename(char *buffer)
|
||||
{
|
||||
static char fname[32];
|
||||
struct tm * tm;
|
||||
int fpos;
|
||||
struct tm *tm = get_time();
|
||||
|
||||
tm = get_time();
|
||||
if(global_settings.rec_directory)
|
||||
getcwd(buffer, MAX_PATH);
|
||||
else
|
||||
strncpy(buffer, rec_base_directory, MAX_PATH);
|
||||
|
||||
/* Create a filename: RYYMMDD-HHMMSS.mp3 */
|
||||
snprintf(fname, 32, "/R%02d%02d%02d-%02d%02d%02d.mp3",
|
||||
/* Append filename to path: RYYMMDD-HH.MM.SS.mp3 */
|
||||
fpos = strlen(buffer);
|
||||
snprintf(&buffer[fpos], MAX_PATH-fpos, "/R%02d%02d%02d-%02d%02d%02d.mp3",
|
||||
tm->tm_year%100, tm->tm_mon+1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
|
||||
DEBUGF("Filename: %s\n", fname);
|
||||
return fname;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool recording_screen(void)
|
||||
|
@ -144,6 +150,9 @@ bool recording_screen(void)
|
|||
unsigned int seconds;
|
||||
unsigned int last_seconds = 0;
|
||||
int hours, minutes;
|
||||
char path_buffer[MAX_PATH];
|
||||
int rc;
|
||||
bool been_in_usb_mode = false;
|
||||
|
||||
cursor = 0;
|
||||
mpeg_init_recording();
|
||||
|
@ -170,6 +179,25 @@ bool recording_screen(void)
|
|||
lcd_getstringsize("M", &w, &h);
|
||||
lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
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)
|
||||
have_recorded = true;
|
||||
}
|
||||
}
|
||||
|
||||
while(!done)
|
||||
{
|
||||
button = button_get_w_tmo(HZ / peak_meter_fps);
|
||||
|
@ -195,13 +223,13 @@ bool recording_screen(void)
|
|||
if(!(mpeg_status() & MPEG_STATUS_RECORD))
|
||||
{
|
||||
have_recorded = true;
|
||||
mpeg_record(rec_create_filename());
|
||||
mpeg_record(rec_create_filename(path_buffer));
|
||||
status_set_playmode(STATUS_RECORD);
|
||||
update_countdown = 1; /* Update immediately */
|
||||
}
|
||||
else
|
||||
{
|
||||
mpeg_new_file(rec_create_filename());
|
||||
mpeg_new_file(rec_create_filename(path_buffer));
|
||||
update_countdown = 1; /* Update immediately */
|
||||
}
|
||||
last_seconds = 0;
|
||||
|
@ -354,8 +382,8 @@ bool recording_screen(void)
|
|||
if(mpeg_status() != MPEG_STATUS_RECORD)
|
||||
{
|
||||
usb_screen();
|
||||
have_recorded = true; /* Refreshes the browser later on */
|
||||
done = true;
|
||||
been_in_usb_mode = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -419,7 +447,7 @@ bool recording_screen(void)
|
|||
that the recorded files don't get too big. */
|
||||
if (mpeg_status() && (seconds >= dseconds))
|
||||
{
|
||||
mpeg_new_file(rec_create_filename());
|
||||
mpeg_new_file(rec_create_filename(path_buffer));
|
||||
update_countdown = 1;
|
||||
last_seconds = 0;
|
||||
}
|
||||
|
@ -529,7 +557,11 @@ bool recording_screen(void)
|
|||
mpeg_sound_set(SOUND_AVC, global_settings.avc);
|
||||
|
||||
lcd_setfont(FONT_UI);
|
||||
return have_recorded;
|
||||
|
||||
if (have_recorded)
|
||||
reload_directory();
|
||||
|
||||
return been_in_usb_mode;
|
||||
}
|
||||
|
||||
bool f2_rec_screen(void)
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
#define RECORDING_H
|
||||
|
||||
bool recording_screen(void);
|
||||
char *rec_create_filename(void);
|
||||
char *rec_create_filename(char *buf);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -65,8 +65,10 @@ void dac_line_in(bool enable);
|
|||
#endif
|
||||
struct user_settings global_settings;
|
||||
char rockboxdir[] = ROCKBOX_DIR; /* config/font/data file directory */
|
||||
char rec_base_directory[] = REC_BASE_DIR;
|
||||
|
||||
#define CONFIG_BLOCK_VERSION 8
|
||||
|
||||
#define CONFIG_BLOCK_VERSION 9
|
||||
#define CONFIG_BLOCK_SIZE 512
|
||||
#define RTC_BLOCK_SIZE 44
|
||||
|
||||
|
@ -156,7 +158,7 @@ Rest of config block, only saved to disk:
|
|||
0xB8 (char[20]) WPS file
|
||||
0xCC (char[20]) Lang file
|
||||
0xE0 (char[20]) Font file
|
||||
0xF4 Prerecording time (bit 0-4)
|
||||
0xF4 Prerecording time (bit 0-4), Recording directory option (bit 5-6)
|
||||
0xF5-0xFF <unused>
|
||||
|
||||
*************************************/
|
||||
|
@ -439,7 +441,8 @@ int settings_save( void )
|
|||
strncpy(&config_block[0xcc], global_settings.lang_file, MAX_FILENAME);
|
||||
strncpy(&config_block[0xe0], global_settings.font_file, MAX_FILENAME);
|
||||
|
||||
config_block[0xf4]=(unsigned char)global_settings.rec_prerecord_time;
|
||||
config_block[0xf4]=((unsigned char)global_settings.rec_prerecord_time |
|
||||
((unsigned char)global_settings.rec_directory << 5));
|
||||
|
||||
if(save_config_buffer())
|
||||
{
|
||||
|
@ -681,7 +684,7 @@ void settings_load(void)
|
|||
}
|
||||
|
||||
if (config_block[0x1d] != 0xFF)
|
||||
memcpy(&global_settings.resume_seed,&config_block[0x1d], 4);
|
||||
memcpy(&global_settings.resume_seed, &config_block[0x1d], 4);
|
||||
|
||||
if (config_block[0x21] != 0xFF)
|
||||
{
|
||||
|
@ -766,8 +769,10 @@ void settings_load(void)
|
|||
strncpy(global_settings.lang_file, &config_block[0xcc], MAX_FILENAME);
|
||||
strncpy(global_settings.font_file, &config_block[0xe0], MAX_FILENAME);
|
||||
|
||||
if (config_block[0xf4] != 0xff)
|
||||
global_settings.rec_prerecord_time = config_block[0xf4];
|
||||
if (config_block[0xf4] != 0xff) {
|
||||
global_settings.rec_prerecord_time = config_block[0xf4] & 0x1f;
|
||||
global_settings.rec_directory = (config_block[0xf4] >> 5) & 3;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
if (config_block[0xa8] != 0xff)
|
||||
|
@ -1101,6 +1106,10 @@ bool settings_load_config(char* file)
|
|||
else if (!strcasecmp(name, "prerecording time")) {
|
||||
set_cfg_int(&global_settings.rec_prerecord_time, value, 0, 30);
|
||||
}
|
||||
else if (!strcasecmp(name, "rec directory")) {
|
||||
static char* options[] = {rec_base_directory, "current"};
|
||||
set_cfg_option(&global_settings.rec_directory, value, options, 2);
|
||||
}
|
||||
#endif
|
||||
else if (!strcasecmp(name, "idle poweroff")) {
|
||||
static char* options[] = {"off","1","2","3","4","5","6","7","8",
|
||||
|
@ -1454,6 +1463,12 @@ bool settings_save_config(void)
|
|||
fprintf(fd, "prerecording time: %d\r\n",
|
||||
global_settings.rec_prerecord_time);
|
||||
|
||||
{
|
||||
static char* options[] = {rec_base_directory, "current"};
|
||||
fprintf(fd, "rec directory: %s\r\n",
|
||||
options[global_settings.rec_directory]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
fprintf(fd, "#\r\n# Bookmarking\r\n#\r\n");
|
||||
|
@ -1513,6 +1528,7 @@ void settings_reset(void) {
|
|||
global_settings.rec_right_gain = 2; /* 0dB */
|
||||
global_settings.rec_editable = false;
|
||||
global_settings.rec_prerecord_time = 0;
|
||||
global_settings.rec_directory = 0; /* rec_base_directory */
|
||||
global_settings.resume = RESUME_ASK;
|
||||
global_settings.contrast = lcd_default_contrast();
|
||||
global_settings.invert = DEFAULT_INVERT_SETTING;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define FONT_DIR "/fonts"
|
||||
#define LANG_DIR "/langs"
|
||||
#define PLUGIN_DIR ROCKBOX_DIR"/rocks"
|
||||
#define REC_BASE_DIR "/recordings"
|
||||
|
||||
#define MAX_FILENAME 20
|
||||
|
||||
|
@ -95,6 +96,7 @@ struct user_settings
|
|||
13= 24:00 */
|
||||
|
||||
int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */
|
||||
int rec_directory; /* 0=base dir, 1=current dir */
|
||||
|
||||
/* device settings */
|
||||
|
||||
|
@ -230,6 +232,9 @@ extern struct user_settings global_settings;
|
|||
extern char rockboxdir[];
|
||||
extern long lasttime;
|
||||
|
||||
/* Recording base directory */
|
||||
extern char rec_base_directory[];
|
||||
|
||||
/* system defines */
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
|
|
|
@ -255,6 +255,17 @@ static bool recprerecord(void)
|
|||
names, 31, NULL );
|
||||
}
|
||||
|
||||
static bool recdirectory(void)
|
||||
{
|
||||
char *names[] = {
|
||||
rec_base_directory, str(LANG_RECORD_CURRENT_DIR)
|
||||
};
|
||||
|
||||
return set_option(str(LANG_RECORD_DIRECTORY),
|
||||
&global_settings.rec_directory, INT,
|
||||
names, 2, NULL );
|
||||
}
|
||||
|
||||
#endif /* HAVE_MAS3587F */
|
||||
|
||||
static void set_chanconf(int val)
|
||||
|
@ -308,7 +319,7 @@ bool recording_menu(bool no_source)
|
|||
{
|
||||
int m;
|
||||
int i = 0;
|
||||
struct menu_items menu[7];
|
||||
struct menu_items menu[8];
|
||||
bool result;
|
||||
|
||||
menu[i].desc = str(LANG_RECORDING_QUALITY);
|
||||
|
@ -327,6 +338,8 @@ bool recording_menu(bool no_source)
|
|||
menu[i++].function = rectimesplit;
|
||||
menu[i].desc = str(LANG_RECORD_PRERECORD_TIME);
|
||||
menu[i++].function = recprerecord;
|
||||
menu[i].desc = str(LANG_RECORD_DIRECTORY);
|
||||
menu[i++].function = recdirectory;
|
||||
|
||||
m=menu_init( menu, i );
|
||||
result = menu_run(m);
|
||||
|
|
27
apps/tree.c
27
apps/tree.c
|
@ -772,6 +772,9 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
|
|||
{
|
||||
int onplay_result;
|
||||
|
||||
if(!numentries)
|
||||
break;
|
||||
|
||||
if (currdir[1])
|
||||
snprintf(buf, sizeof buf, "%s/%s",
|
||||
currdir, dircache[dircursor+dirstart].name);
|
||||
|
@ -1499,6 +1502,30 @@ bool create_playlist(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool create_dir(void)
|
||||
{
|
||||
char dirname[MAX_PATH];
|
||||
int rc;
|
||||
int pathlen;
|
||||
|
||||
memset(dirname, 0, sizeof dirname);
|
||||
|
||||
snprintf(dirname, sizeof dirname, "%s/",
|
||||
currdir[1] ? currdir : "");
|
||||
|
||||
pathlen = strlen(dirname);
|
||||
rc = kbd_input(dirname + pathlen, (sizeof dirname)-pathlen);
|
||||
if(rc < 0)
|
||||
return false;
|
||||
|
||||
rc = mkdir(dirname, 0);
|
||||
if(rc < 0) {
|
||||
splash(HZ, true, "%s %s", str(LANG_CREATE_DIR), str(LANG_FAILED));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rockbox_browse(char *root, int dirfilter)
|
||||
{
|
||||
bool rc;
|
||||
|
|
|
@ -47,6 +47,7 @@ void browse_root(void);
|
|||
void set_current_file(char *path);
|
||||
bool rockbox_browse(char *root, int dirfilter);
|
||||
bool create_playlist(void);
|
||||
bool create_dir(void);
|
||||
void resume_directory(char *dir);
|
||||
char *getcwd(char *buf, int size);
|
||||
void reload_directory(void);
|
||||
|
|
|
@ -115,7 +115,7 @@ struct dirent* readdir(DIR* dir)
|
|||
return theent;
|
||||
}
|
||||
|
||||
int mkdir(char *name)
|
||||
int mkdir(char *name, int mode)
|
||||
{
|
||||
DIR *dir;
|
||||
char namecopy[MAX_PATH];
|
||||
|
@ -125,6 +125,8 @@ int mkdir(char *name)
|
|||
struct dirent *entry;
|
||||
struct fat_dir newdir;
|
||||
int rc;
|
||||
|
||||
(void)mode;
|
||||
|
||||
if ( name[0] != '/' ) {
|
||||
DEBUGF("Only absolute paths supported right now\n");
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef struct DIRtag
|
|||
|
||||
extern DIR* opendir(char* name);
|
||||
extern int closedir(DIR* dir);
|
||||
extern int mkdir(char* name);
|
||||
extern int mkdir(char* name, int mode);
|
||||
|
||||
extern struct dirent* readdir(DIR* dir);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef __FILE_WIN32_H__
|
||||
#define __FILE_WIN32_H__
|
||||
|
||||
#define mkdir(x) dos_mkdir(x)
|
||||
#define mkdir(x, y) dos_mkdir(x)
|
||||
|
||||
#include <io.h>
|
||||
#include "../../firmware/include/dir.h"
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef void * MYDIR;
|
|||
extern MYDIR *x11_opendir(char *name);
|
||||
extern struct x11_dirent* x11_readdir(MYDIR* dir);
|
||||
extern int x11_closedir(MYDIR *dir);
|
||||
extern int x11_mkdir(char *name, int mode);
|
||||
|
||||
#ifndef NO_REDEFINES_PLEASE
|
||||
|
||||
|
@ -40,6 +41,7 @@ extern int x11_closedir(MYDIR *dir);
|
|||
#define opendir(x) x11_opendir(x)
|
||||
#define readdir(x) x11_readdir(x)
|
||||
#define closedir(x) x11_closedir(x)
|
||||
#define mkdir(x, y) x11_mkdir(x, y)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -133,6 +133,19 @@ int x11_creat(const char *name, mode_t mode)
|
|||
return (creat)(name, 0666);
|
||||
}
|
||||
|
||||
int x11_mkdir(const char *name, mode_t mode)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
(void)mode;
|
||||
if(name[0] == '/') {
|
||||
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
||||
|
||||
debugf("We create the real directory '%s'\n", buffer);
|
||||
return (mkdir)(buffer, 0666);
|
||||
}
|
||||
return (mkdir)(name, 0666);
|
||||
}
|
||||
|
||||
int x11_remove(char *name)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
|
|
Loading…
Reference in New Issue
Block a user