Ticket #5229: out_fix_iptv_scanner.diff

File out_fix_iptv_scanner.diff, 3.8 KB (added by laurent@…, 18 years ago)

Patch to fix iptv scanner

  • libs/libmythtv/iptv/iptvchannelfetcher.cpp

     
    1515#define LOC QString("IPTVChanFetch: ")
    1616#define LOC_ERR QString("IPTVChanFetch, Error: ")
    1717
    18 void *run_scan_thunk(void*);
    1918
    2019static bool parse_chan_info(const QString   &rawdata,
    2120                            IPTVChannelInfo &info,
     
    5756        _stop_now = true;
    5857        _lock.unlock();
    5958
    60         pthread_join(_thread, NULL);
     59             _scannerThread.wait();
    6160        return;
    6261    }
    6362
    6463    _lock.unlock();
    6564}
    6665
     66/** \fn EITThread::run(void)
     67 *  \brief Thunk that allows scanner Qthread to
     68 *         call EITScanner::RunEventLoop().
     69 */
     70void ScannerThread::run(void)
     71{
     72    fetcher->RunScan();
     73}
     74
     75
    6776/** \fn IPTVChannelFetcher::Scan(void)
    6877 *  \brief Scans the given frequency list, blocking call.
    6978 */
     
    7685
    7786    _stop_now = false;
    7887
    79     pthread_create(&_thread, NULL, run_scan_thunk, this);
    80 
    81     while (!_thread_running && !_stop_now)
     88    _scannerThread.fetcher = this;
     89    _scannerThread.start(QThread::IdlePriority);
     90   
     91     while (!_thread_running && !_stop_now)
    8292        usleep(5000);
    8393
    8494    _lock.unlock();
     
    8696    return _thread_running;
    8797}
    8898
    89 void *run_scan_thunk(void *param)
    90 {
    91     IPTVChannelFetcher *chanscan = (IPTVChannelFetcher*) param;
    92     chanscan->RunScan();
    9399
    94     return NULL;
    95 }
    96 
    97100void IPTVChannelFetcher::RunScan(void)
    98101{
    99102    _thread_running = true;
     
    107110        return;
    108111    }
    109112
    110     VERBOSE(VB_CHANNEL, QString("Playlist URL: %1").arg(url));
     113    VERBOSE(VB_CHANNEL, QString("Playlist URL: %1").arg(url));
    111114
    112115    // Step 2/4 : Download
    113116    emit ServiceScanPercentComplete(5);
    114117    emit ServiceScanUpdateText(tr("Downloading Playlist"));
    115118
    116     QString playlist = DownloadPlaylist(url, false);
     119    QString playlist = DownloadPlaylist(url, true);
    117120
    118121    if (_stop_now || playlist.isEmpty())
    119122    {
  • libs/libmythtv/iptv/iptvchannelfetcher.h

     
    11#ifndef _IPTVCHANNELFETCHER_H_
    22#define _IPTVCHANNELFETCHER_H_
    33
    4 // POSIX headers
    5 #include <pthread.h>
    64
    75// Qt headers
    86#include <qobject.h>
    97#include <qmutex.h>
     8#include <qthread.h>
    109
    1110// MythTV headers
    1211#include "iptvchannelinfo.h"
    1312
     13class IPTVChannelFetcher;
     14
     15class ScannerThread : public QThread
     16{
     17  public:
     18    virtual void run();
     19    IPTVChannelFetcher   *fetcher;
     20};
     21
    1422class IPTVChannelFetcher : public QObject
    1523{
    1624    Q_OBJECT
    17 
    18     friend void *run_scan_thunk(void *param);
    19 
    2025  public:
    2126    IPTVChannelFetcher(uint cardid, const QString &inputname, uint sourceid);
    2227
    2328    bool Scan(void);
    2429    void Stop(void);
    2530
     31    void RunScan(void);
     32
    2633    static QString DownloadPlaylist(const QString &url, bool inQtThread);
    2734    static fbox_chan_map_t ParsePlaylist(
    2835        const QString &rawdata, IPTVChannelFetcher *fetcher = NULL);
     
    4350    void SetNumChannelsParsed(uint);
    4451    void SetNumChannelsInserted(uint);
    4552    void SetMessage(const QString &status);
    46     void RunScan(void);
     53   
    4754
    4855  private:
    49     uint      _cardid;
    50     QString   _inputname;
    51     uint      _sourceid;
    52     uint      _chan_cnt;
    53     bool      _thread_running;
    54     bool      _stop_now;
    55     pthread_t _thread;
    56     QMutex    _lock;
     56 
     57   uint                 _cardid;
     58    QString             _inputname;
     59    uint                _sourceid;
     60    uint                _chan_cnt;
     61    bool                _thread_running;
     62    bool                _stop_now;
     63    ScannerThread       _scannerThread;
     64    QMutex              _lock;
    5765};
    5866
    5967#endif // _IPTVCHANNELFETCHER_H_