diff -p -r -u -N -X /tmp/diff.exclude.16545 -x myth.20746.0626c -x myth.20746.0626d myth.20746.0626c/mythtv/libs/libmythhdhomerun/hdhomerun_device.c myth.20746.0626d/mythtv/libs/libmythhdhomerun/hdhomerun_device.c
--- mythtv/libs/libmythhdhomerun/hdhomerun_device.c	2009-06-27 10:43:21.000000000 -0500
+++ mythtv/libs/libmythhdhomerun/hdhomerun_device.c	2009-06-28 21:18:05.000000000 -0500
@@ -145,12 +145,17 @@ static struct hdhomerun_device_t *hdhome
 static struct hdhomerun_device_t *hdhomerun_device_create_from_str_ip(const char *device_str)
 {
 	unsigned long a[4];
-	if (sscanf(device_str, "%lu.%lu.%lu.%lu", &a[0], &a[1], &a[2], &a[3]) != 4) {
-		return NULL;
+	unsigned int tuner;
+
+	if (sscanf(device_str, "%lu.%lu.%lu.%lu-%u", &a[0], &a[1], &a[2], &a[3], &tuner) != 5) {
+		tuner = 0;
+		if (sscanf(device_str, "%lu.%lu.%lu.%lu", &a[0], &a[1], &a[2], &a[3]) != 4) {
+			return NULL;
+		}
 	}
 
 	unsigned long device_ip = (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | (a[3] << 0);
-	return hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, (uint32_t)device_ip, 0);
+	return hdhomerun_device_create(HDHOMERUN_DEVICE_ID_WILDCARD, (uint32_t)device_ip, tuner);
 }
 
 static struct hdhomerun_device_t *hdhomerun_device_create_from_str_dns(const char *device_str)
diff -p -r -u -N -X /tmp/diff.exclude.16545 -x myth.20746.0626c -x myth.20746.0626d myth.20746.0626c/mythtv/libs/libmythtv/hdhrstreamhandler.cpp myth.20746.0626d/mythtv/libs/libmythtv/hdhrstreamhandler.cpp
--- mythtv/libs/libmythtv/hdhrstreamhandler.cpp	2009-06-28 20:49:51.000000000 -0500
+++ mythtv/libs/libmythtv/hdhrstreamhandler.cpp	2009-06-28 23:41:44.000000000 -0500
@@ -35,29 +35,57 @@ HDHRStreamHandler *HDHRStreamHandler::Ge
 {
     QMutexLocker locker(&_handlers_lock);
 
+    QString devkey = devname.toUpper();
+
     QMap<QString,HDHRStreamHandler*>::iterator it =
-        _handlers.find(devname);
+        _handlers.find(devkey);
+
+    hdhr_id_data device_data;
 
     if (it == _handlers.end())
     {
-        HDHRStreamHandler *newhandler = new HDHRStreamHandler(devname);
+        // Not found in the current _handlers
+        // Try to find the physical device and determine a unique device key
+        // Then check to see if the unique key exists
+        FindDevice(devname, device_data);
+
+        devkey = QString("%1-%2").arg(device_data.device_id, 8, 16)
+                                 .arg(device_data.tuner);
+
+        // If the physical device is not found use the key "NOTFOUND-0"
+        if (device_data.device_id == 0)
+            devkey = "NOTFOUND-0";
+
+        devkey = devkey.toUpper();
+        it = _handlers.find(devkey);
+    }
+
+
+    if (it == _handlers.end())
+    {
+        HDHRStreamHandler *newhandler = new HDHRStreamHandler(devkey, device_data);
         newhandler->Open();
-        _handlers[devname] = newhandler;
-        _handlers_refcnt[devname] = 1;
+        _handlers[devkey] = newhandler;
+        _handlers_refcnt[devkey] = 1;
+
+        // If we are adding a "NOTFOUND" device, up its refcount so we never delete it.
+        if (device_data.device_id == 0)
+            _handlers_refcnt[devkey]++;
+
         VERBOSE(VB_RECORD,
-                QString("HDHRSH: Creating new stream handler for %1")
-                .arg(devname));
+                QString("HDHRSH: Creating new stream handler %1 for %2")
+                .arg(devkey).arg(devname));
     }
     else
     {
-        _handlers_refcnt[devname]++;
-        uint rcount = _handlers_refcnt[devname];
+        _handlers_refcnt[devkey]++;
+        uint rcount = _handlers_refcnt[devkey];
         VERBOSE(VB_RECORD,
-                QString("HDHRSH: Using existing stream handler for %1")
-                .arg(devname) + QString(" (%2 in use)").arg(rcount));
+                QString("HDHRSH: Using existing stream handler %1 for %2")
+                .arg(devkey).arg(devname) + QString(" (%1 in use)").arg(rcount));
     }
 
-    return _handlers[devname];
+    return _handlers[devkey];
 }
 
 void HDHRStreamHandler::Return(HDHRStreamHandler * & ref)
@@ -98,9 +126,12 @@ void HDHRStreamHandler::Return(HDHRStrea
     ref = NULL;
 }
 
-HDHRStreamHandler::HDHRStreamHandler(const QString &devicename) :
+HDHRStreamHandler::HDHRStreamHandler(const QString &devicename, hdhr_id_data & device_data) :
     _control_socket(NULL),
     _video_socket(NULL),
+    _device_id(device_data.device_id),
+    _device_ip(device_data.device_ip),
+    _tuner(device_data.tuner),
     _devicename(devicename),
 
     _start_stop_lock(QMutex::Recursive),
@@ -577,9 +608,11 @@ PIDPriority HDHRStreamHandler::GetPIDPri
 
 bool HDHRStreamHandler::Open(void)
 {
-    if (!FindDevice())
+    // By the time we get here we have a unique device_id & device_ip pair
+    // for the hdhomerun. _device_id == 0 and _devicename == "NOTFOUND-0"
+    // denote a device which is configured but we coudn't find.
+    if (_device_id == 0)
         return false;
-
     return Connect();
 }
 
@@ -613,27 +646,46 @@ bool HDHRStreamHandler::Connect(void)
     return true;
 }
 
-bool HDHRStreamHandler::FindDevice(void)
+void HDHRStreamHandler::FindDevice(const QString & _devicename, hdhr_id_data &device_data)
 {
     hdhomerun_device_t* thisdevice = hdhomerun_device_create_from_str(
         _devicename.toLocal8Bit().constData());
 
     if (thisdevice)
     {
-        _device_id = hdhomerun_device_get_device_id(thisdevice);
-        _device_ip = hdhomerun_device_get_device_ip(thisdevice);
-        _tuner     = hdhomerun_device_get_tuner(thisdevice);
+        device_data.device_id = hdhomerun_device_get_device_id(thisdevice);
+        device_data.device_ip = hdhomerun_device_get_device_ip(thisdevice);
+        device_data.tuner     = hdhomerun_device_get_tuner(thisdevice);
         hdhomerun_device_destroy(thisdevice);
 
-        VERBOSE(VB_IMPORTANT, LOC +
-                QString("device %5 found at address %1.%2.%3.%4 tuner %6")
-                .arg((_device_ip>>24) & 0xFF).arg((_device_ip>>16) & 0xFF)
-                .arg((_device_ip>> 8) & 0xFF).arg((_device_ip>> 0) & 0xFF)
-                .arg(_devicename).arg(_tuner));
-
-        return true;
+        if (device_data.device_ip != 0)
+        {
+            VERBOSE(VB_IMPORTANT, 
+                    QString("HDHRSH: device %1 found at address %2.%3.%4.%5 tuner %6")
+                    .arg(_devicename)
+                    .arg((device_data.device_ip>>24) & 0xFF)
+                    .arg((device_data.device_ip>>16) & 0xFF)
+                    .arg((device_data.device_ip>> 8) & 0xFF)
+                    .arg((device_data.device_ip>> 0) & 0xFF)
+                    .arg(device_data.tuner));
+        }
+        else
+        {
+            VERBOSE(VB_IMPORTANT,
+                    QString("HDHRSH: hdhomerun device %1 not found").arg(_devicename));
+            device_data.device_id = 0;
+            device_data.device_ip = hdhomerun_device_get_device_ip_requested(thisdevice);
+            device_data.tuner     = 0;
+        }
+    }
+    else
+    {
+        VERBOSE(VB_IMPORTANT,
+                QString("HDHRSH: hdhomerun device %1 not found").arg(_devicename));
+        device_data.device_id = 0;
+        device_data.device_ip = 0;
+        device_data.tuner     = 0;
     }
-    return false;
 }
 
 
diff -p -r -u -N -X /tmp/diff.exclude.16545 -x myth.20746.0626c -x myth.20746.0626d myth.20746.0626c/mythtv/libs/libmythtv/hdhrstreamhandler.h myth.20746.0626d/mythtv/libs/libmythtv/hdhrstreamhandler.h
--- mythtv/libs/libmythtv/hdhrstreamhandler.h	2009-06-28 20:49:51.000000000 -0500
+++ mythtv/libs/libmythtv/hdhrstreamhandler.h	2009-06-28 21:20:49.000000000 -0500
@@ -30,6 +30,12 @@ typedef QMap<uint,int> FilterMap;
 
 //#define RETUNE_TIMEOUT 5000
 
+struct hdhr_id_data {
+    uint device_id;
+    uint device_ip;
+    uint tuner;
+};
+
 class HDHRStreamHandler : public ReaderPausedCB
 {
     friend void *run_hdhr_stream_handler_thunk(void *param);
@@ -55,10 +61,10 @@ class HDHRStreamHandler : public ReaderP
     virtual void ReaderPaused(int fd) { (void) fd; }
 
   private:
-    HDHRStreamHandler(const QString &);
+    HDHRStreamHandler(const QString &, hdhr_id_data &);
     ~HDHRStreamHandler();
 
-    bool FindDevice(void);
+    static void FindDevice(const QString &, hdhr_id_data &);
     bool Connect(void);
 
     QString DeviceGet(const QString &name,
