summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/lang/english.lang42
-rw-r--r--apps/menus/recording_menu.c22
-rw-r--r--apps/onplay.c19
-rw-r--r--apps/plugin.h4
-rw-r--r--apps/recorder/recording.c58
-rw-r--r--apps/settings.c3
-rw-r--r--apps/settings.h10
-rw-r--r--apps/settings_list.c11
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 @@
11006 *: "Use File .talk Clips" 11006 *: "Use File .talk Clips"
11007 </voice> 11007 </voice>
11008</phrase> 11008</phrase>
11009<phrase>
11010 id: LANG_SET_AS_REC_DIR
11011 desc:
11012 user:
11013 <source>
11014 *: "Set As Recording Directory"
11015 </source>
11016 <dest>
11017 *: "Set As Recording Directory"
11018 </dest>
11019 <voice>
11020 *: "Set As Recording Directory"
11021 </voice>
11022</phrase>
11023<phrase>
11024 id: LANG_CLEAR_REC_DIR
11025 desc:
11026 user:
11027 <source>
11028 *: "Clear Recording Directory"
11029 </source>
11030 <dest>
11031 *: "Clear Recording Directory"
11032 </dest>
11033 <voice>
11034 *: "Clear Recording Directory"
11035 </voice>
11036</phrase>
11037<phrase>
11038 id: LANG_REC_DIR_NOT_WRITABLE
11039 desc:
11040 user:
11041 <source>
11042 *: "Can't write to recording directory"
11043 </source>
11044 <dest>
11045 *: "Can't write to recording directory"
11046 </dest>
11047 <voice>
11048 *: "Can't write to recording directory"
11049 </voice>
11050</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 @@
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include <stdbool.h> 23#include <stdbool.h>
24#include "string.h"
24#include "system.h" 25#include "system.h"
25#include "kernel.h" 26#include "kernel.h"
26#include "lcd.h" 27#include "lcd.h"
@@ -313,19 +314,16 @@ MAKE_MENU(filesplitoptionsmenu, ID2P(LANG_RECORD_TIMESPLIT), NULL, Icon_NOICON,
313 314
314 315
315MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL); 316MENUITEM_SETTING(rec_prerecord_time, &global_settings.rec_prerecord_time, NULL);
316static int recdirectory_func(void) 317
318static int clear_rec_directory(void)
317{ 319{
318 static const struct opt_items names[] = { 320 strcpy(global_settings.rec_directory, REC_BASE_DIR);
319 { rec_base_directory, -1 }, 321 gui_syncsplash(HZ, str(LANG_RESET_DONE_CLEAR));
320 { STR(LANG_RECORD_CURRENT_DIR) } 322 return false;
321 };
322 return set_option(str(LANG_RECORD_DIRECTORY),
323 &global_settings.rec_directory, INT,
324 names, 2, NULL );
325} 323}
326MENUITEM_FUNCTION(recdirectory, 0, ID2P(LANG_RECORD_DIRECTORY), 324MENUITEM_FUNCTION(clear_rec_directory_item, 0, ID2P(LANG_CLEAR_REC_DIR),
327 recdirectory_func, NULL, NULL, Icon_Menu_setting); 325 clear_rec_directory, NULL, NULL, Icon_Folder);
328 326
329MENUITEM_SETTING(cliplight, &global_settings.cliplight, NULL); 327MENUITEM_SETTING(cliplight, &global_settings.cliplight, NULL);
330 328
331#ifdef HAVE_AGC 329#ifdef HAVE_AGC
@@ -835,7 +833,7 @@ MAKE_MENU(recording_settings_menu, ID2P(LANG_RECORDING_SETTINGS),
835#endif 833#endif
836 &filesplitoptionsmenu, 834 &filesplitoptionsmenu,
837 &rec_prerecord_time, 835 &rec_prerecord_time,
838 &recdirectory, 836 &clear_rec_directory_item,
839#ifdef HAVE_BACKLIGHT 837#ifdef HAVE_BACKLIGHT
840 &cliplight, 838 &cliplight,
841#endif 839#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),
1043MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP), 1043MENUITEM_FUNCTION(set_backdrop_item, 0, ID2P(LANG_SET_AS_BACKDROP),
1044 set_backdrop, NULL, clipboard_callback, Icon_NOICON); 1044 set_backdrop, NULL, clipboard_callback, Icon_NOICON);
1045#endif 1045#endif
1046#ifdef HAVE_RECORDING
1047static bool set_recdir(void)
1048{
1049 strncpy(global_settings.rec_directory,
1050 selected_file, MAX_FILENAME+1);
1051 return false;
1052}
1053MENUITEM_FUNCTION(set_recdir_item, 0, ID2P(LANG_SET_AS_REC_DIR),
1054 set_recdir, NULL, clipboard_callback, Icon_Recording);
1055#endif
1046 1056
1047 1057
1048 1058
@@ -1090,6 +1100,10 @@ static int clipboard_callback(int action,const struct menu_item_ex *this_item)
1090 if ((this_item == &delete_dir_item) 1100 if ((this_item == &delete_dir_item)
1091 ) 1101 )
1092 return action; 1102 return action;
1103#ifdef HAVE_RECORDING
1104 else if (this_item == &set_recdir_item)
1105 return action;
1106#endif
1093 } 1107 }
1094 else if (selected_file 1108 else if (selected_file
1095#ifdef HAVE_MULTIVOLUME 1109#ifdef HAVE_MULTIVOLUME
@@ -1135,7 +1149,10 @@ MAKE_ONPLAYMENU( tree_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
1135#if LCD_DEPTH > 1 1149#if LCD_DEPTH > 1
1136 &set_backdrop_item, 1150 &set_backdrop_item,
1137#endif 1151#endif
1138 &list_viewers_item, &create_dir_item, &properties_item 1152 &list_viewers_item, &create_dir_item, &properties_item,
1153#ifdef HAVE_RECORDING
1154 &set_recdir_item,
1155#endif
1139 ); 1156 );
1140int onplay(char* file, int attr, int from) 1157int onplay(char* file, int attr, int from)
1141{ 1158{
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 @@
115#define PLUGIN_MAGIC 0x526F634B /* RocK */ 115#define PLUGIN_MAGIC 0x526F634B /* RocK */
116 116
117/* increase this every time the api struct changes */ 117/* increase this every time the api struct changes */
118#define PLUGIN_API_VERSION 60 118#define PLUGIN_API_VERSION 61
119 119
120/* update this to latest version if a change to the api struct breaks 120/* update this to latest version if a change to the api struct breaks
121 backwards compatibility (and please take the opportunity to sort in any 121 backwards compatibility (and please take the opportunity to sort in any
122 new function which are "waiting" at the end of the function table) */ 122 new function which are "waiting" at the end of the function table) */
123#define PLUGIN_MIN_API_VERSION 60 123#define PLUGIN_MIN_API_VERSION 61
124 124
125/* plugin return codes */ 125/* plugin return codes */
126enum plugin_status { 126enum 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)
508 cursor = max_cursor; 508 cursor = max_cursor;
509} 509}
510 510
511static bool check_dir(char *folder)
512{
513 DIR *dir = opendir(folder);
514 if (!dir && strcmp(folder, "/"))
515 {
516 int rc = mkdir(folder);
517 if(rc < 0)
518 return false;
519 return true;
520 }
521 closedir(dir);
522 return true;
523}
524
511char *rec_create_filename(char *buffer) 525char *rec_create_filename(char *buffer)
512{ 526{
513 char ext[16]; 527 char ext[16];
514 528 strcpy(buffer,global_settings.rec_directory);
515 if(global_settings.rec_directory) 529 if (!check_dir(buffer))
516 getcwd(buffer, MAX_PATH); 530 return NULL;
517 else 531
518 strncpy(buffer, rec_base_directory, MAX_PATH);
519
520 snprintf(ext, sizeof(ext), ".%s", 532 snprintf(ext, sizeof(ext), ".%s",
521 REC_FILE_ENDING(global_settings.rec_format)); 533 REC_FILE_ENDING(global_settings.rec_format));
522 534
@@ -542,28 +554,7 @@ void rec_init_filename(void)
542 554
543int rec_create_directory(void) 555int rec_create_directory(void)
544{ 556{
545 int rc; 557 return check_dir(global_settings.rec_directory)?1:0;
546
547 /* Try to create the base directory if needed */
548 if(global_settings.rec_directory == 0)
549 {
550 rc = mkdir(rec_base_directory);
551 if(rc < 0 && errno != EEXIST)
552 {
553 gui_syncsplash(HZ * 2,
554 "Can't create the %s directory. Error code %d.",
555 rec_base_directory, rc);
556 return -1;
557 }
558 else
559 {
560 /* If we have created the directory, we want the dir browser to
561 be refreshed even if we haven't recorded anything */
562 if(errno != EEXIST)
563 return 1;
564 }
565 }
566 return 0;
567} 558}
568 559
569void rec_init_recording_options(struct audio_recording_options *options) 560void rec_init_recording_options(struct audio_recording_options *options)
@@ -747,7 +738,16 @@ bool recording_screen(bool no_source)
747 }; 738 };
748 739
749 struct audio_recording_options rec_options; 740 struct audio_recording_options rec_options;
750 741 if (check_dir(global_settings.rec_directory) == false)
742 {
743 do {
744 gui_syncsplash(0, "%s %s",
745 str(LANG_REC_DIR_NOT_WRITABLE),
746 str(LANG_OFF_ABORT));
747 } while (action_userabort(HZ) == false);
748 return false;
749 }
750
751 rec_status = RCSTAT_IN_RECSCREEN; 751 rec_status = RCSTAT_IN_RECSCREEN;
752 cursor = 0; 752 cursor = 0;
753#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 753#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);
77struct user_settings global_settings; 77struct user_settings global_settings;
78struct system_status global_status; 78struct system_status global_status;
79 79
80#ifdef HAVE_RECORDING
81const char rec_base_directory[] = REC_BASE_DIR;
82#endif
83#if CONFIG_CODEC == SWCODEC 80#if CONFIG_CODEC == SWCODEC
84#include "pcmbuf.h" 81#include "pcmbuf.h"
85#include "pcm_playback.h" 82#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 @@
59#define PLUGIN_DIR ROCKBOX_DIR "/rocks" 59#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
60#define VIEWERS_DIR ROCKBOX_DIR "/viewers" 60#define VIEWERS_DIR ROCKBOX_DIR "/viewers"
61#define BACKDROP_DIR ROCKBOX_DIR "/backdrops" 61#define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
62#define REC_BASE_DIR "/recordings" 62#define REC_BASE_DIR "/"
63#define EQS_DIR ROCKBOX_DIR "/eqs" 63#define EQS_DIR ROCKBOX_DIR "/eqs"
64#define CODECS_DIR ROCKBOX_DIR "/codecs" 64#define CODECS_DIR ROCKBOX_DIR "/codecs"
65#define RECPRESETS_DIR ROCKBOX_DIR "/recpresets" 65#define RECPRESETS_DIR ROCKBOX_DIR "/recpresets"
@@ -336,7 +336,7 @@ struct user_settings
336 int crossfade_fade_out_duration; /* Fade out duration (0-15s) */ 336 int crossfade_fade_out_duration; /* Fade out duration (0-15s) */
337 int crossfade_fade_out_mixmode; /* Fade out mode (0=crossfade,1=mix) */ 337 int crossfade_fade_out_mixmode; /* Fade out mode (0=crossfade,1=mix) */
338#endif 338#endif
339 339#ifdef HAVE_RECORDING
340#if CONFIG_CODEC == SWCODEC 340#if CONFIG_CODEC == SWCODEC
341 int rec_format; /* record format index */ 341 int rec_format; /* record format index */
342#else 342#else
@@ -370,7 +370,7 @@ struct user_settings
370 int rec_split_method; /* time/filesize */ 370 int rec_split_method; /* time/filesize */
371 371
372 int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */ 372 int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */
373 int rec_directory; /* 0=base dir, 1=current dir */ 373 char rec_directory[MAX_FILENAME+1];
374 int cliplight; /* 0 = off 374 int cliplight; /* 0 = off
375 1 = main lcd 375 1 = main lcd
376 2 = main and remote lcd 376 2 = main and remote lcd
@@ -403,7 +403,7 @@ struct user_settings
403 int rec_agc_maxgain_line; /* AGC maximum line-in gain */ 403 int rec_agc_maxgain_line; /* AGC maximum line-in gain */
404 int rec_agc_cliptime; /* 0.2, 0.4, 0.6, 0.8, 1s */ 404 int rec_agc_cliptime; /* 0.2, 0.4, 0.6, 0.8, 1s */
405#endif 405#endif
406 406#endif /* HAVE_RECORDING */
407 /* device settings */ 407 /* device settings */
408 408
409#ifdef HAVE_LCD_CONTRAST 409#ifdef HAVE_LCD_CONTRAST
@@ -740,8 +740,6 @@ struct user_settings
740 740
741/** global variables **/ 741/** global variables **/
742extern long lasttime; 742extern long lasttime;
743/* Recording base directory */
744extern const char rec_base_directory[];
745/* global settings */ 743/* global settings */
746extern struct user_settings global_settings; 744extern struct user_settings global_settings;
747/* global status */ 745/* 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[] = {
773 HAVE_SPDIF_REC_(",spdif") 773 HAVE_SPDIF_REC_(",spdif")
774 HAVE_FMRADIO_REC_(",fmradio")[1] 774 HAVE_FMRADIO_REC_(",fmradio")[1]
775 ,UNUSED}, 775 ,UNUSED},
776 INT_SETTING(F_RECSETTING, rec_prerecord_time, LANG_RECORD_PRERECORD_TIME, 776 INT_SETTING(F_RECSETTING, rec_prerecord_time, LANG_RECORD_PRERECORD_TIME,
777 0, "prerecording time", 777 0, "prerecording time",
778 UNIT_SEC, 0, 30, 1, rectime_formatter, rectime_getlang, NULL), 778 UNIT_SEC, 0, 30, 1, rectime_formatter, rectime_getlang, NULL),
779 {F_T_INT|F_RECSETTING,&global_settings.rec_directory,LANG_RECORD_DIRECTORY, 779
780 INT(0),"rec directory",REC_BASE_DIR ",current",UNUSED}, 780 FILENAME_SETTING(F_RECSETTING, rec_directory, "rec path",
781 REC_BASE_DIR, NULL, NULL, MAX_FILENAME+1),
781#ifdef HAVE_BACKLIGHT 782#ifdef HAVE_BACKLIGHT
782 CHOICE_SETTING(F_RECSETTING, cliplight, LANG_CLIP_LIGHT, 0 , 783 CHOICE_SETTING(F_RECSETTING, cliplight, LANG_CLIP_LIGHT, 0 ,
783 "cliplight", "off,main,both,remote", NULL, 784 "cliplight", "off,main,both,remote", NULL,