[mythtv] [PATCH] Proposing some schedule recordings changes

Vedran Rodic vedran at vodatel.hr
Tue Aug 31 09:35:07 EDT 2004


Hi.. Here are the above mentioned patches.

patch01 - Changes to endcoderlink.cpp, matching a recording with recordid

patch02 - changes to mainserver.cpp

This mainly fixes the deleting manually scheduled recording bug and
makes sure that stopped recording doesn't restart on backend restarts. 
Also some redundant code is removed (setting the starttime to exactly 
the same value in mainserver.cpp).

There still is a problem with stopping a recording and starting another 
on the same program in the same minute. To fix this, we should make 
recordid in recorded table unique, instead of (chanid, starttime).


please comment

Vedran



-------------- next part --------------
Index: programs/mythbackend/encoderlink.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/encoderlink.cpp,v
retrieving revision 1.35
diff -u -1 -b -p -u -r1.35 encoderlink.cpp
--- programs/mythbackend/encoderlink.cpp	15 Aug 2004 22:38:31 -0000	1.35
+++ programs/mythbackend/encoderlink.cpp	31 Aug 2004 13:25:54 -0000
@@ -135,5 +135,3 @@ bool EncoderLink::MatchesRecording(Progr
         {
-            if (tvrec->chanid == rec->chanid && 
-                tvrec->recstartts == rec->recstartts &&
-                tvrec->recendts == rec->recendts)
+	   if (tvrec->recordid == rec->recordid)
             {
-------------- next part --------------
Index: programs/mythbackend/mainserver.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythbackend/mainserver.cpp,v
retrieving revision 1.154
diff -u -1 -b -p -u -r1.154 mainserver.cpp
--- programs/mythbackend/mainserver.cpp	30 Aug 2004 04:21:26 -0000	1.154
+++ programs/mythbackend/mainserver.cpp	31 Aug 2004 13:28:49 -0000
@@ -19,3 +19,3 @@
 using namespace std;
-
+#define DEBUGP std::cout
 #include <sys/stat.h>
@@ -1100,3 +1100,2 @@ void MainServer::DoHandleStopRecording(P
             recnum = iter.key();
-
             elink->StopRecording();
@@ -1133,6 +1132,2 @@ void MainServer::DoHandleStopRecording(P
 
-    QString startts = pginfo->recstartts.toString("yyyyMMddhhmm");
-    startts += "00";
-    QString endts = pginfo->endts.toString("yyyyMMddhhmm");
-    endts += "00";
     QDateTime now(QDateTime::currentDateTime());
@@ -1141,2 +1136,8 @@ void MainServer::DoHandleStopRecording(P
 
+    QString newendtime = now.toString("hhmm");
+    newendtime += "00";
+    
+    QString newenddate = now.toString("yyyyMMdd");
+
+
     // Set the recorded end time to the current time
@@ -1146,12 +1147,6 @@ void MainServer::DoHandleStopRecording(P
     QSqlQuery query(QString::null, m_db);
-    query.prepare("UPDATE recorded SET starttime = :NEWSTARTTIME, "
-                  "endtime = :NEWENDTIME WHERE chanid = :CHANID AND "
-                  "title = :TITLE AND starttime = :STARTTIME AND "
-                  "endtime = :ENDTIME;");
-    query.bindValue(":NEWSTARTTIME", startts);
+    query.prepare("UPDATE recorded SET  endtime = :NEWENDTIME "
+                  "WHERE recordid = :RECORDID;");
     query.bindValue(":NEWENDTIME", newendts);
-    query.bindValue(":CHANID", pginfo->chanid);
-    query.bindValue(":TITLE", pginfo->title.utf8());
-    query.bindValue(":STARTTIME", startts);
-    query.bindValue(":ENDTIME", endts);
+    query.bindValue(":RECORDID", pginfo->recordid);
 
@@ -1164,2 +1159,16 @@ void MainServer::DoHandleStopRecording(P
 
+    query.prepare("UPDATE record SET  endtime = :NEWENDTIME, enddate= :NEWENDDATE "
+		    "WHERE recordid = :RECORDID;");
+    query.bindValue(":NEWENDTIME", newendtime);
+    query.bindValue(":NEWENDDATE", newenddate);
+    query.bindValue(":RECORDID", pginfo->recordid);
+
+    query.exec();
+
+    if (!query.isActive())
+    {
+	    MythContext::DBError("Stop recording program update", query);
+    }
+
+
     dblock.unlock();


More information about the mythtv-dev mailing list