]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: add 'use only RAM' option
authorJaroslav Kysela <perex@perex.cz>
Mon, 19 Jan 2015 20:19:17 +0000 (21:19 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 19 Jan 2015 20:31:18 +0000 (21:31 +0100)
src/timeshift.c
src/timeshift.h
src/timeshift/timeshift_filemgr.c
src/webui/extjs.c
src/webui/static/app/timeshift.js

index 70de729e3ef1863bbcbf47975a7c15be43e6b026..b4acf3a1adfcc77147a7512c4605db4154d3a83e 100644 (file)
@@ -43,6 +43,16 @@ int       timeshift_unlimited_size;
 uint64_t  timeshift_max_size;
 uint64_t  timeshift_ram_size;
 uint64_t  timeshift_ram_segment_size;
+int       timeshift_ram_only;
+
+/*
+ * Safe values for RAM configuration
+ */
+static void timeshift_fixup ( void )
+{
+  if (timeshift_ram_only)
+    timeshift_max_size = timeshift_ram_size;
+}
 
 /*
  * Intialise global file manager
@@ -85,7 +95,10 @@ void timeshift_init ( void )
       timeshift_ram_size = 1048576LL * u32;
       timeshift_ram_segment_size = timeshift_ram_size / 10;
     }
+    if (!htsmsg_get_u32(m, "ram_only", &u32))
+      timeshift_ram_only = u32 ? 1 : 0;
     htsmsg_destroy(m);
+    timeshift_fixup();
   }
 }
 
@@ -106,6 +119,8 @@ void timeshift_save ( void )
 {
   htsmsg_t *m;
 
+  timeshift_fixup();
+
   m = htsmsg_create_map();
   htsmsg_add_u32(m, "enabled", timeshift_enabled);
   htsmsg_add_u32(m, "ondemand", timeshift_ondemand);
@@ -116,6 +131,7 @@ void timeshift_save ( void )
   htsmsg_add_u32(m, "unlimited_size", timeshift_unlimited_size);
   htsmsg_add_u32(m, "max_size", timeshift_max_size / 1048576);
   htsmsg_add_u32(m, "ram_size", timeshift_ram_size / 1048576);
+  htsmsg_add_u32(m, "ram_only", timeshift_ram_only);
 
   hts_settings_save(m, "timeshift/config");
 }
index 908fceaee19d1e7f5a4e007dfc78b544a5d18cd4..f8f98d5ca9c1fd83af315cb835b49cdad0e043db 100644 (file)
@@ -30,6 +30,7 @@ extern uint64_t  timeshift_total_size;
 extern uint64_t  timeshift_ram_size;
 extern uint64_t  timeshift_ram_segment_size;
 extern uint64_t  timeshift_total_ram_size;
+extern int       timeshift_ram_only;
 
 typedef struct timeshift_status
 {
index 33cf39b63c50030056ce413a138f929b1df31991..46d83d5cb365cda887e6d46d09af1343a426b4eb 100644 (file)
@@ -302,7 +302,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create )
         }
       }
       
-      if (!tsf_tmp) {
+      if (!tsf_tmp && !timeshift_ram_only) {
         /* Create directories */
         if (!ts->path) {
           if (timeshift_filemgr_makedirs(ts->id, path, sizeof(path)))
index 0053eaaeeb215fac0adeeb50d00a8bf49669a2c1..736cd386a4eb34356eea3f9603137fa0b3a923ed 100755 (executable)
@@ -678,6 +678,7 @@ extjs_timeshift(http_connection_t *hc, const char *remain, void *opaque)
     htsmsg_add_u32(m, "timeshift_unlimited_size", timeshift_unlimited_size);
     htsmsg_add_u32(m, "timeshift_max_size", timeshift_max_size / 1048576);
     htsmsg_add_u32(m, "timeshift_ram_size", timeshift_ram_size / 1048576);
+    htsmsg_add_u32(m, "timeshift_ram_only", timeshift_ram_only);
     pthread_mutex_unlock(&global_lock);
     out = json_single_record(m, "config");
 
@@ -701,6 +702,7 @@ extjs_timeshift(http_connection_t *hc, const char *remain, void *opaque)
       timeshift_ram_size         = atol(str) * 1048576LL;
       timeshift_ram_segment_size = timeshift_ram_size / 10;
     }
+    timeshift_ram_only = http_arg_get(&hc->hc_req_args, "timeshift_ram_only") ? 1 : 0;
     timeshift_save();
     pthread_mutex_unlock(&global_lock);
 
index ee7ada92ea551441e96599f03ee0f1c608cd9bd1..fd821ee324c43b70cf266eb02dbace409d3c98d1 100644 (file)
@@ -5,17 +5,17 @@ tvheadend.timeshift = function(panel, index) {
      * ***************************************************************/
 
     var confreader = new Ext.data.JsonReader(
-            {
+        {
                 root: 'config'
-            },
-    [
-        'timeshift_enabled', 'timeshift_ondemand',
-        'timeshift_path',
-        'timeshift_unlimited_period', 'timeshift_max_period',
-        'timeshift_unlimited_size', 'timeshift_max_size',
-        'timeshift_ram_size'
-    ]
-            );
+        },
+        [
+            'timeshift_enabled', 'timeshift_ondemand',
+            'timeshift_path',
+            'timeshift_unlimited_period', 'timeshift_max_period',
+            'timeshift_unlimited_size', 'timeshift_max_size',
+            'timeshift_ram_size', 'timeshift_ram_only'
+        ]
+    );
 
     /* ****************************************************************
      * Fields
@@ -64,7 +64,7 @@ tvheadend.timeshift = function(panel, index) {
         fieldLabel: 'Max. RAM Size (MB)',
         name: 'timeshift_ram_size',
         allowBlank: false,
-        width: 300
+        width: 250
     });
 
     var timeshiftUnlSize = new Ext.form.Checkbox({
@@ -73,6 +73,12 @@ tvheadend.timeshift = function(panel, index) {
         width: 300
     });
 
+    var timeshiftRamOnly = new Ext.form.Checkbox({
+        fieldLabel: 'Use only RAM',
+        name: 'timeshift_ram_only',
+        width: 300
+    });
+
     /* ****************************************************************
      * Events
      * ***************************************************************/
@@ -82,7 +88,11 @@ tvheadend.timeshift = function(panel, index) {
     });
 
     timeshiftUnlSize.on('check', function(e, c){
-        timeshiftMaxSize.setDisabled(c);
+        timeshiftMaxSize.setDisabled(c || timeshiftMaxSize.getValue());
+    });
+
+    timeshiftRamOnly.on('check', function(e, c){
+        timeshiftMaxSize.setDisabled(c || timeshiftUnlSize.getValue());
     });
 
     /* ****************************************************************
@@ -108,14 +118,14 @@ tvheadend.timeshift = function(panel, index) {
         width: 500,
         autoHeight: true,
         border: false,
-           items : [timeshiftMaxPeriod, timeshiftMaxSize, timeshiftRamSize]
+        items : [timeshiftMaxPeriod, timeshiftMaxSize, timeshiftRamSize]
     });
 
     var timeshiftPanelB = new Ext.form.FieldSet({
         width: 200,
         autoHeight: true,
         border: false,
-        items : [timeshiftUnlPeriod,timeshiftUnlSize]
+        items : [timeshiftUnlPeriod, timeshiftUnlSize, timeshiftRamOnly]
     });
 
     var timeshiftPanel = new Ext.form.FieldSet({
@@ -166,7 +176,7 @@ tvheadend.timeshift = function(panel, index) {
             success: function() {
                 confpanel.enable();
                 timeshiftMaxPeriod.setDisabled(timeshiftUnlPeriod.getValue());
-                timeshiftMaxSize.setDisabled(timeshiftUnlSize.getValue());
+                timeshiftMaxSize.setDisabled(timeshiftUnlSize.getValue() || timeshiftRamOnly.getValue());
             }
         });
     });