Ticket #5228: iptvchannelfetcher2.patch
File iptvchannelfetcher2.patch, 3.5 KB (added by , 16 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 20 18 static bool parse_chan_info(const QString &rawdata, 21 19 IPTVChannelInfo &info, 22 20 QString &channum, … … 26 24 QString &channum, 27 25 QString &name); 28 26 27 /** \fn IPTVChannelFetcherThread::run(void) 28 * \brief Thunk that allows iptvfetcher Qthread to 29 * call IPTVChannelFetcher::RunScan(). 30 */ 31 void IPTVChannelFetcherThread::run(void) 32 { 33 iptvfetcher->RunScan(); 34 } 35 29 36 IPTVChannelFetcher::IPTVChannelFetcher( 30 37 uint cardid, const QString &inputname, uint sourceid) : 31 38 _cardid(cardid), _inputname(Q3DeepCopy<QString>(inputname)), … … 57 64 _stop_now = true; 58 65 _lock.unlock(); 59 66 60 pthread_join(_thread, NULL);67 _thread.wait(); 61 68 return; 62 69 } 63 70 … … 76 83 77 84 _stop_now = false; 78 85 79 pthread_create(&_thread, NULL, run_scan_thunk, this); 86 _thread.iptvfetcher = this; 87 _thread.start(QThread::NormalPriority); 80 88 81 89 while (!_thread_running && !_stop_now) 82 90 usleep(5000); … … 86 94 return _thread_running; 87 95 } 88 96 89 void *run_scan_thunk(void *param)90 {91 IPTVChannelFetcher *chanscan = (IPTVChannelFetcher*) param;92 chanscan->RunScan();93 94 return NULL;95 }96 97 97 void IPTVChannelFetcher::RunScan(void) 98 98 { 99 99 _thread_running = true; … … 113 113 emit ServiceScanPercentComplete(5); 114 114 emit ServiceScanUpdateText(tr("Downloading Playlist")); 115 115 116 QString playlist = DownloadPlaylist(url, false);116 QString playlist = DownloadPlaylist(url, true); 117 117 118 118 if (_stop_now || playlist.isEmpty()) 119 119 { -
libs/libmythtv/iptv/iptvchannelfetcher.h
1 1 #ifndef _IPTVCHANNELFETCHER_H_ 2 2 #define _IPTVCHANNELFETCHER_H_ 3 3 4 // POSIX headers5 #include <pthread.h>6 7 4 // Qt headers 8 5 #include <qobject.h> 9 6 #include <qmutex.h> 7 #include <qthread.h> 10 8 11 9 // MythTV headers 12 10 #include "iptvchannelinfo.h" 13 11 12 class IPTVChannelFetcher; 13 14 class IPTVChannelFetcherThread : public QThread 15 { 16 public: 17 virtual void run(); 18 IPTVChannelFetcher *iptvfetcher; 19 }; 20 14 21 class IPTVChannelFetcher : public QObject 15 22 { 16 23 Q_OBJECT 17 24 18 friend void *run_scan_thunk(void *param);25 friend class IPTVChannelFetcherThread; 19 26 20 27 public: 21 28 IPTVChannelFetcher(uint cardid, const QString &inputname, uint sourceid); … … 37 44 /// \brief Signals that the scan is complete 38 45 void ServiceScanComplete(void); 39 46 47 protected: 48 void RunScan(void); 49 40 50 private: 41 51 ~IPTVChannelFetcher(); 42 52 void SetTotalNumChannels(uint val) { _chan_cnt = (val) ? val : 1; } 43 53 void SetNumChannelsParsed(uint); 44 54 void SetNumChannelsInserted(uint); 45 55 void SetMessage(const QString &status); 46 void RunScan(void);47 56 48 57 private: 49 58 uint _cardid; … … 52 61 uint _chan_cnt; 53 62 bool _thread_running; 54 63 bool _stop_now; 55 pthread_t_thread;64 IPTVChannelFetcherThread _thread; 56 65 QMutex _lock; 57 66 }; 58 67