Index: libs/libmythtv/videoout_xv.cpp
===================================================================
--- libs/libmythtv/videoout_xv.cpp	(revision 8742)
+++ libs/libmythtv/videoout_xv.cpp	(working copy)
@@ -5,6 +5,7 @@
 #include <cmath>
 #include <ctime>
 #include <cerrno>
+#include <cassert>
 
 #include <malloc.h>
 #include <fcntl.h>
@@ -48,6 +49,32 @@
 #define round(x) ((int) ((x) + 0.5))
 #endif
 
+static QMutex        open_xv_ports_lock;
+static QMap<int,int> open_xv_ports;
+static void add_open_xv_port(int port)
+{
+    if (port < 0)
+        return;
+    QMutexLocker locker(&open_xv_ports_lock);
+    open_xv_ports[port] = port;
+}
+static void del_open_xv_port(int port)
+{
+    if (port < 0)
+        return;
+    QMutexLocker locker(&open_xv_ports_lock);
+    open_xv_ports.remove(port);
+}
+static bool has_open_xv_port(int port)
+{
+    QMutexLocker locker(&open_xv_ports_lock);
+    return open_xv_ports.find(port) != open_xv_ports.end();
+}
+static uint cnt_open_xv_port(void)
+{
+    QMutexLocker locker(&open_xv_ports_lock);
+    return open_xv_ports.count();
+}
 
 //#define DEBUG_PAUSE /* enable to debug XvMC pause frame */
 
@@ -245,7 +272,9 @@
     // ungrab port...
     if (xv_port >= 0)
     {
+        VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port);
         X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime));
+        del_open_xv_port(xv_port);
         xv_port = -1;
     }
 
@@ -637,6 +666,7 @@
                 
                 if (xvmc_surf_info)
                     surf.set(surfNum, xvmc_surf_info);
+                add_open_xv_port(p);
                 port = p;
 #endif // USING_XVMC
             }
@@ -646,7 +676,10 @@
                 {
                     X11S(ret = XvGrabPort(disp, p, CurrentTime));
                     if (Success == ret)
+                    {
+                        add_open_xv_port(p);
                         port = p;
+                    }
                 }
             }
         }
@@ -785,8 +818,10 @@
  */
 bool VideoOutputXv::InitXvMC(MythCodecID mcodecid)
 {
+    VERBOSE(VB_IMPORTANT, "InitXvMC() -- begin");
     (void)mcodecid;
 #ifdef USING_XVMC
+    assert(xv_port < 0);
     xv_port = GrabSuitableXvPort(XJ_disp, XJ_root, mcodecid,
                                  XJ_width, XJ_height, xvmc_chroma,
                                  &xvmc_surf_info);
@@ -826,10 +861,13 @@
             delete xvmc_osd_available[i];
         xvmc_osd_available.clear();
         xvmc_osd_lock.unlock();
+        VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port);
         X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime));
+        del_open_xv_port(xv_port);
         xv_port = -1;
     }
 
+    VERBOSE(VB_IMPORTANT, "InitXvMC() -- end ok("<<ok<<")");
     return ok;
 #else // USING_XVMC
     return false;
@@ -903,7 +941,9 @@
     {
         VERBOSE(VB_IMPORTANT, LOC_ERR +
                 "Couldn't find the proper XVideo image format.");
+        VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port);
         X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime));
+        del_open_xv_port(xv_port);
         xv_port = -1;
     }
 
@@ -916,7 +956,9 @@
     {
         VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to create XVideo Buffers.");
         DeleteBuffers(XVideo, false);
+        VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port);
         X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime));
+        del_open_xv_port(xv_port);
         xv_port = -1;
         ok = false;
     }
@@ -1056,12 +1098,14 @@
                                   width, height);
             ok = NULL != ctx;
             DeleteXvMCContext(disp, ctx);
+            VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << port);
             X11S(XvUngrabPort(disp, port, CurrentTime));
+            del_open_xv_port(port);
         }
     }
     X11S(XCloseDisplay(disp));
 
-    if (!ok)
+    if (!ok && !cnt_open_xv_port())
     {
         QString msg = LOC_ERR + "Could not open XvMC port...\n"
                 "\n"
@@ -1182,7 +1226,9 @@
         DeleteBuffers(VideoOutputSubType(), true);
         if (xv_port >= 0)
         {
+            VERBOSE(VB_PLAYBACK, LOC + "Closing XVideo port " << xv_port);
             X11S(XvUngrabPort(XJ_disp, xv_port, CurrentTime));
+            del_open_xv_port(xv_port);
             xv_port = -1;
         }
 #endif // USING_XVMC
Index: libs/libmythtv/NuppelVideoPlayer.cpp
===================================================================
--- libs/libmythtv/NuppelVideoPlayer.cpp	(revision 8742)
+++ libs/libmythtv/NuppelVideoPlayer.cpp	(working copy)
@@ -367,6 +367,7 @@
 
 bool NuppelVideoPlayer::InitVideo(void)
 {
+    VERBOSE(VB_RECORD, "InitVideo()");
     InitFilters();
     if (using_null_videoout)
     {
@@ -447,6 +448,7 @@
 
 void NuppelVideoPlayer::ReinitVideo(void)
 {
+    VERBOSE(VB_RECORD, "ReinitVideo()");
     InitFilters();
 
     vidExitLock.lock();
