Index: mythtv/libs/libmythtv/mpeg/mpegstreamdata.cpp
===================================================================
--- mythtv.orig/libs/libmythtv/mpeg/mpegstreamdata.cpp	2006-01-06 20:20:09.000000000 +0000
+++ mythtv/libs/libmythtv/mpeg/mpegstreamdata.cpp	2006-01-07 12:01:34.000000000 +0000
@@ -24,11 +24,14 @@
       _cached_pat(NULL), _desired_program(desiredProgram),
       _pmt_single_program_num_video(1),
       _pmt_single_program_num_audio(0),
-      _pat_single_program(NULL), _pmt_single_program(NULL)
+      _pat_single_program(NULL), _pmt_single_program(NULL),
+      _invalid_pat_seen(false), _invalid_pat(NULL)
 {
     AddListeningPID(MPEG_PAT_PID);
 
     _pid_video_single_program = _pid_pmt_single_program = 0xffffffff;
+
+    connect(&_invalid_pat_timer, SIGNAL(timeout()), this, SLOT(ProcessInvalidPAT()));
 }
 
 MPEGStreamData::~MPEGStreamData()
@@ -46,6 +49,12 @@
 void MPEGStreamData::Reset(int desiredProgram)
 {
     _desired_program = desiredProgram;
+    _invalid_pat_seen = false;
+    if (_invalid_pat)
+    {
+        delete _invalid_pat;
+        _invalid_pat = NULL;
+    }
 
     SetPATSingleProgram(0);
     SetPMTSingleProgram(0);
@@ -372,11 +381,39 @@
             SetVersionPAT(psip.Version());
             ProgramAssociationTable *pat =
                 new ProgramAssociationTable(psip);
-            if (_cache_tables)
-                CachePAT(pat);
-            emit UpdatePAT(pat);
-            if ((_desired_program >= 0) && CreatePATSingleProgram(*pat))
-                emit UpdatePATSingleProgram(PATSingleProgram());
+
+            bool foundProgram = pat->FindPID(_desired_program);
+
+            if (_desired_program < 0)
+            {
+                if (_cache_tables)
+                    CachePAT(pat);
+                emit UpdatePAT(pat);
+            }
+            if (_desired_program >= 0)
+            {
+                if (!_invalid_pat_seen && !foundProgram)
+                {
+                    _invalid_pat_seen = true;
+                    _invalid_pat = pat;
+                    _invalid_pat_timer.start(400, TRUE); // 400ms timeout.
+                    VERBOSE(VB_RECORD, "HandleTables -> PAT is missing program, setting timeout");
+                }
+                else if (foundProgram)
+                {
+                    if (_invalid_pat_seen)
+                    {
+                        _invalid_pat_seen = false;
+                        _invalid_pat_timer.stop();
+                        VERBOSE(VB_RECORD, "HandleTables -> PAT updated");
+                    }
+                    if (_cache_tables)
+                        CachePAT(pat);
+                    emit UpdatePAT(pat);
+                    if (CreatePATSingleProgram(*pat))
+                        emit UpdatePATSingleProgram(PATSingleProgram());
+                }
+            }
             if (!_cache_tables)
                 delete pat;
             return true;
@@ -401,6 +438,11 @@
     return false;
 }
 
+void MPEGStreamData::ProcessInvalidPAT(void)
+{
+    VERBOSE(VB_IMPORTANT, "Program not found in PAT. Rescan your transports.");
+    CreatePATSingleProgram(*_invalid_pat);
+}
 
 #define DONE_WITH_PES_PACKET() { if (psip) delete psip; \
     if (morePSIPPackets) goto HAS_ANOTHER_PES; else return; }
Index: mythtv/libs/libmythtv/mpeg/mpegstreamdata.h
===================================================================
--- mythtv.orig/libs/libmythtv/mpeg/mpegstreamdata.h	2005-11-17 11:10:55.000000000 +0000
+++ mythtv/libs/libmythtv/mpeg/mpegstreamdata.h	2006-01-07 00:13:06.000000000 +0000
@@ -7,6 +7,7 @@
 using namespace std;
 
 #include <qmap.h>
+#include <qtimer.h>
 #include "tspacket.h"
 
 class ProgramAssociationTable;
@@ -177,6 +178,14 @@
     uint                      _pmt_single_program_num_audio;
     ProgramAssociationTable  *_pat_single_program;
     ProgramMapTable          *_pmt_single_program;
+
+  // PAT Timeout handling.
+  protected slots:
+    void                     ProcessInvalidPAT();
+  private:
+    bool                     _invalid_pat_seen;
+    QTimer                   _invalid_pat_timer;
+    ProgramAssociationTable *_invalid_pat;
 };
 
 #include "mpegtables.h"
