Ticket #2019: thread_conditions.patch
File thread_conditions.patch, 4.0 KB (added by , 19 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/tv_play.h
567 567 /// runs pipnvp's NuppelVideoPlayer::StartPlaying(). 568 568 pthread_t pipdecode; 569 569 570 /// Condition to signal that the Event thread is up and running 571 QWaitCondition mainLoopCond; 572 QMutex mainLoopCondLock; 573 570 574 // Constants 571 575 static const int kInitFFRWSpeed; ///< 1x, default to normal speed 572 576 static const int kMuteTimeout; ///< Channel changing mute timeout in msec -
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 -
libs/libmythtv/RingBuffer.cpp
629 629 { 630 630 readaheadrunning = false; 631 631 632 readAheadRunningCondLock.lock(); 632 633 pthread_create(&reader, NULL, StartReader, this); 633 634 while (!readaheadrunning) 635 usleep(50); 634 readAheadRunningCond.wait(&readAheadRunningCondLock); 635 readAheadRunningCondLock.unlock(); 636 636 } 637 637 638 638 /** \fn RingBuffer::KillReadAheadThread(void) … … 730 730 totfree = ReadBufFree(); 731 731 732 732 readaheadrunning = true; 733 readAheadRunningCondLock.lock(); 734 readAheadRunningCond.wakeAll(); 735 readAheadRunningCondLock.unlock(); 733 736 while (readaheadrunning) 734 737 { 735 738 if (pausereadthread || writemode) -
libs/libmythtv/tv_play.cpp
484 484 qApp->processEvents(); 485 485 } 486 486 487 mainLoopCondLock.lock(); 487 488 pthread_create(&event, NULL, EventThread, this); 489 mainLoopCond.wait(&mainLoopCondLock); 490 mainLoopCondLock.unlock(); 488 491 489 while (!runMainLoop && !IsErrored())490 usleep(50);491 492 492 return !IsErrored(); 493 493 } 494 494 … … 1503 1503 runMainLoop = true; 1504 1504 exitPlayer = false; 1505 1505 1506 mainLoopCondLock.lock(); 1507 mainLoopCond.wakeAll(); 1508 mainLoopCondLock.unlock(); 1509 1506 1510 while (runMainLoop) 1507 1511 { 1508 1512 stateLock.lock(); -
libs/libmythtv/RingBuffer.h
173 173 174 174 long long readAdjust; 175 175 176 /// Condition to signal that the read ahead thread is running 177 QWaitCondition readAheadRunningCond; 178 QMutex readAheadRunningCondLock; 179 176 180 // constants 177 181 static const uint kBufferSize; 178 182 static const uint kReadTestSize;