Ticket #743: find-correct-pat-in-400ms.diff
File find-correct-pat-in-400ms.diff, 4.1 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/mpeg/mpegstreamdata.cpp
old new 24 24 _cached_pat(NULL), _desired_program(desiredProgram), 25 25 _pmt_single_program_num_video(1), 26 26 _pmt_single_program_num_audio(0), 27 _pat_single_program(NULL), _pmt_single_program(NULL) 27 _pat_single_program(NULL), _pmt_single_program(NULL), 28 _invalid_pat_seen(false), _invalid_pat(NULL) 28 29 { 29 30 AddListeningPID(MPEG_PAT_PID); 30 31 31 32 _pid_video_single_program = _pid_pmt_single_program = 0xffffffff; 33 34 connect(&_invalid_pat_timer, SIGNAL(timeout()), this, SLOT(ProcessInvalidPAT())); 32 35 } 33 36 34 37 MPEGStreamData::~MPEGStreamData() … … 46 49 void MPEGStreamData::Reset(int desiredProgram) 47 50 { 48 51 _desired_program = desiredProgram; 52 _invalid_pat_seen = false; 53 if (_invalid_pat) 54 { 55 delete _invalid_pat; 56 _invalid_pat = NULL; 57 } 49 58 50 59 SetPATSingleProgram(0); 51 60 SetPMTSingleProgram(0); … … 372 381 SetVersionPAT(psip.Version()); 373 382 ProgramAssociationTable *pat = 374 383 new ProgramAssociationTable(psip); 375 if (_cache_tables) 376 CachePAT(pat); 377 emit UpdatePAT(pat); 378 if ((_desired_program >= 0) && CreatePATSingleProgram(*pat)) 379 emit UpdatePATSingleProgram(PATSingleProgram()); 384 385 bool foundProgram = pat->FindPID(_desired_program); 386 387 if (_desired_program < 0) 388 { 389 if (_cache_tables) 390 CachePAT(pat); 391 emit UpdatePAT(pat); 392 } 393 if (_desired_program >= 0) 394 { 395 if (!_invalid_pat_seen && !foundProgram) 396 { 397 _invalid_pat_seen = true; 398 _invalid_pat = pat; 399 _invalid_pat_timer.start(400, TRUE); // 400ms timeout. 400 VERBOSE(VB_RECORD, "HandleTables -> PAT is missing program, setting timeout"); 401 } 402 else if (foundProgram) 403 { 404 if (_invalid_pat_seen) 405 { 406 _invalid_pat_seen = false; 407 _invalid_pat_timer.stop(); 408 VERBOSE(VB_RECORD, "HandleTables -> PAT updated"); 409 } 410 if (_cache_tables) 411 CachePAT(pat); 412 emit UpdatePAT(pat); 413 if (CreatePATSingleProgram(*pat)) 414 emit UpdatePATSingleProgram(PATSingleProgram()); 415 } 416 } 380 417 if (!_cache_tables) 381 418 delete pat; 382 419 return true; … … 401 438 return false; 402 439 } 403 440 441 void MPEGStreamData::ProcessInvalidPAT(void) 442 { 443 VERBOSE(VB_IMPORTANT, "Program not found in PAT. Rescan your transports."); 444 CreatePATSingleProgram(*_invalid_pat); 445 } 404 446 405 447 #define DONE_WITH_PES_PACKET() { if (psip) delete psip; \ 406 448 if (morePSIPPackets) goto HAS_ANOTHER_PES; else return; } -
libs/libmythtv/mpeg/mpegstreamdata.h
old new 7 7 using namespace std; 8 8 9 9 #include <qmap.h> 10 #include <qtimer.h> 10 11 #include "tspacket.h" 11 12 12 13 class ProgramAssociationTable; … … 177 178 uint _pmt_single_program_num_audio; 178 179 ProgramAssociationTable *_pat_single_program; 179 180 ProgramMapTable *_pmt_single_program; 181 182 // PAT Timeout handling. 183 protected slots: 184 void ProcessInvalidPAT(); 185 private: 186 bool _invalid_pat_seen; 187 QTimer _invalid_pat_timer; 188 ProgramAssociationTable *_invalid_pat; 180 189 }; 181 190 182 191 #include "mpegtables.h"