Ticket #5229: out_fix_iptv_scanner.diff
File out_fix_iptv_scanner.diff, 3.8 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/iptv/iptvchannelfetcher.cpp
15 15 #define LOC QString("IPTVChanFetch: ") 16 16 #define LOC_ERR QString("IPTVChanFetch, Error: ") 17 17 18 void *run_scan_thunk(void*);19 18 20 19 static bool parse_chan_info(const QString &rawdata, 21 20 IPTVChannelInfo &info, … … 57 56 _stop_now = true; 58 57 _lock.unlock(); 59 58 60 pthread_join(_thread, NULL);59 _scannerThread.wait(); 61 60 return; 62 61 } 63 62 64 63 _lock.unlock(); 65 64 } 66 65 66 /** \fn EITThread::run(void) 67 * \brief Thunk that allows scanner Qthread to 68 * call EITScanner::RunEventLoop(). 69 */ 70 void ScannerThread::run(void) 71 { 72 fetcher->RunScan(); 73 } 74 75 67 76 /** \fn IPTVChannelFetcher::Scan(void) 68 77 * \brief Scans the given frequency list, blocking call. 69 78 */ … … 76 85 77 86 _stop_now = false; 78 87 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) 82 92 usleep(5000); 83 93 84 94 _lock.unlock(); … … 86 96 return _thread_running; 87 97 } 88 98 89 void *run_scan_thunk(void *param)90 {91 IPTVChannelFetcher *chanscan = (IPTVChannelFetcher*) param;92 chanscan->RunScan();93 99 94 return NULL;95 }96 97 100 void IPTVChannelFetcher::RunScan(void) 98 101 { 99 102 _thread_running = true; … … 107 110 return; 108 111 } 109 112 110 VERBOSE(VB_CHANNEL, QString("Playlist URL: %1").arg(url)); 113 VERBOSE(VB_CHANNEL, QString("Playlist URL: %1").arg(url)); 111 114 112 115 // Step 2/4 : Download 113 116 emit ServiceScanPercentComplete(5); 114 117 emit ServiceScanUpdateText(tr("Downloading Playlist")); 115 118 116 QString playlist = DownloadPlaylist(url, false);119 QString playlist = DownloadPlaylist(url, true); 117 120 118 121 if (_stop_now || playlist.isEmpty()) 119 122 { -
libs/libmythtv/iptv/iptvchannelfetcher.h
1 1 #ifndef _IPTVCHANNELFETCHER_H_ 2 2 #define _IPTVCHANNELFETCHER_H_ 3 3 4 // POSIX headers5 #include <pthread.h>6 4 7 5 // Qt headers 8 6 #include <qobject.h> 9 7 #include <qmutex.h> 8 #include <qthread.h> 10 9 11 10 // MythTV headers 12 11 #include "iptvchannelinfo.h" 13 12 13 class IPTVChannelFetcher; 14 15 class ScannerThread : public QThread 16 { 17 public: 18 virtual void run(); 19 IPTVChannelFetcher *fetcher; 20 }; 21 14 22 class IPTVChannelFetcher : public QObject 15 23 { 16 24 Q_OBJECT 17 18 friend void *run_scan_thunk(void *param);19 20 25 public: 21 26 IPTVChannelFetcher(uint cardid, const QString &inputname, uint sourceid); 22 27 23 28 bool Scan(void); 24 29 void Stop(void); 25 30 31 void RunScan(void); 32 26 33 static QString DownloadPlaylist(const QString &url, bool inQtThread); 27 34 static fbox_chan_map_t ParsePlaylist( 28 35 const QString &rawdata, IPTVChannelFetcher *fetcher = NULL); … … 43 50 void SetNumChannelsParsed(uint); 44 51 void SetNumChannelsInserted(uint); 45 52 void SetMessage(const QString &status); 46 void RunScan(void);53 47 54 48 55 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; 57 65 }; 58 66 59 67 #endif // _IPTVCHANNELFETCHER_H_