Ticket #4733: eitcrash.diff
File eitcrash.diff, 7.3 KB (added by , 16 years ago) |
---|
-
libs/libmythtv/eitscanner.h
2 2 #ifndef EITSCANNER_H 3 3 #define EITSCANNER_H 4 4 5 // C includes6 #include <pthread.h>7 8 5 // Qt includes 9 6 #include <qmutex.h> 10 7 #include <qobject.h> 11 8 #include <qdatetime.h> 12 9 #include <qstringlist.h> 13 10 #include <qwaitcondition.h> 11 #include <qthread.h> 14 12 15 13 class TVRec; 16 14 class ChannelBase; … … 27 25 virtual void SetEITRate(float rate) = 0; 28 26 }; 29 27 28 class EITScanner; 29 30 class EITThread : public QThread 31 { 32 public: 33 virtual void run(); 34 EITScanner *scanner; 35 }; 36 30 37 class EITScanner 31 38 { 39 friend class EITThread; 40 32 41 public: 33 42 EITScanner(uint cardnum); 34 43 ~EITScanner() { TeardownAll(); } … … 39 48 void StartActiveScan(TVRec*, uint max_seconds_per_source, 40 49 bool ignore_source); 41 50 42 void StopActiveScan(void); 51 void StopActiveScan(void); 43 52 53 protected: 54 void RunEventLoop(void); 55 44 56 private: 45 57 void TeardownAll(void); 46 void RunEventLoop(void);47 58 static void *SpawnEventLoop(void*); 48 59 static void RescheduleRecordings(void); 49 60 … … 52 63 EITSource *eitSource; 53 64 54 65 EITHelper *eitHelper; 55 pthread_teventThread;66 EITThread eventThread; 56 67 bool exitThread; 57 68 QWaitCondition exitThreadCond; 58 69 -
libs/libmythtv/tv_rec.cpp
259 259 overRecordSecCat = gContext->GetNumSetting("CategoryOverTime") * 60; 260 260 overRecordCategory= gContext->GetSetting("OverTimeCategory"); 261 261 262 pthread_create(&event_thread, NULL, EventThread, this); 262 tvthread.thetv = this; 263 tvthread.start(); 263 264 264 265 WaitForEventThreadSleep(); 265 266 … … 288 289 if (HasFlags(kFlagRunMainLoop)) 289 290 { 290 291 ClearFlags(kFlagRunMainLoop); 291 pthread_join(event_thread, NULL);292 tvthread.wait(); 292 293 } 293 294 294 295 TeardownSignalMonitor(); … … 1088 1089 gContext->dispatch(me); 1089 1090 1090 1091 recorder->StopRecording(); 1091 pthread_join(recorder_thread, NULL);1092 recthread.wait(); 1092 1093 } 1093 1094 ClearFlags(kFlagRecorderRunning); 1094 1095 … … 1239 1240 #endif // USING_V4L 1240 1241 } 1241 1242 1242 /** \fn TV Rec::EventThread(void*)1243 * \brief Thunk that allows event pthread to call RunTV().1243 /** \fn TVThread::run(void) 1244 * \brief Thunk that allows event Qthread to call RunTV(). 1244 1245 */ 1245 void *TVRec::EventThread(void *param)1246 void TVThread::run(void) 1246 1247 { 1247 TVRec *thetv = (TVRec *)param;1248 1248 thetv->RunTV(); 1249 return NULL;1250 1249 } 1251 1250 1252 /** \fn TVRec::RecorderThread(void*)1253 * \brief Thunk that allows recorder pthread to1251 /** \fn RECThread::run(void) 1252 * \brief Thunk that allows recorder Qthread to 1254 1253 * call RecorderBase::StartRecording(). 1255 1254 */ 1256 void *TVRec::RecorderThread(void *param)1255 void RECThread::run(void) 1257 1256 { 1258 RecorderBase *recorder = (RecorderBase *)param;1259 1257 recorder->StartRecording(); 1260 return NULL;1261 1258 } 1262 1259 1263 1260 bool get_use_eit(uint cardid) … … 4003 4000 } 4004 4001 #endif 4005 4002 4006 pthread_create(&recorder_thread, NULL, TVRec::RecorderThread, recorder); 4003 recthread.recorder = recorder; 4004 recthread.start(); 4007 4005 4008 4006 // Wait for recorder to start. 4009 4007 stateChangeLock.unlock(); -
libs/libmythtv/eitscanner.cpp
36 36 QStringList langPref = iso639_get_language_list(); 37 37 eitHelper->SetLanguagePreferences(langPref); 38 38 39 pthread_create(&eventThread, NULL, SpawnEventLoop, this); 39 // Start scanner with Idle scheduling priority, to avoid problems with recordings. 40 eventThread.scanner = this; 41 eventThread.start(QThread::IdlePriority); 40 42 } 41 43 42 44 void EITScanner::TeardownAll(void) … … 46 48 { 47 49 exitThread = true; 48 50 exitThreadCond.wakeAll(); 49 pthread_join(eventThread, NULL);51 eventThread.wait(); 50 52 } 51 53 52 54 if (eitHelper) … … 56 58 } 57 59 } 58 60 59 /** \fn EIT Scanner::SpawnEventLoop(void*)60 * \brief Thunk that allows scanner _thread pthread to61 /** \fn EITThread::run(void) 62 * \brief Thunk that allows scanner Qthread to 61 63 * call EITScanner::RunScanner(). 62 64 */ 63 void *EITScanner::SpawnEventLoop(void *param)65 void EITThread::run(void) 64 66 { 65 // Lower scheduling priority, to avoid problems with recordings.66 if (setpriority(PRIO_PROCESS, 0, 19))67 VERBOSE(VB_IMPORTANT, LOC + "Setting priority failed." + ENO);68 EITScanner *scanner = (EITScanner*) param;69 67 scanner->RunEventLoop(); 70 return NULL;71 68 } 72 69 73 70 /** \fn EITScanner::RunEventLoop() -
libs/libmythtv/tv_rec.h
2 2 #define TVREC_H 3 3 4 4 #include <qstring.h> 5 #include < pthread.h>5 #include <qthread.h> 6 6 #include <qdatetime.h> 7 7 #include <qvaluelist.h> 8 8 #include <qptrlist.h> … … 149 149 }; 150 150 typedef QMap<uint,PendingInfo> PendingMap; 151 151 152 class RECThread : public QThread 153 { 154 public: 155 virtual void run(); 156 RecorderBase *recorder; 157 }; 158 159 class MPUBLIC TVRec; 160 161 class TVThread : public QThread 162 { 163 public: 164 virtual void run(); 165 TVRec *thetv; 166 }; 167 152 168 class MPUBLIC TVRec : public QObject 153 169 { 154 170 friend class TuningRequest; 171 friend class TVThread; 155 172 Q_OBJECT 156 173 public: 157 174 TVRec(int capturecardnum); … … 332 349 SignalMonitor *signalMonitor; 333 350 EITScanner *scanner; 334 351 335 // Various threads336 /// Event processing thread, runs RunTV().337 pthread_t event_thread;338 /// Recorder thread, runs RecorderBase::StartRecording()339 pthread_t recorder_thread;340 341 352 // Configuration variables from database 342 353 bool eitIgnoresSource; 343 354 bool transcodeFirst; … … 400 411 static QMutex cardsLock; 401 412 static QMap<uint,TVRec*> cards; 402 413 414 // Various threads 415 /// Recorder thread, runs RecorderBase::StartRecording() 416 RECThread recthread; 417 418 /// Event processing thread, runs RunTV(). 419 TVThread tvthread; 420 403 421 public: 404 422 static const uint kSignalMonitoringRate; 405 423 -
libs/libmythtv/mpeg/pespacket.cpp
48 48 49 49 if (ccExp == cc) 50 50 { 51 if (_pesdataSize + payloadSize >= _allocSize) 51 uint sz = _allocSize; 52 53 while (_pesdataSize + payloadSize >= sz) 52 54 { 53 uint sz = (((_allocSize * 2) + 4095) / 4096) * 4096; 55 if (sz > 0) 56 { 57 sz = (((sz * 2) + 4095) / 4096) * 4096; 58 } 59 else 60 { 61 sz = 4096; 62 } 63 } 64 65 if (sz != _allocSize) 66 { 54 67 unsigned char *nbuf = pes_alloc(sz); 68 69 if (!nbuf) 70 { 71 return true; 72 } 73 55 74 memcpy(nbuf, _fullbuffer, _pesdataSize); 56 75 pes_free(_fullbuffer); 57 76 _fullbuffer = nbuf;