[mythtv-users] [PATCH] Both patches I sent before hopefully in the correct format now

Tako Schotanus quintesse at palacio-cristal.com
Sat Jun 28 01:59:08 EDT 2003


The mainserver patch fixes not being able to delete recorded programs if 
the .nuv file is missing
The other two add the possibility to start scheduled programs X seconds 
early.

Cheers,
 -Tako
-------------- next part --------------
--- scheduler.cpp.old	2003-06-28 00:45:12.000000000 +0200
+++ scheduler.cpp	2003-06-28 00:46:24.000000000 +0200
@@ -1008,13 +1008,15 @@
             VERBOSE("Found changes in the todo list.");
         }
 
+        int underrecordseconds = gContext->GetNumSetting("RecordUnderTime");
+
         recIter = recordingList.begin();
         while (recIter != recordingList.end())
         {
             nextRecording = (*recIter);
 
             nextrectime = nextRecording->startts;
-            secsleft = curtime.secsTo(nextrectime);
+            secsleft = curtime.secsTo(nextrectime) - underrecordseconds;
 
             bool recording = nextRecording->recording;
 
-------------- next part --------------
Index: globalsettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/globalsettings.cpp,v
retrieving revision 1.73
diff -b -u -2 -r1.73 globalsettings.cpp
--- globalsettings.cpp	22 Jun 2003 18:10:10 -0000	1.73
+++ globalsettings.cpp	27 Jun 2003 22:51:00 -0000
@@ -214,4 +214,14 @@
 };
 
+class RecordUnderTime: public SpinBoxSetting, public GlobalSetting {
+public:
+    RecordUnderTime():
+        SpinBoxSetting(0, 600, 1),
+        GlobalSetting("RecordUnderTime") {
+        setLabel("Time to record before start of show (in seconds)");
+        setValue(0);
+    };
+};
+
 class RecordOverTime: public SpinBoxSetting, public GlobalSetting {
 public:
@@ -907,4 +917,5 @@
     VerticalConfigurationGroup* general = new VerticalConfigurationGroup(false);
     general->setLabel("General");
+    general->addChild(new RecordUnderTime());
     general->addChild(new RecordOverTime());
     general->addChild(new PlayBoxOrdering());
-------------- next part --------------
--- mainserver.cpp	2003-06-28 00:38:46.000000000 +0200
+++ mainserver.cpp.new	2003-06-28 00:07:47.000000000 +0200
@@ -719,23 +719,6 @@
         }
     }
 
-    QString fileprefix = gContext->GetFilePrefix();
-    QString filename = pginfo->GetRecordFilename(fileprefix);
-    QFile checkFile(filename);
-
-    if (!checkFile.exists())
-    {
-       cerr << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")
-            << " Strange.  File: " << filename << " doesn't exist." << endl;
-
-       QStringList outputlist;
-       outputlist << "BAD: Tried to delete a file that was in "
-                     "the database but wasn't on the disk.";
-       WriteStringList(pbs->getSocket(), outputlist);
-       delete pginfo;
-       return;
-    }
-
     QSqlQuery query;
     QString thequery;
 
@@ -779,15 +762,35 @@
 
     dblock.unlock();
 
-    DeleteStruct *ds = new DeleteStruct;
-    ds->filename = filename;
+    QString fileprefix = gContext->GetFilePrefix();
+    QString filename = pginfo->GetRecordFilename(fileprefix);
+    QFile checkFile(filename);
 
-    pthread_t deletethread;
-    pthread_attr_t attr;
-    pthread_attr_init(&attr);
-    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+    // Check if file exists
+    if (checkFile.exists())
+    {
+        // If so, let's delete it using a newly created deleter thread
+        DeleteStruct *ds = new DeleteStruct;
+        ds->filename = filename;
+
+        pthread_t deletethread;
+        pthread_attr_t attr;
+        pthread_attr_init(&attr);
+        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
-    pthread_create(&deletethread, &attr, SpawnDelete, ds);
+        pthread_create(&deletethread, &attr, SpawnDelete, ds);
+    }
+    else
+    {
+	// If not, output an error but continue as if nothing happened
+        cerr << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")
+             << " Strange.  File: " << filename << " doesn't exist." << endl;
+
+        QStringList outputlist;
+        outputlist << "BAD: Tried to delete a file that was in "
+                      "the database but wasn't on the disk.";
+        WriteStringList(pbs->getSocket(), outputlist);
+    }
 
     QStringList outputlist = QString::number(recnum);
     WriteStringList(pbs->getSocket(), outputlist);


More information about the mythtv-users mailing list