Ticket #2022: analogscan_threadcond.patch
File analogscan_threadcond.patch, 1.4 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/analogscan.h
35 35 36 36 #include <qobject.h> 37 37 #include <qstring.h> 38 #include <qmutex.h> 39 #include <qwaitcondition.h> 38 40 #include <pthread.h> 39 41 #include "frequencies.h" 40 42 … … 90 92 /** @brief Scanning thread*/ 91 93 pthread_t thread; 92 94 95 /** @brief Condition to signal that the scanning thread is running */ 96 QWaitCondition scanThreadCond; 97 QMutex scanThreadCondLock; 98 93 99 /** @brief Actual scanning proc */ 94 100 void doScan(); 95 101 /** @brief Actual thread proc , calls doScan*/ -
libs/libmythtv/analogscan.cpp
76 76 void AnalogScan::doScan() 77 77 { 78 78 fRunning = true; 79 scanThreadCondLock.lock(); 80 scanThreadCond.wakeAll(); 81 scanThreadCondLock.unlock(); 79 82 80 83 Channel *channel = NULL; 81 84 struct CHANLIST *flist = NULL; … … 156 159 } 157 160 158 161 if (!fRunning) 162 { 163 scanThreadCondLock.lock(); 159 164 pthread_create(&thread, NULL, spawn, this); 160 while (!fRunning) 161 usleep(50); 165 scanThreadCond.wait(&scanThreadCondLock); 166 scanThreadCondLock.unlock(); 167 } 168 162 169 return true; 163 170 } 164 171