| 1 | --- ./programs/mythcommflag/main.cpp.hibernate 2006-08-17 09:53:41.000000000 -0400
|
|---|
| 2 | +++ ./programs/mythcommflag/main.cpp 2006-09-25 22:19:00.000000000 -0400
|
|---|
| 3 | @@ -52,6 +52,13 @@
|
|---|
| 4 |
|
|---|
| 5 | int jobID = -1;
|
|---|
| 6 | int lastCmd = -1;
|
|---|
| 7 | +JobMonitor *currentJobMonitor;
|
|---|
| 8 | +
|
|---|
| 9 | +static void rebuild_status_callback(int, void *)
|
|---|
| 10 | +{
|
|---|
| 11 | + if (currentJobMonitor)
|
|---|
| 12 | + currentJobMonitor->hibernate();
|
|---|
| 13 | +}
|
|---|
| 14 |
|
|---|
| 15 | int BuildVideoMarkup(QString& filename)
|
|---|
| 16 | {
|
|---|
| 17 | @@ -82,7 +89,7 @@
|
|---|
| 18 | program_info);
|
|---|
| 19 | nvp->SetRingBuffer(tmprbuf);
|
|---|
| 20 |
|
|---|
| 21 | - nvp->RebuildSeekTable(!quiet);
|
|---|
| 22 | + nvp->RebuildSeekTable(!quiet, rebuild_status_callback);
|
|---|
| 23 |
|
|---|
| 24 | cerr << "Rebuilt\n";
|
|---|
| 25 |
|
|---|
| 26 | @@ -255,7 +262,9 @@
|
|---|
| 27 |
|
|---|
| 28 | if (jobID != -1)
|
|---|
| 29 | {
|
|---|
| 30 | - int curCmd = JobQueue::GetJobCmd(jobID);
|
|---|
| 31 | + int curCmd = currentJobMonitor ? currentJobMonitor->GetJobCmd()
|
|---|
| 32 | + : JobQueue::GetJobCmd(jobID);
|
|---|
| 33 | +
|
|---|
| 34 | if (curCmd == lastCmd)
|
|---|
| 35 | return;
|
|---|
| 36 |
|
|---|
| 37 | @@ -397,6 +406,10 @@
|
|---|
| 38 |
|
|---|
| 39 | program_info->SetCommFlagged(COMM_FLAG_PROCESSING);
|
|---|
| 40 |
|
|---|
| 41 | + JobMonitor monitor(jobID);
|
|---|
| 42 | +
|
|---|
| 43 | + currentJobMonitor= jobID == -1 ? NULL: &monitor;
|
|---|
| 44 | +
|
|---|
| 45 | CustomEventRelayer cer(incomingCustomEvent);
|
|---|
| 46 | SlotRelayer a(commDetectorBreathe);
|
|---|
| 47 | SlotRelayer b(commDetectorStatusUpdate);
|
|---|
| 48 | @@ -447,7 +460,7 @@
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | delete commDetector;
|
|---|
| 52 | -
|
|---|
| 53 | + currentJobMonitor=NULL;
|
|---|
| 54 | return comms_found;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | @@ -537,7 +550,7 @@
|
|---|
| 58 |
|
|---|
| 59 | if (rebuildSeekTable)
|
|---|
| 60 | {
|
|---|
| 61 | - nvp->RebuildSeekTable();
|
|---|
| 62 | + nvp->RebuildSeekTable(false, rebuild_status_callback);
|
|---|
| 63 |
|
|---|
| 64 | if (!quiet)
|
|---|
| 65 | cerr << "Rebuilt\n";
|
|---|
| 66 | --- ./programs/mythtranscode/transcode.cpp.hibernate 2006-08-23 18:20:59.000000000 -0400
|
|---|
| 67 | +++ ./programs/mythtranscode/transcode.cpp 2006-09-25 22:19:00.000000000 -0400
|
|---|
| 68 | @@ -609,6 +609,8 @@
|
|---|
| 69 | QTime flagTime;
|
|---|
| 70 | flagTime.start();
|
|---|
| 71 |
|
|---|
| 72 | + JobMonitor monitor(jobID);
|
|---|
| 73 | +
|
|---|
| 74 | while (nvp->TranscodeGetNextFrame(dm_iter, &did_ff, &is_key, honorCutList))
|
|---|
| 75 | {
|
|---|
| 76 | if (first_loop)
|
|---|
| 77 | @@ -885,7 +887,7 @@
|
|---|
| 78 |
|
|---|
| 79 | if ((jobID >= 0) || (print_verbose_messages & VB_IMPORTANT))
|
|---|
| 80 | {
|
|---|
| 81 | - if (JobQueue::GetJobCmd(jobID) == JOB_STOP)
|
|---|
| 82 | + if (monitor.GetJobCmd() == JOB_STOP)
|
|---|
| 83 | {
|
|---|
| 84 | unlink(outputname);
|
|---|
| 85 | delete newFrame;
|
|---|
| 86 | --- ./programs/mythtranscode/mpeg2fix.cpp.hibernate 2006-07-18 20:24:00.000000000 -0400
|
|---|
| 87 | +++ ./programs/mythtranscode/mpeg2fix.cpp 2006-09-25 22:24:29.000000000 -0400
|
|---|
| 88 | @@ -14,6 +14,7 @@
|
|---|
| 89 | #include <netinet/in.h>
|
|---|
| 90 | #include <getopt.h>
|
|---|
| 91 | #include <stdint.h>
|
|---|
| 92 | +#include "jobqueue.h"
|
|---|
| 93 |
|
|---|
| 94 | #ifndef O_LARGEFILE
|
|---|
| 95 | #define O_LARGEFILE 0
|
|---|
| 96 | @@ -199,8 +200,11 @@
|
|---|
| 97 | MPEG2fixup::MPEG2fixup(const char *inf, const char *outf,
|
|---|
| 98 | QMap<long long, int> *deleteMap,
|
|---|
| 99 | const char *fmt, int norp, int fixPTS, int maxf,
|
|---|
| 100 | - bool showprog, int otype)
|
|---|
| 101 | + bool showprog, int otype, int jobIDarg)
|
|---|
| 102 | + : rx(jobID)
|
|---|
| 103 | {
|
|---|
| 104 | + jobID=jobIDarg;
|
|---|
| 105 | +
|
|---|
| 106 | displayFrame = new QPtrListIterator<MPEG2frame> (vFrame);
|
|---|
| 107 |
|
|---|
| 108 | infile = inf;
|
|---|
| 109 | @@ -429,13 +433,14 @@
|
|---|
| 110 | return (rx->WaitBuffers());
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | -MPEG2replex::MPEG2replex()
|
|---|
| 114 | +MPEG2replex::MPEG2replex(int jobIDarg)
|
|---|
| 115 | {
|
|---|
| 116 | memset(&vrbuf, 0, sizeof(ringbuffer));
|
|---|
| 117 | memset(&index_vrbuf, 0, sizeof(ringbuffer));
|
|---|
| 118 | memset(&extrbuf, 0, sizeof(ringbuffer) * N_AUDIO);
|
|---|
| 119 | memset(&index_extrbuf, 0, sizeof(ringbuffer) * N_AUDIO);
|
|---|
| 120 | ext_count = 0;
|
|---|
| 121 | + jobID=jobIDarg;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | MPEG2replex::~MPEG2replex()
|
|---|
| 125 | @@ -1797,8 +1802,12 @@
|
|---|
| 126 |
|
|---|
| 127 | InitReplex();
|
|---|
| 128 |
|
|---|
| 129 | + JobMonitor monitor(jobID);
|
|---|
| 130 | +
|
|---|
| 131 | while (1)
|
|---|
| 132 | {
|
|---|
| 133 | + monitor.hibernate();
|
|---|
| 134 | +
|
|---|
| 135 | /* read packet */
|
|---|
| 136 | if (! file_end)
|
|---|
| 137 | {
|
|---|
| 138 | @@ -2432,6 +2441,8 @@
|
|---|
| 139 | AVPacket pkt;
|
|---|
| 140 | int count = 0;
|
|---|
| 141 |
|
|---|
| 142 | + JobMonitor monitor(jobID);
|
|---|
| 143 | +
|
|---|
| 144 | /*============ initialise AV ===============*/
|
|---|
| 145 | if (!InitAV(file.ascii(), NULL, 0))
|
|---|
| 146 | return TRANSCODE_EXIT_UNKNOWN_ERROR;
|
|---|
| 147 | @@ -2440,6 +2451,8 @@
|
|---|
| 148 |
|
|---|
| 149 | while (av_read_frame(inputFC, &pkt) >= 0)
|
|---|
| 150 | {
|
|---|
| 151 | + monitor.hibernate();
|
|---|
| 152 | +
|
|---|
| 153 | if (pkt.stream_index == vid_id)
|
|---|
| 154 | {
|
|---|
| 155 | if (pkt.flags & PKT_FLAG_KEY)
|
|---|
| 156 | --- ./programs/mythtranscode/mpeg2fix.h.hibernate 2006-02-18 13:44:52.000000000 -0500
|
|---|
| 157 | +++ ./programs/mythtranscode/mpeg2fix.h 2006-09-25 22:20:52.000000000 -0400
|
|---|
| 158 | @@ -102,7 +102,7 @@
|
|---|
| 159 | class MPEG2replex
|
|---|
| 160 | {
|
|---|
| 161 | public:
|
|---|
| 162 | - MPEG2replex();
|
|---|
| 163 | + MPEG2replex(int jobID);
|
|---|
| 164 | ~MPEG2replex();
|
|---|
| 165 | void Start();
|
|---|
| 166 | int WaitBuffers();
|
|---|
| 167 | @@ -124,6 +124,7 @@
|
|---|
| 168 |
|
|---|
| 169 | private:
|
|---|
| 170 | multiplex_t *mplex;
|
|---|
| 171 | + int jobID;
|
|---|
| 172 | };
|
|---|
| 173 |
|
|---|
| 174 | class MPEG2fixup
|
|---|
| 175 | @@ -131,7 +132,8 @@
|
|---|
| 176 | public:
|
|---|
| 177 | MPEG2fixup(const char *inf, const char *outf,
|
|---|
| 178 | QMap<long long, int> *deleteMap, const char *fmt, int norp,
|
|---|
| 179 | - int fixPTS, int maxf, bool showprog, int otype);
|
|---|
| 180 | + int fixPTS, int maxf, bool showprog, int otype,
|
|---|
| 181 | + int jobID);
|
|---|
| 182 | ~MPEG2fixup();
|
|---|
| 183 | int Start();
|
|---|
| 184 | void AddRangeList(QStringList cutlist, int type);
|
|---|
| 185 | @@ -224,6 +226,8 @@
|
|---|
| 186 | QMap<long long, int> delMap;
|
|---|
| 187 | QMap<long long, int> saveMap;
|
|---|
| 188 |
|
|---|
| 189 | + int jobID;
|
|---|
| 190 | +
|
|---|
| 191 | pthread_t thread;
|
|---|
| 192 |
|
|---|
| 193 | AVFormatContext *inputFC;
|
|---|
| 194 | --- ./programs/mythtranscode/main.cpp.hibernate 2006-07-15 15:39:26.000000000 -0400
|
|---|
| 195 | +++ ./programs/mythtranscode/main.cpp 2006-09-25 22:22:04.000000000 -0400
|
|---|
| 196 | @@ -468,7 +468,7 @@
|
|---|
| 197 |
|
|---|
| 198 | MPEG2fixup *m2f = new MPEG2fixup(infile.ascii(), outfile.ascii(),
|
|---|
| 199 | &deleteMap, NULL, false, false, 20,
|
|---|
| 200 | - showprogress, otype);
|
|---|
| 201 | + showprogress, otype, jobID);
|
|---|
| 202 | if (build_index)
|
|---|
| 203 | {
|
|---|
| 204 | int err = BuildKeyframeIndex(m2f, infile, posMap, jobID);
|
|---|
| 205 | --- ./programs/mythfilldatabase/filldata.cpp.hibernate 2006-09-25 22:16:01.000000000 -0400
|
|---|
| 206 | +++ ./programs/mythfilldatabase/filldata.cpp 2006-09-25 22:55:42.000000000 -0400
|
|---|
| 207 | @@ -43,6 +43,7 @@
|
|---|
| 208 | #include "cardutil.h"
|
|---|
| 209 | #include "sourceutil.h"
|
|---|
| 210 | #include "remoteutil.h"
|
|---|
| 211 | +#include "jobqueue.h"
|
|---|
| 212 |
|
|---|
| 213 | using namespace std;
|
|---|
| 214 |
|
|---|
| 215 | @@ -81,6 +82,8 @@
|
|---|
| 216 | QString graboptions = "";
|
|---|
| 217 | QString cardtype = QString::null;
|
|---|
| 218 |
|
|---|
| 219 | +JobMonitor *myMonitor;
|
|---|
| 220 | +
|
|---|
| 221 | class ChanInfo
|
|---|
| 222 | {
|
|---|
| 223 | public:
|
|---|
| 224 | @@ -241,6 +244,8 @@
|
|---|
| 225 | int secs;
|
|---|
| 226 | QDateTime newFrom, newTo;
|
|---|
| 227 |
|
|---|
| 228 | + myMonitor->hibernate();
|
|---|
| 229 | +
|
|---|
| 230 | MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 231 |
|
|---|
| 232 | query.prepare("SELECT tmoffset FROM channel where chanid = :CHANID ;");
|
|---|
| 233 | @@ -258,6 +263,8 @@
|
|---|
| 234 | newFrom = from.addSecs(secs);
|
|---|
| 235 | newTo = to.addSecs(secs);
|
|---|
| 236 |
|
|---|
| 237 | + myMonitor->hibernate();
|
|---|
| 238 | +
|
|---|
| 239 | query.prepare("DELETE FROM program "
|
|---|
| 240 | "WHERE starttime >= :FROM AND starttime < :TO "
|
|---|
| 241 | "AND chanid = :CHANID ;");
|
|---|
| 242 | @@ -266,6 +273,8 @@
|
|---|
| 243 | query.bindValue(":CHANID", chanid);
|
|---|
| 244 | query.exec();
|
|---|
| 245 |
|
|---|
| 246 | + myMonitor->hibernate();
|
|---|
| 247 | +
|
|---|
| 248 | query.prepare("DELETE FROM programrating "
|
|---|
| 249 | "WHERE starttime >= :FROM AND starttime < :TO "
|
|---|
| 250 | "AND chanid = :CHANID ;");
|
|---|
| 251 | @@ -274,6 +283,8 @@
|
|---|
| 252 | query.bindValue(":CHANID", chanid);
|
|---|
| 253 | query.exec();
|
|---|
| 254 |
|
|---|
| 255 | + myMonitor->hibernate();
|
|---|
| 256 | +
|
|---|
| 257 | query.prepare("DELETE FROM credits "
|
|---|
| 258 | "WHERE starttime >= :FROM AND starttime < :TO "
|
|---|
| 259 | "AND chanid = :CHANID ;");
|
|---|
| 260 | @@ -282,6 +293,8 @@
|
|---|
| 261 | query.bindValue(":CHANID", chanid);
|
|---|
| 262 | query.exec();
|
|---|
| 263 |
|
|---|
| 264 | + myMonitor->hibernate();
|
|---|
| 265 | +
|
|---|
| 266 | query.prepare("DELETE FROM programgenres "
|
|---|
| 267 | "WHERE starttime >= :FROM AND starttime < :TO "
|
|---|
| 268 | "AND chanid = :CHANID ;");
|
|---|
| 269 | @@ -298,6 +311,8 @@
|
|---|
| 270 | "sourceid = :SOURCE ;");
|
|---|
| 271 | query.bindValue(":SOURCE", sourceid);
|
|---|
| 272 |
|
|---|
| 273 | + myMonitor->hibernate();
|
|---|
| 274 | +
|
|---|
| 275 | if (!query.exec())
|
|---|
| 276 | MythContext::DBError("Selecting channels per source", query);
|
|---|
| 277 |
|
|---|
| 278 | @@ -366,6 +381,8 @@
|
|---|
| 279 |
|
|---|
| 280 | QString fileprefix = SetupIconCacheDirectory();
|
|---|
| 281 |
|
|---|
| 282 | + myMonitor->hibernate();
|
|---|
| 283 | +
|
|---|
| 284 | MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 285 | query.prepare("SELECT ch.chanid, nim.url "
|
|---|
| 286 | "FROM (channel ch, callsignnetworkmap csm) "
|
|---|
| 287 | @@ -382,6 +399,8 @@
|
|---|
| 288 | {
|
|---|
| 289 | while (query.next())
|
|---|
| 290 | {
|
|---|
| 291 | + myMonitor->hibernate();
|
|---|
| 292 | +
|
|---|
| 293 | QString icon_url = expandURLString(query.value(1).toString());
|
|---|
| 294 | QFileInfo qfi(icon_url);
|
|---|
| 295 | QFile localfile(fileprefix + "/" + qfi.fileName());
|
|---|
| 296 | @@ -566,6 +585,7 @@
|
|---|
| 297 | QDomNode node = element.firstChild();
|
|---|
| 298 | while (!node.isNull())
|
|---|
| 299 | {
|
|---|
| 300 | + myMonitor->hibernate();
|
|---|
| 301 | try
|
|---|
| 302 | {
|
|---|
| 303 | QDomElement e = nodeToElement(node);
|
|---|
| 304 | @@ -576,6 +596,7 @@
|
|---|
| 305 |
|
|---|
| 306 | nm_query.bindValue(":NETWORK", net.stripWhiteSpace());
|
|---|
| 307 | nm_query.bindValue(":URL", u.stripWhiteSpace());
|
|---|
| 308 | +
|
|---|
| 309 | if (!nm_query.exec())
|
|---|
| 310 | MythContext::DBError(
|
|---|
| 311 | "Inserting network->url mapping", nm_query);
|
|---|
| 312 | @@ -599,6 +620,8 @@
|
|---|
| 313 | st += getNamedElementText(e, IM_BASE_STUB_TAG);
|
|---|
| 314 | QString u = getNamedElementText(e, IM_NET_URL_TAG);
|
|---|
| 315 |
|
|---|
| 316 | + myMonitor->hibernate();
|
|---|
| 317 | +
|
|---|
| 318 | MSqlQuery qc(MSqlQuery::InitCon());
|
|---|
| 319 | qc.prepare("SELECT COUNT(*) FROM settings "
|
|---|
| 320 | "WHERE value = :STUBNAME");
|
|---|
| 321 | @@ -616,6 +639,8 @@
|
|---|
| 322 | qr->bindValue(":STUBNAME", st);
|
|---|
| 323 | qr->bindValue(":URL", u);
|
|---|
| 324 |
|
|---|
| 325 | + myMonitor->hibernate();
|
|---|
| 326 | +
|
|---|
| 327 | if (!qr->exec())
|
|---|
| 328 | MythContext::DBError(
|
|---|
| 329 | "Inserting callsign->network mapping", *qr);
|
|---|
| 330 | @@ -667,6 +692,8 @@
|
|---|
| 331 | QDomDocument iconmap;
|
|---|
| 332 | QDomElement roote = iconmap.createElement(IM_DOC_TAG);
|
|---|
| 333 |
|
|---|
| 334 | + myMonitor->hibernate();
|
|---|
| 335 | +
|
|---|
| 336 | MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 337 | query.exec("SELECT * FROM callsignnetworkmap ORDER BY callsign;");
|
|---|
| 338 |
|
|---|
| 339 | @@ -674,6 +701,8 @@
|
|---|
| 340 | {
|
|---|
| 341 | while (query.next())
|
|---|
| 342 | {
|
|---|
| 343 | + myMonitor->hibernate();
|
|---|
| 344 | +
|
|---|
| 345 | QDomElement cs2nettag = iconmap.createElement(IM_CS_TO_NET_TAG);
|
|---|
| 346 | QDomElement cstag = iconmap.createElement(IM_CS_TAG);
|
|---|
| 347 | QDomElement nettag = iconmap.createElement(IM_NET_TAG);
|
|---|
| 348 | @@ -692,11 +721,14 @@
|
|---|
| 349 | }
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | + myMonitor->hibernate();
|
|---|
| 353 | query.exec("SELECT * FROM networkiconmap ORDER BY network;");
|
|---|
| 354 | if (query.isActive() && query.size() > 0)
|
|---|
| 355 | {
|
|---|
| 356 | while (query.next())
|
|---|
| 357 | {
|
|---|
| 358 | + myMonitor->hibernate();
|
|---|
| 359 | +
|
|---|
| 360 | QDomElement net2urltag = iconmap.createElement(
|
|---|
| 361 | IM_NET_TO_URL_TAG);
|
|---|
| 362 | QDomElement nettag = iconmap.createElement(IM_NET_TAG);
|
|---|
| 363 | @@ -716,6 +748,8 @@
|
|---|
| 364 | }
|
|---|
| 365 | }
|
|---|
| 366 |
|
|---|
| 367 | + myMonitor->hibernate();
|
|---|
| 368 | +
|
|---|
| 369 | query.prepare("SELECT value,data FROM settings WHERE value "
|
|---|
| 370 | "LIKE :URLMAP");
|
|---|
| 371 | query.bindValue(":URLMAP", QString(BASEURLMAP_START) + "%");
|
|---|
| 372 | @@ -725,6 +759,8 @@
|
|---|
| 373 | QRegExp baseax("\\.([^\\.]+)$");
|
|---|
| 374 | while (query.next())
|
|---|
| 375 | {
|
|---|
| 376 | + myMonitor->hibernate();
|
|---|
| 377 | +
|
|---|
| 378 | QString base_stub = query.value(0).toString();
|
|---|
| 379 | if (baseax.search(base_stub) != -1)
|
|---|
| 380 | {
|
|---|
| 381 | @@ -760,6 +796,8 @@
|
|---|
| 382 |
|
|---|
| 383 | void RunSimpleQuery(const QString &query)
|
|---|
| 384 | {
|
|---|
| 385 | + myMonitor->hibernate();
|
|---|
| 386 | +
|
|---|
| 387 | MSqlQuery q(MSqlQuery::InitCon());
|
|---|
| 388 | if (!q.exec(query))
|
|---|
| 389 | MythContext::DBError("RunSimpleQuery ", q);
|
|---|
| 390 | @@ -770,6 +808,7 @@
|
|---|
| 391 | MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 392 | query.prepare("DELETE FROM settings WHERE value LIKE :URLMAPLIKE");
|
|---|
| 393 | query.bindValue(":URLMAPLIKE", QString(BASEURLMAP_START) + '%');
|
|---|
| 394 | + myMonitor->hibernate();
|
|---|
| 395 | if (!query.exec())
|
|---|
| 396 | MythContext::DBError("ResetIconMap", query);
|
|---|
| 397 |
|
|---|
| 398 | @@ -799,6 +838,8 @@
|
|---|
| 399 |
|
|---|
| 400 | freq = get_center_frequency("atsc", "vsb8", "us", freqid);
|
|---|
| 401 |
|
|---|
| 402 | + myMonitor->hibernate();
|
|---|
| 403 | +
|
|---|
| 404 | // Check if this is connected to an HDTV card.
|
|---|
| 405 | MSqlQuery query(MSqlQuery::DDCon());
|
|---|
| 406 | query.prepare(
|
|---|
| 407 | @@ -899,6 +940,8 @@
|
|---|
| 408 | {
|
|---|
| 409 | MSqlQuery query(MSqlQuery::DDCon());
|
|---|
| 410 |
|
|---|
| 411 | + myMonitor->hibernate();
|
|---|
| 412 | +
|
|---|
| 413 | //cerr << "Adding rows to main program table from view table..\n";
|
|---|
| 414 | if (!query.exec("INSERT IGNORE INTO program (chanid, starttime, endtime, "
|
|---|
| 415 | "title, subtitle, description, "
|
|---|
| 416 | @@ -922,6 +965,8 @@
|
|---|
| 417 | "WHERE dd_v_program.chanid = channel.chanid;"))
|
|---|
| 418 | MythContext::DBError("Inserting into program table", query);
|
|---|
| 419 |
|
|---|
| 420 | + myMonitor->hibernate();
|
|---|
| 421 | +
|
|---|
| 422 | //cerr << "Finished adding rows to main program table...\n";
|
|---|
| 423 | //cerr << "Adding program ratings...\n";
|
|---|
| 424 |
|
|---|
| 425 | @@ -934,6 +979,8 @@
|
|---|
| 426 | "channel.chanid"))
|
|---|
| 427 | MythContext::DBError("Inserting into programrating table", query);
|
|---|
| 428 |
|
|---|
| 429 | + myMonitor->hibernate();
|
|---|
| 430 | +
|
|---|
| 431 | if (!query.exec("INSERT IGNORE INTO programrating (chanid, starttime, "
|
|---|
| 432 | "system, rating) SELECT dd_v_program.chanid, "
|
|---|
| 433 | "DATE_ADD(starttime, INTERVAL channel.tmoffset MINUTE), "
|
|---|
| 434 | @@ -945,6 +992,8 @@
|
|---|
| 435 | //cerr << "Finished adding program ratings...\n";
|
|---|
| 436 | //cerr << "Populating people table from production crew list...\n";
|
|---|
| 437 |
|
|---|
| 438 | + myMonitor->hibernate();
|
|---|
| 439 | +
|
|---|
| 440 | if (!query.exec("INSERT IGNORE INTO people (name) SELECT fullname "
|
|---|
| 441 | "FROM dd_productioncrew;"))
|
|---|
| 442 | MythContext::DBError("Inserting into people table", query);
|
|---|
| 443 | @@ -952,6 +1001,8 @@
|
|---|
| 444 | //cerr << "Finished adding people...\n";
|
|---|
| 445 | //cerr << "Adding credits entries from production crew list...\n";
|
|---|
| 446 |
|
|---|
| 447 | + myMonitor->hibernate();
|
|---|
| 448 | +
|
|---|
| 449 | if (!query.exec("INSERT IGNORE INTO credits (chanid, starttime, person, "
|
|---|
| 450 | "role) SELECT dd_v_program.chanid, "
|
|---|
| 451 | "DATE_ADD(starttime, INTERVAL channel.tmoffset MINUTE), "
|
|---|
| 452 | @@ -966,6 +1017,8 @@
|
|---|
| 453 | //cerr << "Finished inserting credits...\n";
|
|---|
| 454 | //cerr << "Adding genres...\n";
|
|---|
| 455 |
|
|---|
| 456 | + myMonitor->hibernate();
|
|---|
| 457 | +
|
|---|
| 458 | if (!query.exec("INSERT IGNORE INTO programgenres (chanid, starttime, "
|
|---|
| 459 | "relevance, genre) SELECT dd_v_program.chanid, "
|
|---|
| 460 | "DATE_ADD(starttime, INTERVAL channel.tmoffset MINUTE), "
|
|---|
| 461 | @@ -995,6 +1048,8 @@
|
|---|
| 462 | MSqlQuery query(MSqlQuery::DDCon());
|
|---|
| 463 | QString status = "currently running.";
|
|---|
| 464 |
|
|---|
| 465 | + myMonitor->hibernate();
|
|---|
| 466 | +
|
|---|
| 467 | query.exec(QString("UPDATE settings SET data ='%1' "
|
|---|
| 468 | "WHERE value='mythfilldatabaseLastRunStart'")
|
|---|
| 469 | .arg(qdtNow.toString("yyyy-MM-dd hh:mm")));
|
|---|
| 470 | @@ -1046,6 +1101,7 @@
|
|---|
| 471 | .arg(ddprocessor.GetDDProgramsStartAt().toString())
|
|---|
| 472 | .arg(ddprocessor.GetDDProgramsEndAt().toString()));
|
|---|
| 473 |
|
|---|
| 474 | + myMonitor->hibernate();
|
|---|
| 475 | qdtNow = QDateTime::currentDateTime();
|
|---|
| 476 | query.exec(QString("UPDATE settings SET data ='%1' "
|
|---|
| 477 | "WHERE value='mythfilldatabaseLastRunEnd'")
|
|---|
| 478 | @@ -1064,6 +1120,8 @@
|
|---|
| 479 | DataDirectProcessor::UpdateProgramViewTable(source.id);
|
|---|
| 480 | //cerr << "Finished creating program view table...\n";
|
|---|
| 481 |
|
|---|
| 482 | + myMonitor->hibernate();
|
|---|
| 483 | +
|
|---|
| 484 | query.exec("SELECT count(*) from dd_v_program;");
|
|---|
| 485 | if (query.isActive() && query.size() > 0)
|
|---|
| 486 | {
|
|---|
| 487 | @@ -1676,6 +1734,8 @@
|
|---|
| 488 | }
|
|---|
| 489 | else if (e.tagName() == "programme")
|
|---|
| 490 | {
|
|---|
| 491 | + myMonitor->hibernate();
|
|---|
| 492 | +
|
|---|
| 493 | ProgInfo *pginfo = parseProgram(e, localTimezoneOffset);
|
|---|
| 494 |
|
|---|
| 495 | if (pginfo->startts == pginfo->endts)
|
|---|
| 496 | @@ -1761,6 +1821,8 @@
|
|---|
| 497 | QValueList<ProgInfo>::iterator cur;
|
|---|
| 498 | while (1)
|
|---|
| 499 | {
|
|---|
| 500 | + myMonitor->hibernate();
|
|---|
| 501 | +
|
|---|
| 502 | cur = i;
|
|---|
| 503 | i++;
|
|---|
| 504 | // fill in miss stop times
|
|---|
| 505 | @@ -1947,6 +2009,8 @@
|
|---|
| 506 |
|
|---|
| 507 | if ((*i).old_xmltvid != "")
|
|---|
| 508 | {
|
|---|
| 509 | + myMonitor->hibernate();
|
|---|
| 510 | +
|
|---|
| 511 | querystr.sprintf("SELECT xmltvid FROM channel WHERE xmltvid = '%s'",
|
|---|
| 512 | (*i).old_xmltvid.ascii());
|
|---|
| 513 | query.exec(querystr);
|
|---|
| 514 | @@ -1966,6 +2030,8 @@
|
|---|
| 515 | }
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 | + myMonitor->hibernate();
|
|---|
| 519 | +
|
|---|
| 520 | querystr.sprintf("SELECT chanid,name,callsign,channum,finetune,"
|
|---|
| 521 | "icon,freqid,tvformat FROM channel WHERE "
|
|---|
| 522 | "xmltvid = '%s' AND sourceid = %d;",
|
|---|
| 523 | @@ -1974,6 +2040,8 @@
|
|---|
| 524 | query.exec(querystr);
|
|---|
| 525 | if (query.isActive() && query.size() > 0)
|
|---|
| 526 | {
|
|---|
| 527 | + myMonitor->hibernate();
|
|---|
| 528 | +
|
|---|
| 529 | query.next();
|
|---|
| 530 |
|
|---|
| 531 | QString chanid = query.value(0).toString();
|
|---|
| 532 | @@ -2041,6 +2109,8 @@
|
|---|
| 533 | subquery.bindValue(":XMLTVID", (*i).xmltvid);
|
|---|
| 534 | subquery.bindValue(":SOURCEID", id);
|
|---|
| 535 |
|
|---|
| 536 | + myMonitor->hibernate();
|
|---|
| 537 | +
|
|---|
| 538 | if (!subquery.exec())
|
|---|
| 539 | {
|
|---|
| 540 | cerr << "DB Error: Channel update failed, SQL query "
|
|---|
| 541 | @@ -2071,6 +2141,8 @@
|
|---|
| 542 | subquery.bindValue(":ICON", localfile);
|
|---|
| 543 | subquery.bindValue(":CHANID", chanid);
|
|---|
| 544 |
|
|---|
| 545 | + myMonitor->hibernate();
|
|---|
| 546 | +
|
|---|
| 547 | if (!subquery.exec())
|
|---|
| 548 | MythContext::DBError("Channel icon change", subquery);
|
|---|
| 549 | }
|
|---|
| 550 | @@ -2217,6 +2289,8 @@
|
|---|
| 551 |
|
|---|
| 552 | for (mapiter = proglist->begin(); mapiter != proglist->end(); ++mapiter)
|
|---|
| 553 | {
|
|---|
| 554 | + myMonitor->hibernate();
|
|---|
| 555 | +
|
|---|
| 556 | MSqlQuery query(MSqlQuery::InitCon()), chanQuery(MSqlQuery::InitCon());
|
|---|
| 557 |
|
|---|
| 558 | if (mapiter.key() == "")
|
|---|
| 559 | @@ -2256,6 +2330,8 @@
|
|---|
| 560 | QValueList<ProgInfo>::iterator i = sortlist->begin();
|
|---|
| 561 | for (; i != sortlist->end(); i++)
|
|---|
| 562 | {
|
|---|
| 563 | + myMonitor->hibernate();
|
|---|
| 564 | +
|
|---|
| 565 | query.prepare("SELECT * FROM program WHERE "
|
|---|
| 566 | "chanid=:CHANID AND starttime=:START AND "
|
|---|
| 567 | "endtime=:END AND title=:TITLE AND "
|
|---|
| 568 | @@ -2306,6 +2382,8 @@
|
|---|
| 569 | continue;
|
|---|
| 570 | }
|
|---|
| 571 |
|
|---|
| 572 | + myMonitor->hibernate();
|
|---|
| 573 | +
|
|---|
| 574 | query.prepare("SELECT title,starttime,endtime FROM program "
|
|---|
| 575 | "WHERE chanid=:CHANID AND starttime>=:START AND "
|
|---|
| 576 | "starttime<:END;");
|
|---|
| 577 | @@ -2334,6 +2412,8 @@
|
|---|
| 578 | << (*i).end.toString() << endl << endl;
|
|---|
| 579 | }
|
|---|
| 580 |
|
|---|
| 581 | + myMonitor->hibernate();
|
|---|
| 582 | +
|
|---|
| 583 | MSqlQuery subquery(MSqlQuery::InitCon());
|
|---|
| 584 | subquery.prepare("DELETE FROM program WHERE "
|
|---|
| 585 | "chanid=:CHANID AND starttime>=:START "
|
|---|
| 586 | @@ -2401,6 +2481,9 @@
|
|---|
| 587 | query.bindValue(":COLORCODE", (*i).colorcode);
|
|---|
| 588 | query.bindValue(":SYNDICATEDEPISODENUMBER", (*i).syndicatedepisodenumber);
|
|---|
| 589 | query.bindValue(":PROGRAMID", (*i).programid);
|
|---|
| 590 | +
|
|---|
| 591 | + myMonitor->hibernate();
|
|---|
| 592 | +
|
|---|
| 593 | if (!query.exec())
|
|---|
| 594 | MythContext::DBError("program insert", query);
|
|---|
| 595 |
|
|---|
| 596 | @@ -2417,6 +2500,8 @@
|
|---|
| 597 | query.bindValue(":SYS", (*j).system.utf8());
|
|---|
| 598 | query.bindValue(":RATING", (*j).rating.utf8());
|
|---|
| 599 |
|
|---|
| 600 | + myMonitor->hibernate();
|
|---|
| 601 | +
|
|---|
| 602 | if (!query.exec())
|
|---|
| 603 | MythContext::DBError("programrating insert", query);
|
|---|
| 604 | }
|
|---|
| 605 | @@ -2424,6 +2509,8 @@
|
|---|
| 606 | QValueList<ProgCredit>::iterator k = (*i).credits.begin();
|
|---|
| 607 | for (; k != (*i).credits.end(); k++)
|
|---|
| 608 | {
|
|---|
| 609 | + myMonitor->hibernate();
|
|---|
| 610 | +
|
|---|
| 611 | query.prepare("SELECT person FROM people WHERE "
|
|---|
| 612 | "name = :NAME;");
|
|---|
| 613 | query.bindValue(":NAME", (*k).name.utf8());
|
|---|
| 614 | @@ -2439,6 +2526,7 @@
|
|---|
| 615 |
|
|---|
| 616 | if (personid < 0)
|
|---|
| 617 | {
|
|---|
| 618 | + myMonitor->hibernate();
|
|---|
| 619 | query.prepare("INSERT INTO people (name) VALUES "
|
|---|
| 620 | "(:NAME);");
|
|---|
| 621 | query.bindValue(":NAME", (*k).name.utf8());
|
|---|
| 622 | @@ -2464,6 +2552,8 @@
|
|---|
| 623 | continue;
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | + myMonitor->hibernate();
|
|---|
| 627 | +
|
|---|
| 628 | query.prepare("INSERT INTO credits (chanid,starttime,"
|
|---|
| 629 | "role,person) VALUES "
|
|---|
| 630 | "(:CHANID, :START, :ROLE, :PERSON);");
|
|---|
| 631 | @@ -2680,6 +2770,8 @@
|
|---|
| 632 | MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 633 | QString status = "currently running.";
|
|---|
| 634 |
|
|---|
| 635 | + myMonitor->hibernate();
|
|---|
| 636 | +
|
|---|
| 637 | query.exec(QString("UPDATE settings SET data ='%1' "
|
|---|
| 638 | "WHERE value='mythfilldatabaseLastRunStart'")
|
|---|
| 639 | .arg(qdtNow.toString("yyyy-MM-dd hh:mm")));
|
|---|
| 640 | @@ -2755,6 +2847,8 @@
|
|---|
| 641 | VERBOSE(VB_GENERAL, "Keeping 7 days of data.");
|
|---|
| 642 | }
|
|---|
| 643 |
|
|---|
| 644 | + myMonitor->hibernate();
|
|---|
| 645 | +
|
|---|
| 646 | query.prepare("DELETE FROM oldprogram WHERE airdate < "
|
|---|
| 647 | "DATE_SUB(CURRENT_DATE, INTERVAL 320 DAY);");
|
|---|
| 648 | query.exec();
|
|---|
| 649 | @@ -2763,44 +2857,57 @@
|
|---|
| 650 | "SELECT title,starttime FROM program "
|
|---|
| 651 | "WHERE starttime < NOW() AND manualid = 0 "
|
|---|
| 652 | "GROUP BY title;");
|
|---|
| 653 | + myMonitor->hibernate();
|
|---|
| 654 | +
|
|---|
| 655 | query.exec();
|
|---|
| 656 |
|
|---|
| 657 | query.prepare("DELETE FROM program WHERE starttime <= "
|
|---|
| 658 | "DATE_SUB(CURRENT_DATE, INTERVAL :OFFSET DAY);");
|
|---|
| 659 | query.bindValue(":OFFSET", offset);
|
|---|
| 660 | + myMonitor->hibernate();
|
|---|
| 661 | +
|
|---|
| 662 | query.exec();
|
|---|
| 663 |
|
|---|
| 664 | query.prepare("DELETE FROM programrating WHERE starttime <= "
|
|---|
| 665 | "DATE_SUB(CURRENT_DATE, INTERVAL :OFFSET DAY);");
|
|---|
| 666 | query.bindValue(":OFFSET", offset);
|
|---|
| 667 | + myMonitor->hibernate();
|
|---|
| 668 | +
|
|---|
| 669 | query.exec();
|
|---|
| 670 |
|
|---|
| 671 | query.prepare("DELETE FROM programgenres WHERE starttime <= "
|
|---|
| 672 | "DATE_SUB(CURRENT_DATE, INTERVAL :OFFSET DAY);");
|
|---|
| 673 | query.bindValue(":OFFSET", offset);
|
|---|
| 674 | + myMonitor->hibernate();
|
|---|
| 675 | +
|
|---|
| 676 | query.exec();
|
|---|
| 677 |
|
|---|
| 678 | query.prepare("DELETE FROM credits WHERE starttime <= "
|
|---|
| 679 | "DATE_SUB(CURRENT_DATE, INTERVAL :OFFSET DAY);");
|
|---|
| 680 | query.bindValue(":OFFSET", offset);
|
|---|
| 681 | + myMonitor->hibernate();
|
|---|
| 682 | +
|
|---|
| 683 | query.exec();
|
|---|
| 684 |
|
|---|
| 685 | query.prepare("DELETE p FROM recordedprogram p "
|
|---|
| 686 | "LEFT JOIN recorded r ON "
|
|---|
| 687 | " p.chanid = r.chanid AND p.starttime = r.progstart "
|
|---|
| 688 | "WHERE r.chanid IS NULL;");
|
|---|
| 689 | + myMonitor->hibernate();
|
|---|
| 690 | query.exec();
|
|---|
| 691 |
|
|---|
| 692 | query.prepare("DELETE p FROM recordedrating p "
|
|---|
| 693 | "LEFT JOIN recorded r ON "
|
|---|
| 694 | " p.chanid = r.chanid AND p.starttime = r.progstart "
|
|---|
| 695 | "WHERE r.chanid IS NULL;");
|
|---|
| 696 | + myMonitor->hibernate();
|
|---|
| 697 | query.exec();
|
|---|
| 698 |
|
|---|
| 699 | query.prepare("DELETE p FROM recordedcredits p "
|
|---|
| 700 | "LEFT JOIN recorded r ON "
|
|---|
| 701 | " p.chanid = r.chanid AND p.starttime = r.progstart "
|
|---|
| 702 | "WHERE r.chanid IS NULL;");
|
|---|
| 703 | + myMonitor->hibernate();
|
|---|
| 704 | query.exec();
|
|---|
| 705 |
|
|---|
| 706 | query.prepare("DELETE FROM record WHERE (type = :SINGLE "
|
|---|
| 707 | @@ -2809,8 +2916,11 @@
|
|---|
| 708 | query.bindValue(":SINGLE", kSingleRecord);
|
|---|
| 709 | query.bindValue(":OVERRIDE", kOverrideRecord);
|
|---|
| 710 | query.bindValue(":DONTRECORD", kDontRecord);
|
|---|
| 711 | + myMonitor->hibernate();
|
|---|
| 712 | query.exec();
|
|---|
| 713 |
|
|---|
| 714 | + myMonitor->hibernate();
|
|---|
| 715 | +
|
|---|
| 716 | MSqlQuery findq(MSqlQuery::InitCon());
|
|---|
| 717 | findq.prepare("SELECT record.recordid FROM record "
|
|---|
| 718 | "LEFT JOIN oldfind ON oldfind.recordid = record.recordid "
|
|---|
| 719 | @@ -2822,16 +2932,23 @@
|
|---|
| 720 | {
|
|---|
| 721 | while (findq.next())
|
|---|
| 722 | {
|
|---|
| 723 | + myMonitor->hibernate();
|
|---|
| 724 | +
|
|---|
| 725 | query.prepare("DELETE FROM record WHERE recordid = :RECORDID;");
|
|---|
| 726 | query.bindValue(":RECORDID", findq.value(0).toInt());
|
|---|
| 727 | query.exec();
|
|---|
| 728 | }
|
|---|
| 729 | }
|
|---|
| 730 | +
|
|---|
| 731 | + myMonitor->hibernate();
|
|---|
| 732 | +
|
|---|
| 733 | query.prepare("DELETE FROM oldfind WHERE findid < TO_DAYS(NOW()) - 14;");
|
|---|
| 734 | query.exec();
|
|---|
| 735 |
|
|---|
| 736 | int cleanOldRecorded = gContext->GetNumSetting( "CleanOldRecorded", 10);
|
|---|
| 737 |
|
|---|
| 738 | + myMonitor->hibernate();
|
|---|
| 739 | +
|
|---|
| 740 | query.prepare("DELETE FROM oldrecorded WHERE "
|
|---|
| 741 | "recstatus <> :RECORDED AND duplicate = 0 AND "
|
|---|
| 742 | "endtime < DATE_SUB(CURRENT_DATE, INTERVAL :CLEAN DAY);");
|
|---|
| 743 | @@ -2856,6 +2973,8 @@
|
|---|
| 744 | int externally_handled = 0;
|
|---|
| 745 | int total_sources = sourcelist.size();
|
|---|
| 746 |
|
|---|
| 747 | + myMonitor->hibernate();
|
|---|
| 748 | +
|
|---|
| 749 | query.exec(QString("SELECT MAX(endtime) FROM program WHERE manualid=0;"));
|
|---|
| 750 | if (query.isActive() && query.size() > 0)
|
|---|
| 751 | {
|
|---|
| 752 | @@ -2951,6 +3070,8 @@
|
|---|
| 753 |
|
|---|
| 754 | for (int i = 0; i < grabdays; i++)
|
|---|
| 755 | {
|
|---|
| 756 | + myMonitor->hibernate();
|
|---|
| 757 | +
|
|---|
| 758 | // We need to check and see if the current date has changed
|
|---|
| 759 | // since we started in this loop. If it has, we need to adjust
|
|---|
| 760 | // the value of 'i' to compensate for this.
|
|---|
| 761 | @@ -3011,6 +3132,8 @@
|
|---|
| 762 | "WHERE c.sourceid = %3 "
|
|---|
| 763 | "GROUP BY c.chanid;";
|
|---|
| 764 |
|
|---|
| 765 | + myMonitor->hibernate();
|
|---|
| 766 | +
|
|---|
| 767 | if (query.exec(querystr.arg(i-1).arg(i).arg((*it).id)) &&
|
|---|
| 768 | query.isActive())
|
|---|
| 769 | {
|
|---|
| 770 | @@ -3030,6 +3153,8 @@
|
|---|
| 771 | .arg(query.value(1).toInt()));
|
|---|
| 772 | }
|
|---|
| 773 |
|
|---|
| 774 | + myMonitor->hibernate();
|
|---|
| 775 | +
|
|---|
| 776 | if (query.exec(querystr.arg(i).arg(i+1).arg((*it).id))
|
|---|
| 777 | && query.isActive())
|
|---|
| 778 | {
|
|---|
| 779 | @@ -3132,6 +3257,8 @@
|
|---|
| 780 | }
|
|---|
| 781 | else if (xmltv_grabber == "eitonly")
|
|---|
| 782 | {
|
|---|
| 783 | + myMonitor->hibernate();
|
|---|
| 784 | +
|
|---|
| 785 | VERBOSE(VB_IMPORTANT, "Source configured to use only the "
|
|---|
| 786 | "broadcasted guide data. Skipping.");
|
|---|
| 787 | externally_handled++;
|
|---|
| 788 | @@ -3144,6 +3271,8 @@
|
|---|
| 789 | xmltv_grabber == "none" ||
|
|---|
| 790 | xmltv_grabber == "")
|
|---|
| 791 | {
|
|---|
| 792 | + myMonitor->hibernate();
|
|---|
| 793 | +
|
|---|
| 794 | VERBOSE(VB_IMPORTANT,
|
|---|
| 795 | "Source configured with no grabber. Nothing to do.");
|
|---|
| 796 | externally_handled++;
|
|---|
| 797 | @@ -3168,6 +3297,8 @@
|
|---|
| 798 | if (only_update_channels && !need_post_grab_proc)
|
|---|
| 799 | return true;
|
|---|
| 800 |
|
|---|
| 801 | + myMonitor->hibernate();
|
|---|
| 802 | +
|
|---|
| 803 | query.exec(QString("SELECT MAX(endtime) FROM program WHERE manualid=0;"));
|
|---|
| 804 | if (query.isActive() && query.size() > 0)
|
|---|
| 805 | {
|
|---|
| 806 | @@ -3180,6 +3311,8 @@
|
|---|
| 807 |
|
|---|
| 808 | if (failures == 0)
|
|---|
| 809 | {
|
|---|
| 810 | + myMonitor->hibernate();
|
|---|
| 811 | +
|
|---|
| 812 | if ((GuideDataAfter == GuideDataBefore) &&
|
|---|
| 813 | (total_sources != externally_handled))
|
|---|
| 814 | status = "mythfilldatabase ran, but did not insert "
|
|---|
| 815 | @@ -3285,6 +3418,8 @@
|
|---|
| 816 | QString chanid, starttime, endtime, querystr;
|
|---|
| 817 | MSqlQuery query1(MSqlQuery::InitCon()), query2(MSqlQuery::InitCon());
|
|---|
| 818 |
|
|---|
| 819 | + myMonitor->hibernate();
|
|---|
| 820 | +
|
|---|
| 821 | querystr = "SELECT chanid, starttime, endtime FROM program "
|
|---|
| 822 | "WHERE (DATE_FORMAT(endtime,'%H%i') = '0000') "
|
|---|
| 823 | "ORDER BY chanid, starttime;";
|
|---|
| 824 | @@ -3302,6 +3437,8 @@
|
|---|
| 825 | chanid = query1.value(0).toString();
|
|---|
| 826 | endtime = query1.value(2).toString();
|
|---|
| 827 |
|
|---|
| 828 | + myMonitor->hibernate();
|
|---|
| 829 | +
|
|---|
| 830 | querystr = QString("SELECT chanid, starttime, endtime FROM program "
|
|---|
| 831 | "WHERE (DATE_FORMAT(starttime, '%%Y-%%m-%%d') = "
|
|---|
| 832 | "'%1') AND chanid = '%2' "
|
|---|
| 833 | @@ -3327,6 +3464,8 @@
|
|---|
| 834 | .arg(endtime)
|
|---|
| 835 | .arg(chanid)
|
|---|
| 836 | .arg(starttime);
|
|---|
| 837 | + myMonitor->hibernate();
|
|---|
| 838 | +
|
|---|
| 839 |
|
|---|
| 840 | if (!query2.exec(querystr))
|
|---|
| 841 | {
|
|---|
| 842 | @@ -3811,7 +3950,11 @@
|
|---|
| 843 | gContext->LogEntry("mythfilldatabase", LP_INFO,
|
|---|
| 844 | "Listings Download Started", "");
|
|---|
| 845 |
|
|---|
| 846 | -
|
|---|
| 847 | + JobMonitor jobMonitor(-1);
|
|---|
| 848 | +
|
|---|
| 849 | + myMonitor= &jobMonitor;
|
|---|
| 850 | + myMonitor->hibernate();
|
|---|
| 851 | +
|
|---|
| 852 | if (!grab_data)
|
|---|
| 853 | {
|
|---|
| 854 | }
|
|---|
| 855 | @@ -3821,6 +3964,8 @@
|
|---|
| 856 | }
|
|---|
| 857 | else if (from_file)
|
|---|
| 858 | {
|
|---|
| 859 | + myMonitor->hibernate();
|
|---|
| 860 | +
|
|---|
| 861 | QString status = "currently running.";
|
|---|
| 862 | QDateTime GuideDataBefore, GuideDataAfter;
|
|---|
| 863 |
|
|---|
| 864 | @@ -3829,10 +3974,14 @@
|
|---|
| 865 | "WHERE value='mythfilldatabaseLastRunStart'")
|
|---|
| 866 | .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm")));
|
|---|
| 867 |
|
|---|
| 868 | + myMonitor->hibernate();
|
|---|
| 869 | +
|
|---|
| 870 | query.exec(QString("UPDATE settings SET data ='%1' "
|
|---|
| 871 | "WHERE value='mythfilldatabaseLastRunStatus'")
|
|---|
| 872 | .arg(status));
|
|---|
| 873 |
|
|---|
| 874 | + myMonitor->hibernate();
|
|---|
| 875 | +
|
|---|
| 876 | query.exec(QString("SELECT MAX(endtime) FROM program;"));
|
|---|
| 877 | if (query.isActive() && query.size() > 0)
|
|---|
| 878 | {
|
|---|
| 879 | @@ -3846,12 +3995,18 @@
|
|---|
| 880 | if (!grabDataFromFile(fromfile_id, fromfile_name))
|
|---|
| 881 | return FILLDB_EXIT_GRAB_DATA_FAILED;
|
|---|
| 882 |
|
|---|
| 883 | + myMonitor->hibernate();
|
|---|
| 884 | +
|
|---|
| 885 | clearOldDBEntries();
|
|---|
| 886 |
|
|---|
| 887 | + myMonitor->hibernate();
|
|---|
| 888 | +
|
|---|
| 889 | query.exec(QString("UPDATE settings SET data ='%1' "
|
|---|
| 890 | "WHERE value='mythfilldatabaseLastRunEnd'")
|
|---|
| 891 | .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm")));
|
|---|
| 892 |
|
|---|
| 893 | + myMonitor->hibernate();
|
|---|
| 894 | +
|
|---|
| 895 | query.exec(QString("SELECT MAX(endtime) FROM program;"));
|
|---|
| 896 | if (query.isActive() && query.size() > 0)
|
|---|
| 897 | {
|
|---|
| 898 | @@ -3869,6 +4024,8 @@
|
|---|
| 899 | else
|
|---|
| 900 | status = "Successful.";
|
|---|
| 901 |
|
|---|
| 902 | + myMonitor->hibernate();
|
|---|
| 903 | +
|
|---|
| 904 | query.exec(QString("UPDATE settings SET data ='%1' "
|
|---|
| 905 | "WHERE value='mythfilldatabaseLastRunStatus'")
|
|---|
| 906 | .arg(status));
|
|---|
| 907 | @@ -3894,6 +4051,8 @@
|
|---|
| 908 | where = QString("WHERE sourceid = %1").arg(sourceid);
|
|---|
| 909 | }
|
|---|
| 910 |
|
|---|
| 911 | + myMonitor->hibernate();
|
|---|
| 912 | +
|
|---|
| 913 | QString querystr = QString("SELECT sourceid,name,xmltvgrabber,userid,"
|
|---|
| 914 | "password,lineupid "
|
|---|
| 915 | "FROM videosource ") + where +
|
|---|
| 916 | @@ -3955,24 +4114,34 @@
|
|---|
| 917 | return FILLDB_EXIT_OK;
|
|---|
| 918 | }
|
|---|
| 919 |
|
|---|
| 920 | + myMonitor->hibernate();
|
|---|
| 921 | +
|
|---|
| 922 | if (reset_iconmap)
|
|---|
| 923 | {
|
|---|
| 924 | ResetIconMap(reset_iconmap_icons);
|
|---|
| 925 | }
|
|---|
| 926 |
|
|---|
| 927 | + myMonitor->hibernate();
|
|---|
| 928 | +
|
|---|
| 929 | if (import_iconmap)
|
|---|
| 930 | {
|
|---|
| 931 | ImportIconMap(import_icon_map_filename);
|
|---|
| 932 | }
|
|---|
| 933 |
|
|---|
| 934 | + myMonitor->hibernate();
|
|---|
| 935 | +
|
|---|
| 936 | if (export_iconmap)
|
|---|
| 937 | {
|
|---|
| 938 | ExportIconMap(export_icon_map_filename);
|
|---|
| 939 | }
|
|---|
| 940 |
|
|---|
| 941 | + myMonitor->hibernate();
|
|---|
| 942 | +
|
|---|
| 943 | if (update_icon_map)
|
|---|
| 944 | {
|
|---|
| 945 | MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 946 | + myMonitor->hibernate();
|
|---|
| 947 | +
|
|---|
| 948 | query.exec("SELECT sourceid FROM videosource ORDER BY sourceid;");
|
|---|
| 949 | if (query.isActive() && query.size() > 0)
|
|---|
| 950 | {
|
|---|
| 951 | @@ -3983,6 +4152,8 @@
|
|---|
| 952 | }
|
|---|
| 953 | }
|
|---|
| 954 |
|
|---|
| 955 | + myMonitor->hibernate();
|
|---|
| 956 | +
|
|---|
| 957 | if (grab_data)
|
|---|
| 958 | {
|
|---|
| 959 | VERBOSE(VB_GENERAL, "Adjusting program database end times.");
|
|---|
| 960 | @@ -3997,6 +4168,8 @@
|
|---|
| 961 | "Listings Download Finished", "");
|
|---|
| 962 | }
|
|---|
| 963 |
|
|---|
| 964 | + myMonitor->hibernate();
|
|---|
| 965 | +
|
|---|
| 966 | if (grab_data)
|
|---|
| 967 | {
|
|---|
| 968 | VERBOSE(VB_GENERAL, "Marking generic episodes.");
|
|---|
| 969 | @@ -4011,6 +4184,8 @@
|
|---|
| 970 | QString(" Found %1").arg(query.numRowsAffected()));
|
|---|
| 971 | }
|
|---|
| 972 |
|
|---|
| 973 | + myMonitor->hibernate();
|
|---|
| 974 | +
|
|---|
| 975 | if (mark_repeats)
|
|---|
| 976 | {
|
|---|
| 977 | VERBOSE(VB_GENERAL, "Marking repeats.");
|
|---|
| 978 | @@ -4042,11 +4217,15 @@
|
|---|
| 979 |
|
|---|
| 980 | if (grab_data)
|
|---|
| 981 | {
|
|---|
| 982 | + myMonitor->hibernate();
|
|---|
| 983 | +
|
|---|
| 984 | MSqlQuery updt(MSqlQuery::InitCon());
|
|---|
| 985 | updt.exec("UPDATE program SET first = 0, last = 0;");
|
|---|
| 986 |
|
|---|
| 987 | VERBOSE(VB_GENERAL, "Marking episode first showings.");
|
|---|
| 988 |
|
|---|
| 989 | + myMonitor->hibernate();
|
|---|
| 990 | +
|
|---|
| 991 | MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 992 | query.exec("SELECT MIN(starttime),programid FROM program "
|
|---|
| 993 | "WHERE programid > '' GROUP BY programid;");
|
|---|
| 994 | @@ -4055,6 +4234,8 @@
|
|---|
| 995 | {
|
|---|
| 996 | while(query.next())
|
|---|
| 997 | {
|
|---|
| 998 | + myMonitor->hibernate();
|
|---|
| 999 | +
|
|---|
| 1000 | updt.prepare("UPDATE program set first = 1 "
|
|---|
| 1001 | "WHERE starttime = :STARTTIME "
|
|---|
| 1002 | " AND programid = :PROGRAMID;");
|
|---|
| 1003 | @@ -4065,6 +4246,8 @@
|
|---|
| 1004 | }
|
|---|
| 1005 | int found = query.numRowsAffected();
|
|---|
| 1006 |
|
|---|
| 1007 | + myMonitor->hibernate();
|
|---|
| 1008 | +
|
|---|
| 1009 | query.exec("SELECT MIN(starttime),title,subtitle,description "
|
|---|
| 1010 | "FROM program WHERE programid = '' "
|
|---|
| 1011 | "GROUP BY title,subtitle,description;");
|
|---|
| 1012 | @@ -4082,7 +4265,9 @@
|
|---|
| 1013 | updt.bindValue(":TITLE", query.value(1).toString());
|
|---|
| 1014 | updt.bindValue(":SUBTITLE", query.value(2).toString());
|
|---|
| 1015 | updt.bindValue(":DESCRIPTION", query.value(3).toString());
|
|---|
| 1016 | - updt.exec();
|
|---|
| 1017 | + myMonitor->hibernate();
|
|---|
| 1018 | +
|
|---|
| 1019 | + updt.exec();
|
|---|
| 1020 | }
|
|---|
| 1021 | }
|
|---|
| 1022 | found += query.numRowsAffected();
|
|---|
| 1023 | @@ -4090,6 +4275,8 @@
|
|---|
| 1024 |
|
|---|
| 1025 | VERBOSE(VB_GENERAL, "Marking episode last showings.");
|
|---|
| 1026 |
|
|---|
| 1027 | + myMonitor->hibernate();
|
|---|
| 1028 | +
|
|---|
| 1029 | query.exec("SELECT MAX(starttime),programid FROM program "
|
|---|
| 1030 | "WHERE programid > '' GROUP BY programid;");
|
|---|
| 1031 |
|
|---|
| 1032 | @@ -4102,11 +4289,14 @@
|
|---|
| 1033 | " AND programid = :PROGRAMID;");
|
|---|
| 1034 | updt.bindValue(":STARTTIME", query.value(0).toDateTime());
|
|---|
| 1035 | updt.bindValue(":PROGRAMID", query.value(1).toString());
|
|---|
| 1036 | + myMonitor->hibernate();
|
|---|
| 1037 | updt.exec();
|
|---|
| 1038 | }
|
|---|
| 1039 | }
|
|---|
| 1040 | found = query.numRowsAffected();
|
|---|
| 1041 |
|
|---|
| 1042 | + myMonitor->hibernate();
|
|---|
| 1043 | +
|
|---|
| 1044 | query.exec("SELECT MAX(starttime),title,subtitle,description "
|
|---|
| 1045 | "FROM program WHERE programid = '' "
|
|---|
| 1046 | "GROUP BY title,subtitle,description;");
|
|---|
| 1047 | @@ -4124,6 +4314,8 @@
|
|---|
| 1048 | updt.bindValue(":TITLE", query.value(1).toString());
|
|---|
| 1049 | updt.bindValue(":SUBTITLE", query.value(2).toString());
|
|---|
| 1050 | updt.bindValue(":DESCRIPTION", query.value(3).toString());
|
|---|
| 1051 | +
|
|---|
| 1052 | + myMonitor->hibernate();
|
|---|
| 1053 | updt.exec();
|
|---|
| 1054 | }
|
|---|
| 1055 | }
|
|---|
| 1056 | @@ -4131,6 +4323,8 @@
|
|---|
| 1057 | VERBOSE(VB_GENERAL, QString(" Found %1").arg(found));
|
|---|
| 1058 | }
|
|---|
| 1059 |
|
|---|
| 1060 | + myMonitor->hibernate();
|
|---|
| 1061 | +
|
|---|
| 1062 | if (1) // limit MSqlQuery's lifetime
|
|---|
| 1063 | {
|
|---|
| 1064 | MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 1065 | --- ./libs/libmythtv/jobqueue.cpp.hibernate 2006-07-30 15:53:33.000000000 -0400
|
|---|
| 1066 | +++ ./libs/libmythtv/jobqueue.cpp 2006-09-25 22:19:00.000000000 -0400
|
|---|
| 1067 | @@ -26,6 +26,10 @@
|
|---|
| 1068 | #define LOC QString("JobQueue: ")
|
|---|
| 1069 | #define LOC_ERR QString("JobQueue Error: ")
|
|---|
| 1070 |
|
|---|
| 1071 | +#include <stdio.h>
|
|---|
| 1072 | +#include <string.h>
|
|---|
| 1073 | +#include <stdlib.h>
|
|---|
| 1074 | +
|
|---|
| 1075 | JobQueue::JobQueue(bool master)
|
|---|
| 1076 | {
|
|---|
| 1077 | isMaster = master;
|
|---|
| 1078 | @@ -2168,4 +2172,122 @@
|
|---|
| 1079 | return JOB_NONE;
|
|---|
| 1080 | }
|
|---|
| 1081 |
|
|---|
| 1082 | +long JobMonitor::bogomips=0;
|
|---|
| 1083 | +
|
|---|
| 1084 | +/*
|
|---|
| 1085 | +** Add up all bogomips in /proc/cpuinfo
|
|---|
| 1086 | +*/
|
|---|
| 1087 | +
|
|---|
| 1088 | +long JobMonitor::getEstimatedBogoMips()
|
|---|
| 1089 | +{
|
|---|
| 1090 | + if (bogomips)
|
|---|
| 1091 | + return bogomips;
|
|---|
| 1092 | +
|
|---|
| 1093 | + FILE *fp=fopen("/proc/cpuinfo", "r");
|
|---|
| 1094 | + char linebuf[256];
|
|---|
| 1095 | +
|
|---|
| 1096 | + while (fp && fgets(linebuf, sizeof(linebuf), fp))
|
|---|
| 1097 | + {
|
|---|
| 1098 | + char *p=strtok(linebuf, " \t:");
|
|---|
| 1099 | +
|
|---|
| 1100 | + if (!p)
|
|---|
| 1101 | + continue;
|
|---|
| 1102 | +
|
|---|
| 1103 | + if (strcmp(p, "bogomips") == 0)
|
|---|
| 1104 | + {
|
|---|
| 1105 | + p=strtok(NULL, " \t:");
|
|---|
| 1106 | +
|
|---|
| 1107 | + if (p)
|
|---|
| 1108 | + bogomips += atol(p);
|
|---|
| 1109 | + }
|
|---|
| 1110 | + }
|
|---|
| 1111 | + if (fp) fclose(fp);
|
|---|
| 1112 | +
|
|---|
| 1113 | + return bogomips;
|
|---|
| 1114 | +}
|
|---|
| 1115 | +
|
|---|
| 1116 | +
|
|---|
| 1117 | +
|
|---|
| 1118 | +JobMonitor::JobMonitor(int jobIDArg)
|
|---|
| 1119 | + : jobID(jobIDArg), jobLastChk(time(NULL)), counter(1),
|
|---|
| 1120 | + doMonitor(gContext->GetNumSetting("JobHibernate", -1))
|
|---|
| 1121 | +{
|
|---|
| 1122 | + if (doMonitor < 0)
|
|---|
| 1123 | + doMonitor= getEstimatedBogoMips() < 3000;
|
|---|
| 1124 | +}
|
|---|
| 1125 | +
|
|---|
| 1126 | +JobMonitor::~JobMonitor()
|
|---|
| 1127 | +{
|
|---|
| 1128 | +}
|
|---|
| 1129 | +
|
|---|
| 1130 | +int JobMonitor::GetJobCmd()
|
|---|
| 1131 | +{
|
|---|
| 1132 | + int jobCmd;
|
|---|
| 1133 | +
|
|---|
| 1134 | + while ((jobCmd=JobQueue::GetJobCmd(jobID)) == JOB_RUN)
|
|---|
| 1135 | + {
|
|---|
| 1136 | + if (!doHibernateCheck())
|
|---|
| 1137 | + break;
|
|---|
| 1138 | + }
|
|---|
| 1139 | +
|
|---|
| 1140 | + return jobCmd;
|
|---|
| 1141 | +}
|
|---|
| 1142 | +
|
|---|
| 1143 | +void JobMonitor::hibernate()
|
|---|
| 1144 | +{
|
|---|
| 1145 | + while (doHibernateCheck())
|
|---|
| 1146 | + ;
|
|---|
| 1147 | +}
|
|---|
| 1148 | +
|
|---|
| 1149 | +bool JobMonitor::doHibernateCheck()
|
|---|
| 1150 | +{
|
|---|
| 1151 | + if (!doMonitor)
|
|---|
| 1152 | + return false;
|
|---|
| 1153 | +
|
|---|
| 1154 | + time_t t=time(NULL);
|
|---|
| 1155 | +
|
|---|
| 1156 | + if (t == jobLastChk)
|
|---|
| 1157 | + return false;
|
|---|
| 1158 | +
|
|---|
| 1159 | + if (t < jobLastChk)
|
|---|
| 1160 | + counter=0; // Time went backwards?
|
|---|
| 1161 | + else if (t - jobLastChk > counter)
|
|---|
| 1162 | + counter=0;
|
|---|
| 1163 | + else
|
|---|
| 1164 | + counter -= t - jobLastChk;
|
|---|
| 1165 | +
|
|---|
| 1166 | + jobLastChk=t;
|
|---|
| 1167 | +
|
|---|
| 1168 | + if (counter)
|
|---|
| 1169 | + return false;
|
|---|
| 1170 | +
|
|---|
| 1171 | + counter=5;
|
|---|
| 1172 | +
|
|---|
| 1173 | + bool isActive=false;
|
|---|
| 1174 | +
|
|---|
| 1175 | + MSqlQuery query(MSqlQuery::InitCon());
|
|---|
| 1176 | + query.prepare("SELECT recusage FROM inuseprograms");
|
|---|
| 1177 | + if (query.exec() && query.isActive() && query.size() > 0)
|
|---|
| 1178 | + while (query.next())
|
|---|
| 1179 | + {
|
|---|
| 1180 | + QString usage=
|
|---|
| 1181 | + query.value(0).toString().lower();
|
|---|
| 1182 | +
|
|---|
| 1183 | + if (usage == "player" ||
|
|---|
| 1184 | + usage == "recorder" ||
|
|---|
| 1185 | + usage.left(7) == "preview")
|
|---|
| 1186 | + isActive=true;
|
|---|
| 1187 | + }
|
|---|
| 1188 | +
|
|---|
| 1189 | + if (!isActive)
|
|---|
| 1190 | + return false;
|
|---|
| 1191 | + counter=1;
|
|---|
| 1192 | + if (jobID >= 0 &&
|
|---|
| 1193 | + !JobQueue::ChangeJobComment(jobID,
|
|---|
| 1194 | + "waiting for record/playback to stop"))
|
|---|
| 1195 | + return false;
|
|---|
| 1196 | + sleep(5);
|
|---|
| 1197 | + return true;
|
|---|
| 1198 | +}
|
|---|
| 1199 | +
|
|---|
| 1200 | /* vim: set expandtab tabstop=4 shiftwidth=4: */
|
|---|
| 1201 | --- ./libs/libmythtv/datadirect.cpp.hibernate 2006-08-08 14:14:52.000000000 -0400
|
|---|
| 1202 | +++ ./libs/libmythtv/datadirect.cpp 2006-09-25 22:47:21.000000000 -0400
|
|---|
| 1203 | @@ -44,7 +44,8 @@
|
|---|
| 1204 | static void update_channel_basic(uint sourceid, bool insert,
|
|---|
| 1205 | QString xmltvid, QString callsign,
|
|---|
| 1206 | QString name, uint freqid,
|
|---|
| 1207 | - QString chan_major, QString chan_minor);
|
|---|
| 1208 | + QString chan_major, QString chan_minor,
|
|---|
| 1209 | + JobMonitor &monitor);
|
|---|
| 1210 |
|
|---|
| 1211 | DataDirectStation::DataDirectStation(void) :
|
|---|
| 1212 | stationid(""), callsign(""),
|
|---|
| 1213 | @@ -224,6 +225,7 @@
|
|---|
| 1214 | query.bindValue(":AFFILIATE", curr_station.affiliate);
|
|---|
| 1215 | query.bindValue(":FCCCHANNUM", curr_station.fccchannelnumber);
|
|---|
| 1216 |
|
|---|
| 1217 | + parent.monitor.hibernate();
|
|---|
| 1218 | if (!query.exec())
|
|---|
| 1219 | MythContext::DBError("Inserting into dd_station", query);
|
|---|
| 1220 | }
|
|---|
| 1221 | @@ -245,6 +247,7 @@
|
|---|
| 1222 | query.bindValue(":DEVICE", curr_lineup.device);
|
|---|
| 1223 | query.bindValue(":POSTAL", curr_lineup.postal);
|
|---|
| 1224 |
|
|---|
| 1225 | + parent.monitor.hibernate();
|
|---|
| 1226 | if (!query.exec())
|
|---|
| 1227 | MythContext::DBError("Inserting into dd_lineup", query);
|
|---|
| 1228 | }
|
|---|
| 1229 | @@ -262,11 +265,13 @@
|
|---|
| 1230 | query.bindValue(":STATIONID", curr_lineupmap.stationid);
|
|---|
| 1231 | query.bindValue(":CHANNEL", curr_lineupmap.channel);
|
|---|
| 1232 | query.bindValue(":CHANNELMINOR",curr_lineupmap.channelMinor);
|
|---|
| 1233 | + parent.monitor.hibernate();
|
|---|
| 1234 | if (!query.exec())
|
|---|
| 1235 | MythContext::DBError("Inserting into dd_lineupmap", query);
|
|---|
| 1236 | }
|
|---|
| 1237 | else if (pqname == "schedule")
|
|---|
| 1238 | {
|
|---|
| 1239 | + parent.monitor.hibernate();
|
|---|
| 1240 | QDateTime endtime = curr_schedule.time.addSecs(
|
|---|
| 1241 | QTime().secsTo(curr_schedule.duration));
|
|---|
| 1242 |
|
|---|
| 1243 | @@ -354,6 +359,7 @@
|
|---|
| 1244 | query.bindValue(":SYNDNUM", curr_program.syndicatedEpisodeNumber);
|
|---|
| 1245 | query.bindValue(":ORIGAIRDATE", curr_program.originalAirDate);
|
|---|
| 1246 |
|
|---|
| 1247 | + parent.monitor.hibernate();
|
|---|
| 1248 | if (!query.exec())
|
|---|
| 1249 | MythContext::DBError("Inserting into dd_program", query);
|
|---|
| 1250 | }
|
|---|
| 1251 | @@ -377,6 +383,7 @@
|
|---|
| 1252 | query.bindValue(":SURNAME", curr_productioncrew.surname.utf8());
|
|---|
| 1253 | query.bindValue(":FULLNAME", fullname.utf8());
|
|---|
| 1254 |
|
|---|
| 1255 | + parent.monitor.hibernate();
|
|---|
| 1256 | if (!query.exec())
|
|---|
| 1257 | MythContext::DBError("Inserting into dd_productioncrew", query);
|
|---|
| 1258 |
|
|---|
| 1259 | @@ -394,6 +401,7 @@
|
|---|
| 1260 | query.bindValue(":CLASS", curr_genre.gclass.utf8());
|
|---|
| 1261 | query.bindValue(":RELEVANCE", curr_genre.relevance);
|
|---|
| 1262 |
|
|---|
| 1263 | + parent.monitor.hibernate();
|
|---|
| 1264 | if (!query.exec())
|
|---|
| 1265 | MythContext::DBError("Inserting into dd_genre", query);
|
|---|
| 1266 | }
|
|---|
| 1267 | @@ -450,6 +458,7 @@
|
|---|
| 1268 |
|
|---|
| 1269 | query.prepare(querystr);
|
|---|
| 1270 |
|
|---|
| 1271 | + parent.monitor.hibernate();
|
|---|
| 1272 | if (!query.exec())
|
|---|
| 1273 | {
|
|---|
| 1274 | MythContext::DBError("Updating DataDirect Status Message",
|
|---|
| 1275 | @@ -535,7 +544,8 @@
|
|---|
| 1276 | userid(user), password(pass),
|
|---|
| 1277 | inputfilename(""), tmpPostFile(""),
|
|---|
| 1278 | tmpResultFile(""), cookieFile(""),
|
|---|
| 1279 | - cookieFileDT()
|
|---|
| 1280 | + cookieFileDT(),
|
|---|
| 1281 | + monitor(-1)
|
|---|
| 1282 | {
|
|---|
| 1283 | DataDirectURLs urls0(
|
|---|
| 1284 | "Tribune Media Zap2It",
|
|---|
| 1285 | @@ -560,7 +570,8 @@
|
|---|
| 1286 | void DataDirectProcessor::UpdateStationViewTable(QString lineupid)
|
|---|
| 1287 | {
|
|---|
| 1288 | MSqlQuery query(MSqlQuery::DDCon());
|
|---|
| 1289 | -
|
|---|
| 1290 | +
|
|---|
| 1291 | + monitor.hibernate();
|
|---|
| 1292 | if (!query.exec("TRUNCATE TABLE dd_v_station;"))
|
|---|
| 1293 | MythContext::DBError("Truncating temporary table dd_v_station", query);
|
|---|
| 1294 |
|
|---|
| 1295 | @@ -578,6 +589,7 @@
|
|---|
| 1296 |
|
|---|
| 1297 | query.bindValue(":LINEUP", lineupid);
|
|---|
| 1298 |
|
|---|
| 1299 | + monitor.hibernate();
|
|---|
| 1300 | if (!query.exec())
|
|---|
| 1301 | MythContext::DBError("Populating temporary table dd_v_station", query);
|
|---|
| 1302 | }
|
|---|
| 1303 | @@ -586,6 +598,7 @@
|
|---|
| 1304 | {
|
|---|
| 1305 | MSqlQuery query(MSqlQuery::DDCon());
|
|---|
| 1306 |
|
|---|
| 1307 | + monitor.hibernate();
|
|---|
| 1308 | if (!query.exec("TRUNCATE TABLE dd_v_program;"))
|
|---|
| 1309 | MythContext::DBError("Truncating temporary table dd_v_program", query);
|
|---|
| 1310 |
|
|---|
| 1311 | @@ -617,9 +630,13 @@
|
|---|
| 1312 | if (!query.exec())
|
|---|
| 1313 | MythContext::DBError("Populating temporary table dd_v_program", query);
|
|---|
| 1314 |
|
|---|
| 1315 | + monitor.hibernate();
|
|---|
| 1316 | +
|
|---|
| 1317 | if (!query.exec("ANALYZE TABLE dd_v_program;"))
|
|---|
| 1318 | MythContext::DBError("Analyzing table dd_v_program", query);
|
|---|
| 1319 |
|
|---|
| 1320 | + monitor.hibernate();
|
|---|
| 1321 | +
|
|---|
| 1322 | if (!query.exec("ANALYZE TABLE dd_productioncrew;"))
|
|---|
| 1323 | MythContext::DBError("Analyzing table dd_productioncrew", query);
|
|---|
| 1324 | }
|
|---|
| 1325 | @@ -643,6 +660,7 @@
|
|---|
| 1326 | "WHERE channel.chanid IS NULL");
|
|---|
| 1327 | query.bindValue(":SOURCEID", sourceid);
|
|---|
| 1328 |
|
|---|
| 1329 | + monitor.hibernate();
|
|---|
| 1330 | if (!query.exec())
|
|---|
| 1331 | {
|
|---|
| 1332 | MythContext::DBError("Selecting new channels", query);
|
|---|
| 1333 | @@ -660,7 +678,7 @@
|
|---|
| 1334 |
|
|---|
| 1335 | update_channel_basic(sourceid, insert_channels,
|
|---|
| 1336 | xmltvid, callsign, name, freqid,
|
|---|
| 1337 | - chan_major, chan_minor);
|
|---|
| 1338 | + chan_major, chan_minor, monitor);
|
|---|
| 1339 |
|
|---|
| 1340 | if (!insert_channels)
|
|---|
| 1341 | {
|
|---|
| 1342 | @@ -675,6 +693,7 @@
|
|---|
| 1343 |
|
|---|
| 1344 | bool DataDirectProcessor::UpdateChannelsUnsafe(uint sourceid)
|
|---|
| 1345 | {
|
|---|
| 1346 | + monitor.hibernate();
|
|---|
| 1347 | MSqlQuery dd_station_info(MSqlQuery::DDCon());
|
|---|
| 1348 | dd_station_info.prepare(
|
|---|
| 1349 | "SELECT callsign, stationname, stationid,"
|
|---|
| 1350 | @@ -713,6 +732,7 @@
|
|---|
| 1351 | chan_update_q.bindValue(":MAJORCHAN", chan_major.toUInt());
|
|---|
| 1352 | chan_update_q.bindValue(":MINORCHAN", chan_minor.toUInt());
|
|---|
| 1353 |
|
|---|
| 1354 | + monitor.hibernate();
|
|---|
| 1355 | if (!chan_update_q.exec())
|
|---|
| 1356 | {
|
|---|
| 1357 | MythContext::DBError("Updating channel table",
|
|---|
| 1358 | @@ -903,14 +923,17 @@
|
|---|
| 1359 | QString querystr =
|
|---|
| 1360 | QString("UPDATE settings SET data = '%1' WHERE value = '%2';");
|
|---|
| 1361 |
|
|---|
| 1362 | + monitor.hibernate();
|
|---|
| 1363 | query.prepare(querystr.arg(minhr).arg("MythFillMinHour"));
|
|---|
| 1364 | if (!query.exec())
|
|---|
| 1365 | MythContext::DBError("Updating DataDirect MythFillMinHour", query);
|
|---|
| 1366 |
|
|---|
| 1367 | + monitor.hibernate();
|
|---|
| 1368 | query.prepare(querystr.arg(maxhr).arg("MythFillMaxHour"));
|
|---|
| 1369 | if (!query.exec())
|
|---|
| 1370 | MythContext::DBError("Updating DataDirect MythFillMaxHour", query);
|
|---|
| 1371 |
|
|---|
| 1372 | + monitor.hibernate();
|
|---|
| 1373 | query.prepare(querystr.arg(NextSuggestedTime.toString(Qt::ISODate))
|
|---|
| 1374 | .arg("MythFillSuggestedRunTime"));
|
|---|
| 1375 |
|
|---|
| 1376 | @@ -978,6 +1001,8 @@
|
|---|
| 1377 | void DataDirectProcessor::CreateATempTable(const QString &ptablename,
|
|---|
| 1378 | const QString &ptablestruct)
|
|---|
| 1379 | {
|
|---|
| 1380 | + monitor.hibernate();
|
|---|
| 1381 | +
|
|---|
| 1382 | MSqlQuery query(MSqlQuery::DDCon());
|
|---|
| 1383 | QString querystr;
|
|---|
| 1384 | querystr = "CREATE TEMPORARY TABLE IF NOT EXISTS " + ptablename + " " +
|
|---|
| 1385 | @@ -988,6 +1013,7 @@
|
|---|
| 1386 |
|
|---|
| 1387 | querystr = "TRUNCATE TABLE " + ptablename + ";";
|
|---|
| 1388 |
|
|---|
| 1389 | + monitor.hibernate();
|
|---|
| 1390 | if (!query.exec(querystr))
|
|---|
| 1391 | MythContext::DBError("Truncating temporary table", query);
|
|---|
| 1392 | }
|
|---|
| 1393 | @@ -1404,6 +1430,7 @@
|
|---|
| 1394 | "WHERE sourceid = :SOURCEID");
|
|---|
| 1395 | query.bindValue(":SOURCEID", sourceid);
|
|---|
| 1396 |
|
|---|
| 1397 | + monitor.hibernate();
|
|---|
| 1398 | if (!query.exec() || !query.isActive())
|
|---|
| 1399 | {
|
|---|
| 1400 | MythContext::DBError("Selecting existing channels", query);
|
|---|
| 1401 | @@ -1798,7 +1825,8 @@
|
|---|
| 1402 | static void update_channel_basic(uint sourceid, bool insert,
|
|---|
| 1403 | QString xmltvid, QString callsign,
|
|---|
| 1404 | QString name, uint freqid,
|
|---|
| 1405 | - QString chan_major, QString chan_minor)
|
|---|
| 1406 | + QString chan_major, QString chan_minor,
|
|---|
| 1407 | + JobMonitor &monitor)
|
|---|
| 1408 | {
|
|---|
| 1409 | callsign = (callsign.isEmpty()) ? name : callsign;
|
|---|
| 1410 |
|
|---|
| 1411 | @@ -1807,6 +1835,7 @@
|
|---|
| 1412 | sourceid, chan_major, chan_minor, tvformat, freqid);
|
|---|
| 1413 |
|
|---|
| 1414 | // First check if channel already in DB, but without xmltvid
|
|---|
| 1415 | + monitor.hibernate();
|
|---|
| 1416 | MSqlQuery query(MSqlQuery::DDCon());
|
|---|
| 1417 | query.prepare("SELECT chanid FROM channel "
|
|---|
| 1418 | "WHERE sourceid = :SOURCEID AND xmltvid = 0 AND "
|
|---|
| 1419 | @@ -1835,6 +1864,7 @@
|
|---|
| 1420 | "SET xmltvid = :XMLTVID "
|
|---|
| 1421 | "WHERE chanid = :CHANID AND sourceid = :SOURCEID");
|
|---|
| 1422 |
|
|---|
| 1423 | + monitor.hibernate();
|
|---|
| 1424 | while (query.next())
|
|---|
| 1425 | {
|
|---|
| 1426 | uint chanid = query.value(0).toInt();
|
|---|
| 1427 | @@ -1860,12 +1890,15 @@
|
|---|
| 1428 | get_atsc_stuff(channum, sourceid, freqid,
|
|---|
| 1429 | majorC, minorC, freq);
|
|---|
| 1430 |
|
|---|
| 1431 | + monitor.hibernate();
|
|---|
| 1432 | if (minorC > 0 && freq >= 0)
|
|---|
| 1433 | mplexid = ChannelUtil::CreateMultiplex(sourceid, "atsc", freq, "8vsb");
|
|---|
| 1434 |
|
|---|
| 1435 | + monitor.hibernate();
|
|---|
| 1436 | if ((mplexid > 0) || (minorC == 0))
|
|---|
| 1437 | chanid = ChannelUtil::CreateChanID(sourceid, channum);
|
|---|
| 1438 |
|
|---|
| 1439 | + monitor.hibernate();
|
|---|
| 1440 | if (chanid > 0)
|
|---|
| 1441 | {
|
|---|
| 1442 | QString icon = "";
|
|---|
| 1443 | --- ./libs/libmythtv/jobqueue.h.hibernate 2006-07-15 16:13:46.000000000 -0400
|
|---|
| 1444 | +++ ./libs/libmythtv/jobqueue.h 2006-09-25 22:19:00.000000000 -0400
|
|---|
| 1445 | @@ -219,6 +219,30 @@
|
|---|
| 1446 | QMutex queueThreadCondLock;
|
|---|
| 1447 | };
|
|---|
| 1448 |
|
|---|
| 1449 | +#include <time.h>
|
|---|
| 1450 | +
|
|---|
| 1451 | +class JobMonitor {
|
|---|
| 1452 | + int jobID;
|
|---|
| 1453 | + time_t jobLastChk;
|
|---|
| 1454 | + int counter;
|
|---|
| 1455 | +
|
|---|
| 1456 | + int doMonitor;
|
|---|
| 1457 | +
|
|---|
| 1458 | + static long bogomips;
|
|---|
| 1459 | +
|
|---|
| 1460 | + public:
|
|---|
| 1461 | + JobMonitor(int jobID);
|
|---|
| 1462 | + ~JobMonitor();
|
|---|
| 1463 | +
|
|---|
| 1464 | + int GetJobCmd();
|
|---|
| 1465 | + void hibernate();
|
|---|
| 1466 | +
|
|---|
| 1467 | + static long getEstimatedBogoMips();
|
|---|
| 1468 | +
|
|---|
| 1469 | + private:
|
|---|
| 1470 | + bool doHibernateCheck();
|
|---|
| 1471 | +};
|
|---|
| 1472 | +
|
|---|
| 1473 | #endif
|
|---|
| 1474 |
|
|---|
| 1475 | /* vim: set expandtab tabstop=4 shiftwidth=4: */
|
|---|
| 1476 | --- libs/libmythtv/datadirect.h.hibernate 2006-07-15 14:26:08.000000000 -0400
|
|---|
| 1477 | +++ libs/libmythtv/datadirect.h 2006-09-29 22:01:04.000000000 -0400
|
|---|
| 1478 | @@ -7,6 +7,9 @@
|
|---|
| 1479 | #include <qmap.h>
|
|---|
| 1480 |
|
|---|
| 1481 | #include <vector>
|
|---|
| 1482 | +
|
|---|
| 1483 | +#include "jobqueue.h"
|
|---|
| 1484 | +
|
|---|
| 1485 | using namespace std;
|
|---|
| 1486 |
|
|---|
| 1487 | enum DD_PROVIDERS
|
|---|
| 1488 | @@ -308,12 +311,12 @@
|
|---|
| 1489 | void SetInputFile(const QString &file) { inputfilename = file; }
|
|---|
| 1490 |
|
|---|
| 1491 | // static commands (these update temp DB tables)
|
|---|
| 1492 | - static void UpdateStationViewTable(QString lineupid);
|
|---|
| 1493 | - static void UpdateProgramViewTable(uint sourceid);
|
|---|
| 1494 | + void UpdateStationViewTable(QString lineupid);
|
|---|
| 1495 | + void UpdateProgramViewTable(uint sourceid);
|
|---|
| 1496 |
|
|---|
| 1497 | // static commands (these update regular DB tables from temp DB tables)
|
|---|
| 1498 | - static int UpdateChannelsSafe(uint sourceid, bool insert_channels);
|
|---|
| 1499 | - static bool UpdateChannelsUnsafe(uint sourceid);
|
|---|
| 1500 | + int UpdateChannelsSafe(uint sourceid, bool insert_channels);
|
|---|
| 1501 | + bool UpdateChannelsUnsafe(uint sourceid);
|
|---|
| 1502 |
|
|---|
| 1503 | private:
|
|---|
| 1504 | void CreateTempTables(void);
|
|---|
| 1505 | @@ -358,6 +361,9 @@
|
|---|
| 1506 | QString tmpResultFile;
|
|---|
| 1507 | QString cookieFile;
|
|---|
| 1508 | QDateTime cookieFileDT;
|
|---|
| 1509 | +
|
|---|
| 1510 | + public:
|
|---|
| 1511 | + JobMonitor monitor;
|
|---|
| 1512 | };
|
|---|
| 1513 |
|
|---|
| 1514 | #endif
|
|---|