Ticket #10541: 10541-v2.patch

File 10541-v2.patch, 2.4 KB (added by danielk, 9 years ago)
  • mythtv/libs/libmythtv/eitscanner.cpp

    diff --git a/mythtv/libs/libmythtv/eitscanner.cpp b/mythtv/libs/libmythtv/eitscanner.cpp
    index 6135e08..80041d5 100644
    a b void EITScanner::run(void) 
    7575    static const float rt[] = { 0.0f, 0.2f, 0.4f, 0.6f, 0.8f, };
    7676
    7777    lock.lock();
    78     exitThread = false;
    7978
    8079    MythTimer t;
    8180    uint eitCount = 0;
    void EITScanner::run(void) 
    149148        }
    150149
    151150        lock.lock();
    152         if (!exitThread)
     151        if ((activeScan || activeScanStopped) && !exitThread)
    153152            exitThreadCond.wait(&lock, 400); // sleep up to 400 ms.
     153
     154        if (!activeScan && !activeScanStopped)
     155        {
     156            activeScanStopped = true;
     157            activeScanCond.wakeAll();
     158        }
    154159    }
     160    activeScanStopped = true;
     161    activeScanCond.wakeAll();
    155162    lock.unlock();
    156163}
    157164
    void EITScanner::StartActiveScan(TVRec *_rec, uint max_seconds_per_source) 
    271278        // Add a little randomness to trigger time so multiple
    272279        // cards will have a staggered channel changing time.
    273280        activeScanTrigTime += random() % 29;
     281        activeScanStopped = false;
    274282        activeScan = true;
    275283    }
    276284}
    277285
    278 void EITScanner::StopActiveScan()
     286void EITScanner::StopActiveScan(void)
    279287{
     288    QMutexLocker locker(&lock);
     289
     290    activeScanStopped = false;
    280291    activeScan = false;
    281     rec = NULL;
     292    exitThreadCond.wakeAll();
     293
     294    locker.unlock();
    282295    StopPassiveScan();
     296    locker.relock();
     297
     298    while (!activeScan && !activeScanStopped)
     299        activeScanCond.wait(&lock, 100);
     300
     301    rec = NULL;
    283302}
  • mythtv/libs/libmythtv/eitscanner.h

    diff --git a/mythtv/libs/libmythtv/eitscanner.h b/mythtv/libs/libmythtv/eitscanner.h
    index 36dd4d9..3351aae 100644
    a b class EITScanner : public QRunnable 
    5454
    5555    EITHelper       *eitHelper;
    5656    MThread         *eventThread;
    57     bool             exitThread;
    58     QWaitCondition   exitThreadCond;
     57    volatile bool    exitThread;
     58    QWaitCondition   exitThreadCond; // protected by lock
    5959
    6060    TVRec           *rec;
    61     bool             activeScan;
     61    volatile bool    activeScan;
     62    volatile bool    activeScanStopped; // protected by lock
     63    QWaitCondition   activeScanCond; // protected by lock
    6264    QDateTime        activeScanNextTrig;
    6365    uint             activeScanTrigTime;
    6466    QStringList      activeScanChannels;