Ticket #13339: hdhr-locking-pooling-3.patch
File hdhr-locking-pooling-3.patch, 29.9 KB (added by , 5 years ago) |
---|
-
mythtv/libs/libmythtv/cardutil.cpp
diff --git a/mythtv/libs/libmythtv/cardutil.cpp b/mythtv/libs/libmythtv/cardutil.cpp index bf797e6a57..246e70a29e 100644
a b QStringList CardUtil::ProbeVideoDevices(const QString &rawtype) 540 540 .arg((result_list[i].ip_addr>> 8) & 0xFF) 541 541 .arg((result_list[i].ip_addr>> 0) & 0xFF); 542 542 543 for (int tuner = 0; tuner < result_list[i].tuner_count; tuner++) 544 { 545 QString hdhrdev = id.toUpper() + " " + ip + " " + 546 QString("%1").arg(tuner); 547 devs.push_back(hdhrdev); 548 } 543 QString hdhrdev = id.toUpper() + " " + ip; 544 devs.push_back(hdhrdev); 549 545 } 550 546 } 551 547 #endif // USING_HDHOMERUN … … uint CardUtil::CreateDeviceInputGroup(uint inputid, 1396 1392 { 1397 1393 QString name = host + '|' + device; 1398 1394 if (type == "FREEBOX" || type == "IMPORT" || 1399 type == "DEMO" || type == "EXTERNAL") 1395 type == "DEMO" || type == "EXTERNAL" || 1396 type == "HDHOMERUN") 1400 1397 name += QString("|%1").arg(inputid); 1401 1398 return CreateInputGroup(name); 1402 1399 } -
mythtv/libs/libmythtv/recorders/channelbase.cpp
diff --git a/mythtv/libs/libmythtv/recorders/channelbase.cpp b/mythtv/libs/libmythtv/recorders/channelbase.cpp index 04d46da5e7..281583fb44 100644
a b ChannelBase *ChannelBase::CreateChannel( 805 805 { 806 806 if (channel && 807 807 ((genOpt.inputtype == "DVB" && dvbOpt.dvb_on_demand) || 808 genOpt.inputtype == "HDHOMERUN" || 808 809 CardUtil::IsV4L(genOpt.inputtype))) 809 810 { 810 811 channel->Close(); … … bool ChannelBase::IsExternalChannelChangeInUse(void) 835 836 836 837 return !m_externalChanger.isEmpty(); 837 838 } 839 840 int ChannelBase::GetMajorID(void) 841 { 842 return m_pParent ? m_pParent->GetMajorId() : m_inputid; 843 } -
mythtv/libs/libmythtv/recorders/channelbase.h
diff --git a/mythtv/libs/libmythtv/recorders/channelbase.h b/mythtv/libs/libmythtv/recorders/channelbase.h index 7711e10650..a326faffc6 100644
a b class ChannelBase 100 100 // \brief Set inputid for scanning 101 101 void SetInputID(uint _inputid) { m_inputid = _inputid; } 102 102 103 // \brief Get major input ID 104 int GetMajorID(void); 105 103 106 static ChannelBase *CreateChannel( 104 107 TVRec *tv_rec, 105 108 const GeneralDBOptions &genOpt, -
mythtv/libs/libmythtv/recorders/hdhrchannel.cpp
diff --git a/mythtv/libs/libmythtv/recorders/hdhrchannel.cpp b/mythtv/libs/libmythtv/recorders/hdhrchannel.cpp index 448a75635e..133fe827e1 100644
a b bool HDHRChannel::Open(void) 59 59 if (IsOpen()) 60 60 return true; 61 61 62 _stream_handler = HDHRStreamHandler::Get(_device_id, GetInputID()); 62 _stream_handler = HDHRStreamHandler::Get(GetDevice(), GetInputID(), 63 GetMajorID()); 63 64 64 65 _tuner_types = _stream_handler->GetTunerTypes(); 65 66 tunerType = (_tuner_types.empty()) ? … … void HDHRChannel::Close(void) 86 87 87 88 bool HDHRChannel::EnterPowerSavingMode(void) 88 89 { 89 if (IsOpen()) 90 return _stream_handler->EnterPowerSavingMode(); 91 else 92 return true; 90 Close(); 91 return true; 93 92 } 94 93 95 94 bool HDHRChannel::IsOpen(void) const -
mythtv/libs/libmythtv/recorders/hdhrrecorder.cpp
diff --git a/mythtv/libs/libmythtv/recorders/hdhrrecorder.cpp b/mythtv/libs/libmythtv/recorders/hdhrrecorder.cpp index 1138c8d046..f85c0015b5 100644
a b bool HDHRRecorder::Open(void) 36 36 ResetForNewFile(); 37 37 38 38 _stream_handler = HDHRStreamHandler::Get(_channel->GetDevice(), 39 (tvrec ? tvrec->GetInputId() : -1)); 39 _channel->GetInputID(), 40 _channel->GetMajorID()); 40 41 41 42 LOG(VB_RECORD, LOG_INFO, LOC + "HDHR opened successfully"); 42 43 -
mythtv/libs/libmythtv/recorders/hdhrsignalmonitor.cpp
diff --git a/mythtv/libs/libmythtv/recorders/hdhrsignalmonitor.cpp b/mythtv/libs/libmythtv/recorders/hdhrsignalmonitor.cpp index 71c0438a13..45c4857d98 100644
a b HDHRSignalMonitor::HDHRSignalMonitor(int db_cardnum, 51 51 52 52 AddFlags(kSigMon_WaitForSig); 53 53 54 streamHandler = HDHRStreamHandler::Get(channel->GetDevice(), inputid); 54 streamHandler = HDHRStreamHandler::Get(channel->GetDevice(), 55 channel->GetInputID(), 56 channel->GetMajorID()); 55 57 } 56 58 57 59 /** \fn HDHRSignalMonitor::~HDHRSignalMonitor() -
mythtv/libs/libmythtv/recorders/hdhrstreamhandler.cpp
diff --git a/mythtv/libs/libmythtv/recorders/hdhrstreamhandler.cpp b/mythtv/libs/libmythtv/recorders/hdhrstreamhandler.cpp index 4254732c82..644e7dfd8b 100644
a b 21 21 22 22 #define LOC QString("HDHRSH[%1](%2): ").arg(_inputid).arg(_device) 23 23 24 QMap< QString,HDHRStreamHandler*>HDHRStreamHandler::_handlers;25 QMap< QString,uint>HDHRStreamHandler::_handlers_refcnt;24 QMap<int,HDHRStreamHandler*> HDHRStreamHandler::_handlers; 25 QMap<int,uint> HDHRStreamHandler::_handlers_refcnt; 26 26 QMutex HDHRStreamHandler::_handlers_lock; 27 27 28 28 HDHRStreamHandler *HDHRStreamHandler::Get(const QString &devname, 29 int inputid )29 int inputid, int majorid) 30 30 { 31 31 QMutexLocker locker(&_handlers_lock); 32 32 33 QString devkey = devname.toUpper(); 34 35 QMap<QString,HDHRStreamHandler*>::iterator it = _handlers.find(devkey); 33 QMap<int,HDHRStreamHandler*>::iterator it = _handlers.find(majorid); 36 34 37 35 if (it == _handlers.end()) 38 36 { 39 HDHRStreamHandler *newhandler = new HDHRStreamHandler(devkey, inputid); 37 HDHRStreamHandler *newhandler = new HDHRStreamHandler(devname, inputid, 38 majorid); 40 39 newhandler->Open(); 41 _handlers[ devkey] = newhandler;42 _handlers_refcnt[ devkey] = 1;40 _handlers[majorid] = newhandler; 41 _handlers_refcnt[majorid] = 1; 43 42 44 43 LOG(VB_RECORD, LOG_INFO, 45 44 QString("HDHRSH[%1]: Creating new stream handler %2 for %3") 46 .arg(inputid).arg( devkey).arg(devname));45 .arg(inputid).arg(majorid).arg(devname)); 47 46 } 48 47 else 49 48 { 50 _handlers_refcnt[ devkey]++;51 uint rcount = _handlers_refcnt[ devkey];49 _handlers_refcnt[majorid]++; 50 uint rcount = _handlers_refcnt[majorid]; 52 51 LOG(VB_RECORD, LOG_INFO, 53 52 QString("HDHRSH[%1]: Using existing stream handler %2 for %3") 54 .arg(inputid).arg( devkey)53 .arg(inputid).arg(majorid) 55 54 .arg(devname) + QString(" (%1 in use)").arg(rcount)); 56 55 } 57 56 58 return _handlers[ devkey];57 return _handlers[majorid]; 59 58 } 60 59 61 60 void HDHRStreamHandler::Return(HDHRStreamHandler * & ref, int inputid) 62 61 { 63 62 QMutexLocker locker(&_handlers_lock); 64 63 65 QString devname = ref->_device;64 int majorid = ref->_majorid; 66 65 67 QMap< QString,uint>::iterator rit = _handlers_refcnt.find(devname);66 QMap<int,uint>::iterator rit = _handlers_refcnt.find(majorid); 68 67 if (rit == _handlers_refcnt.end()) 69 68 return; 70 69 71 QMap< QString,HDHRStreamHandler*>::iterator it = _handlers.find(devname);70 QMap<int,HDHRStreamHandler*>::iterator it = _handlers.find(majorid); 72 71 if (*rit > 1) 73 72 { 74 73 ref = nullptr; … … void HDHRStreamHandler::Return(HDHRStreamHandler * & ref, int inputid) 79 78 if ((it != _handlers.end()) && (*it == ref)) 80 79 { 81 80 LOG(VB_RECORD, LOG_INFO, QString("HDHRSH[%1]: Closing handler for %2") 82 .arg(inputid).arg( devname));81 .arg(inputid).arg(majorid)); 83 82 ref->Close(); 84 83 delete *it; 85 84 _handlers.erase(it); … … void HDHRStreamHandler::Return(HDHRStreamHandler * & ref, int inputid) 88 87 { 89 88 LOG(VB_GENERAL, LOG_ERR, 90 89 QString("HDHRSH[%1] Error: Couldn't find handler for %2") 91 .arg(inputid).arg( devname));90 .arg(inputid).arg(majorid)); 92 91 } 93 92 94 93 _handlers_refcnt.erase(rit); 95 94 ref = nullptr; 96 95 } 97 96 98 HDHRStreamHandler::HDHRStreamHandler(const QString &device, int inputid) 97 HDHRStreamHandler::HDHRStreamHandler(const QString &device, int inputid, 98 int majorid) 99 99 : StreamHandler(device, inputid) 100 100 , _hdhomerun_device(nullptr) 101 101 , _tuner(-1) 102 102 , _tune_mode(hdhrTuneModeNone) 103 , _majorid(majorid) 103 104 , _hdhr_lock(QMutex::Recursive) 104 105 { 105 106 setObjectName("HDHRStreamHandler"); … … HDHRStreamHandler::HDHRStreamHandler(const QString &device, int inputid) 110 111 */ 111 112 void HDHRStreamHandler::run(void) 112 113 { 113 int tunerLock = 0;114 char *error = nullptr;115 116 114 RunProlog(); 117 /* Get a tuner lock */ 118 tunerLock = hdhomerun_device_tuner_lockkey_request(_hdhomerun_device, &error); 119 if(tunerLock < 1) 120 { 121 LOG(VB_GENERAL, LOG_ERR, LOC + 122 QString("Get tuner lock failed. Aborting. Error: %1").arg(error)); 123 _error = true; 124 RunEpilog(); 125 return; 126 } 115 127 116 /* Create TS socket. */ 128 117 if (!hdhomerun_device_stream_start(_hdhomerun_device)) 129 118 { … … void HDHRStreamHandler::run(void) 221 210 222 211 LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): " + "end"); 223 212 224 if(tunerLock == 1)225 {226 LOG(VB_RECORD, LOG_INFO, LOC + "Release tuner lock.");227 hdhomerun_device_tuner_lockkey_release(_hdhomerun_device);228 }229 230 213 SetRunning(false, false, false); 214 231 215 RunEpilog(); 232 216 } 233 217 … … void HDHRStreamHandler::Close(void) 361 345 if (_hdhomerun_device) 362 346 { 363 347 TuneChannel("none"); 364 hdhomerun_device_ destroy(_hdhomerun_device);348 hdhomerun_device_tuner_lockkey_release(_hdhomerun_device); 365 349 _hdhomerun_device = nullptr; 366 350 } 351 if (_device_selector) 352 { 353 hdhomerun_device_selector_destroy(_device_selector, true); 354 _device_selector = nullptr; 355 } 367 356 } 368 357 369 358 bool HDHRStreamHandler::Connect(void) 370 359 { 371 _hdhomerun_device = hdhomerun_device_create_from_str( 372 _device.toLocal8Bit().constData(), nullptr); 373 374 if (!_hdhomerun_device) 360 _device_selector = hdhomerun_device_selector_create(nullptr); 361 if (!_device_selector) 375 362 { 376 LOG(VB_GENERAL, LOG_ERR, LOC + "Unable to create hdhomerun object");363 LOG(VB_GENERAL, LOG_ERR, LOC + "Unable to create device selector"); 377 364 return false; 378 365 } 379 366 380 _tuner = hdhomerun_device_get_tuner(_hdhomerun_device); 367 QStringList devices = _device.split(","); 368 for (int i = 0; i < devices.size(); ++i) 369 { 370 QByteArray ba = devices[i].toUtf8(); 371 int n = hdhomerun_device_selector_load_from_str( 372 _device_selector, ba.data()); 373 LOG(VB_GENERAL, LOG_INFO, LOC + QString("Added %1 devices from %3") 374 .arg(n).arg(devices[i])); 375 } 381 376 382 if (hdhomerun_device_get_local_machine_addr(_hdhomerun_device) == 0) 377 _hdhomerun_device = hdhomerun_device_selector_choose_and_lock( 378 _device_selector, nullptr); 379 if (!_hdhomerun_device) 383 380 { 384 LOG(VB_GENERAL, LOG_ERR, LOC + "Unable to connect to device"); 381 LOG(VB_GENERAL, LOG_ERR, LOC + 382 QString("Unable to find a free device")); 383 hdhomerun_device_selector_destroy(_device_selector, true); 384 _device_selector = nullptr; 385 385 return false; 386 386 } 387 387 388 LOG(VB_RECORD, LOG_INFO, LOC + "Successfully connected to device"); 389 return true; 390 } 388 _tuner = hdhomerun_device_get_tuner(_hdhomerun_device); 391 389 392 bool HDHRStreamHandler::EnterPowerSavingMode(void) 393 { 394 QMutexLocker locker(&_listener_lock);390 LOG(VB_GENERAL, LOG_INFO, LOC + 391 QString("Connected to device(%1)") 392 .arg(hdhomerun_device_get_name(_hdhomerun_device))); 395 393 396 if (!_stream_data_list.empty()) 397 { 398 LOG(VB_RECORD, LOG_INFO, LOC + 399 "Ignoring request - video streaming active"); 400 return false; 401 } 402 else 403 { 404 locker.unlock(); // _listener_lock 405 return TuneChannel("none"); 406 } 394 return true; 407 395 } 408 396 409 397 QString HDHRStreamHandler::TunerGet( -
mythtv/libs/libmythtv/recorders/hdhrstreamhandler.h
diff --git a/mythtv/libs/libmythtv/recorders/hdhrstreamhandler.h b/mythtv/libs/libmythtv/recorders/hdhrstreamhandler.h index 70f8ae1853..02cb7f27b3 100644
a b class DeviceReadBuffer; 30 30 #endif 31 31 #else 32 32 struct hdhomerun_device_t { int dummy; }; 33 struct hdhomerun_device_selector_t { int dummy; }; 33 34 #endif 34 35 35 36 enum HDHRTuneMode { … … enum HDHRTuneMode { 49 50 class HDHRStreamHandler : public StreamHandler 50 51 { 51 52 public: 52 static HDHRStreamHandler *Get(const QString &devicename, int inputid); 53 static HDHRStreamHandler *Get(const QString &devicename, int inputid, 54 int majorid); 53 55 static void Return(HDHRStreamHandler * & ref, int inputid); 54 56 55 57 void AddListener(MPEGStreamData *data, … … class HDHRStreamHandler : public StreamHandler 68 70 bool TuneChannel(const QString &chanid); 69 71 bool TuneProgram(uint mpeg_prog_num); 70 72 bool TuneVChannel(const QString &vchn); 71 bool EnterPowerSavingMode(void);72 73 73 74 private: 74 explicit HDHRStreamHandler(const QString &, int inputid );75 explicit HDHRStreamHandler(const QString &, int inputid, int majorid); 75 76 76 77 bool Connect(void); 77 78 … … class HDHRStreamHandler : public StreamHandler 91 92 92 93 private: 93 94 hdhomerun_device_t *_hdhomerun_device; 95 hdhomerun_device_selector_t *_device_selector; 94 96 int _tuner; 95 97 vector<DTVTunerType> _tuner_types; 96 98 HDHRTuneMode _tune_mode; // debug self check 99 int _majorid; 97 100 98 101 mutable QMutex _hdhr_lock; 99 102 100 103 // for implementing Get & Return 101 104 static QMutex _handlers_lock; 102 static QMap< QString, HDHRStreamHandler*>_handlers;103 static QMap< QString, uint>_handlers_refcnt;105 static QMap<int, HDHRStreamHandler*> _handlers; 106 static QMap<int, uint> _handlers_refcnt; 104 107 }; 105 108 106 109 #endif // _HDHRSTREAMHANDLER_H_ -
mythtv/libs/libmythtv/tv_rec.h
diff --git a/mythtv/libs/libmythtv/tv_rec.h b/mythtv/libs/libmythtv/tv_rec.h index a493582d47..3d8321a339 100644
a b class MTV_PUBLIC TVRec : public SignalMonitorListener, public QRunnable 240 240 /// \brief Returns the inputid 241 241 uint GetInputId(void) { return inputid; } 242 242 uint GetParentId(void) { return parentid; } 243 uint GetMajorId(void) { return parentid ? parentid : inputid; } 243 244 /// \brief Returns true is "errored" is true, false otherwise. 244 245 bool IsErrored(void) const { return HasFlags(kFlagErrored); } 245 246 -
mythtv/libs/libmythtv/videosource.cpp
diff --git a/mythtv/libs/libmythtv/videosource.cpp b/mythtv/libs/libmythtv/videosource.cpp index 13d008bec5..4db1fa8dc9 100644
a b static void FirewireConfigurationGroup(CaptureCard& parent, CardType& cardtype) 1383 1383 // HDHomeRun Configuration 1384 1384 // ----------------------- 1385 1385 1386 HDHomeRunIP::HDHomeRunIP() 1387 { 1388 setLabel(QObject::tr("IP Address")); 1389 setEnabled(false); 1390 connect(this, SIGNAL(valueChanged( const QString&)), 1391 this, SLOT( UpdateDevices(const QString&))); 1392 _oldValue=""; 1393 }; 1394 1395 void HDHomeRunIP::setEnabled(bool e) 1396 { 1397 MythUITextEditSetting::setEnabled(e); 1398 if (e) 1399 { 1400 if (!_oldValue.isEmpty()) 1401 setValue(_oldValue); 1402 emit NewIP(getValue()); 1403 } 1404 else 1405 { 1406 _oldValue = getValue(); 1407 _oldValue.detach(); 1408 } 1409 } 1410 1411 void HDHomeRunIP::UpdateDevices(const QString &v) 1412 { 1413 if (isEnabled()) 1414 { 1415 #if 0 1416 LOG(VB_GENERAL, LOG_DEBUG, QString("Emitting NewIP(%1)").arg(v)); 1417 #endif 1418 emit NewIP(v); 1419 } 1420 } 1421 1422 HDHomeRunTunerIndex::HDHomeRunTunerIndex() 1386 HDHomeRunDeviceID::HDHomeRunDeviceID(const CaptureCard &parent) : 1387 MythUITextEditSetting( 1388 new CaptureCardDBStorage(this, parent, "videodevice")) 1423 1389 { 1424 setLabel(QObject::tr("Tuner")); 1425 setEnabled(false); 1390 setLabel(QObject::tr("Devices")); 1391 setHelpText( 1392 QObject::tr( 1393 "Device IDs, IP addresses or hostnames of HDHomerun devices. " 1394 "Separate values by ',' to pool the tuners from multiple devices. " 1395 "When devices are pooled, all devices must support the same set " 1396 "of channels.")); 1426 1397 connect(this, SIGNAL(valueChanged( const QString&)), 1427 1398 this, SLOT( UpdateDevices(const QString&))); 1428 _oldValue = "";1429 1399 }; 1430 1400 1431 void HDHomeRun TunerIndex::setEnabled(bool e)1401 void HDHomeRunDeviceID::UpdateDevices(const QString &v) 1432 1402 { 1433 MythUITextEditSetting::setEnabled(e); 1434 if (e) { 1435 if (!_oldValue.isEmpty()) 1436 setValue(_oldValue); 1437 emit NewTuner(getValue()); 1438 } 1439 else 1440 { 1441 _oldValue = getValue(); 1442 } 1443 } 1444 1445 void HDHomeRunTunerIndex::UpdateDevices(const QString &v) 1446 { 1447 if (isEnabled()) 1448 { 1449 #if 0 1450 LOG(VB_GENERAL, LOG_DEBUG, QString("Emitting NewTuner(%1)").arg(v)); 1451 #endif 1452 emit NewTuner(v); 1453 } 1454 } 1455 1456 HDHomeRunDeviceID::HDHomeRunDeviceID(const CaptureCard &parent) : 1457 MythUITextEditSetting(new CaptureCardDBStorage(this, parent, "videodevice")) 1458 { 1459 setLabel(tr("Device ID")); 1460 setHelpText(tr("Device ID of HDHomeRun device")); 1461 setEnabled(false); 1462 } 1463 1464 void HDHomeRunDeviceID::SetIP(const QString &ip) 1465 { 1466 #if 0 1467 LOG(VB_GENERAL, LOG_DEBUG, QString("Setting IP to %1").arg(ip)); 1468 #endif 1469 _ip = ip; 1470 setValue(QString("%1-%2").arg(_ip).arg(_tuner)); 1471 #if 0 1472 LOG(VB_GENERAL, LOG_DEBUG, QString("Done Setting IP to %1").arg(ip)); 1473 #endif 1474 } 1475 1476 void HDHomeRunDeviceID::SetTuner(const QString &tuner) 1477 { 1478 #if 0 1479 LOG(VB_GENERAL, LOG_DEBUG, QString("Setting Tuner to %1").arg(tuner)); 1480 #endif 1481 _tuner = tuner; 1482 setValue(QString("%1-%2").arg(_ip).arg(_tuner)); 1483 #if 0 1484 LOG(VB_GENERAL, LOG_DEBUG, QString("Done Setting Tuner to %1").arg(tuner)); 1485 #endif 1486 } 1487 1488 void HDHomeRunDeviceID::SetOverrideDeviceID(const QString &deviceid) 1489 { 1490 _overridedeviceid = deviceid; 1491 setValue(deviceid); 1492 } 1493 1494 void HDHomeRunDeviceID::Load(void) 1495 { 1496 GetStorage()->Load(); 1497 if (!_overridedeviceid.isEmpty()) 1498 { 1499 setValue(_overridedeviceid); 1500 _overridedeviceid.clear(); 1501 } 1403 emit NewDeviceID(v); 1502 1404 } 1503 1405 1504 1406 HDHomeRunDeviceIDList::HDHomeRunDeviceIDList( 1505 HDHomeRunDeviceID *deviceid,1506 1407 StandardSetting *desc, 1507 HDHomeRunIP*cardip,1508 HDHomeRun TunerIndex *cardtuner,1408 StandardSetting *cardip, 1409 HDHomeRunDeviceID *deviceid, 1509 1410 HDHomeRunDeviceList *devicelist, 1510 1411 const CaptureCard &parent) : 1511 _deviceid(deviceid),1512 1412 _desc(desc), 1513 1413 _cardip(cardip), 1514 _ cardtuner(cardtuner),1414 _deviceid(deviceid), 1515 1415 _devicelist(devicelist), 1516 1416 m_parent(parent) 1517 1417 { 1518 1418 setLabel(QObject::tr("Available devices")); 1519 1419 setHelpText( 1520 1420 QObject::tr( 1521 "Device ID and Tuner Numberof available HDHomeRun devices."));1421 "Device ID of available HDHomeRun devices.")); 1522 1422 1523 1423 connect(this, SIGNAL(valueChanged( const QString&)), 1524 1424 this, SLOT( UpdateDevices(const QString&))); … … void HDHomeRunDeviceIDList::fillSelections(const QString &cur) 1553 1453 } 1554 1454 } 1555 1455 1556 QString man_addr = HDHomeRunDeviceIDList::tr("Manually Enter IP Address");1456 QString man_addr = HDHomeRunDeviceIDList::tr("Manually Enter Devices"); 1557 1457 QString sel = man_addr; 1558 1458 devs.push_back(sel); 1559 1459 1560 if (3 == devs.size() && current.startsWith("FFFFFFFF", Qt::CaseInsensitive)) 1460 if (devs.size() > 0 && 1461 current.compare("FFFFFFFF", Qt::CaseInsensitive) == 0) 1561 1462 { 1562 current = sel = (current.endsWith("0")) ? 1563 *(devs.begin()) : *(++devs.begin()); 1463 current = sel = *(devs.begin()); 1564 1464 } 1565 1465 else 1566 1466 { … … void HDHomeRunDeviceIDList::fillSelections(const QString &cur) 1579 1479 desc = (current == devs[i]) ? dev : desc; 1580 1480 addSelection(desc, dev, dev == sel); 1581 1481 } 1582 1583 if (current != cur)1584 {1585 _deviceid->SetOverrideDeviceID(current);1586 }1587 else if (sel == man_addr && !current.isEmpty())1588 {1589 // Populate the proper values for IP address and tuner1590 QStringList selection = current.split("-");1591 1592 _cardip->SetOldValue(selection.first());1593 _cardtuner->SetOldValue(selection.last());1594 1595 _cardip->setValue(selection.first());1596 _cardtuner->setValue(selection.last());1597 }1598 1482 } 1599 1483 1600 1484 void HDHomeRunDeviceIDList::Load(void) … … void HDHomeRunDeviceIDList::Load(void) 1608 1492 1609 1493 void HDHomeRunDeviceIDList::UpdateDevices(const QString &v) 1610 1494 { 1611 #if 0 1612 LOG(VB_GENERAL, LOG_DEBUG, QString("Got signal with %1").arg(v)); 1613 #endif 1614 if (v == HDHomeRunDeviceIDList::tr("Manually Enter IP Address")) 1615 { 1616 _cardip->setEnabled(true); 1617 _cardtuner->setEnabled(true); 1618 #if 0 1619 LOG(VB_GENERAL, LOG_DEBUG, "Done"); 1620 #endif 1621 } 1622 else if (!v.isEmpty()) 1495 if (!v.isEmpty()) 1623 1496 { 1624 if (_oldValue == HDHomeRunDeviceIDList::tr("Manually Enter IP Address")) 1625 { 1626 _cardip->setEnabled(false); 1627 _cardtuner->setEnabled(false); 1628 } 1629 _deviceid->setValue(v); 1630 1631 // Update _cardip and cardtuner 1632 _cardip->setValue((*_devicelist)[v].cardip); 1633 _cardtuner->setValue(QString("%1").arg((*_devicelist)[v].cardtuner)); 1497 _deviceid->setValue((*_devicelist)[v].mythdeviceid); 1634 1498 _desc->setValue((*_devicelist)[v].desc); 1499 _cardip->setValue((*_devicelist)[v].cardip); 1635 1500 } 1636 1501 _oldValue = v; 1637 1502 }; … … HDHomeRunConfigurationGroup::HDHomeRunConfigurationGroup 2087 1952 // Fill Device list 2088 1953 FillDeviceList(); 2089 1954 2090 deviceid = new HDHomeRunDeviceID(parent);2091 1955 desc = new GroupSetting(); 2092 1956 desc->setLabel(tr("Description")); 2093 cardip = new HDHomeRunIP(); 2094 cardtuner = new HDHomeRunTunerIndex(); 1957 cardip = new GroupSetting(); 1958 cardip->setLabel(tr("IP Address")); 1959 deviceid = new HDHomeRunDeviceID(parent); 2095 1960 deviceidlist = new HDHomeRunDeviceIDList( 2096 de viceid, desc, cardip, cardtuner, &devicelist, parent);1961 desc, cardip, deviceid, &devicelist, parent); 2097 1962 2098 1963 a_cardtype.addTargetedChild("HDHOMERUN", deviceidlist); 2099 1964 a_cardtype.addTargetedChild("HDHOMERUN", new EmptyAudioDevice(parent)); 2100 1965 a_cardtype.addTargetedChild("HDHOMERUN", new EmptyVBIDevice(parent)); 2101 a_cardtype.addTargetedChild("HDHOMERUN", deviceid);2102 1966 a_cardtype.addTargetedChild("HDHOMERUN", desc); 2103 1967 a_cardtype.addTargetedChild("HDHOMERUN", cardip); 2104 a_cardtype.addTargetedChild("HDHOMERUN", cardtuner);1968 a_cardtype.addTargetedChild("HDHOMERUN", deviceid); 2105 1969 2106 1970 GroupSetting *buttonRecOpt = new GroupSetting(); 2107 1971 buttonRecOpt->setLabel(tr("Recording Options")); … … HDHomeRunConfigurationGroup::HDHomeRunConfigurationGroup 2109 1973 buttonRecOpt->addChild(new ChannelTimeout(parent, 3000, 1750)); 2110 1974 buttonRecOpt->addChild(new HDHomeRunEITScan(parent)); 2111 1975 a_cardtype.addTargetedChild("HDHOMERUN", buttonRecOpt); 2112 2113 connect(cardip, SIGNAL(NewIP(const QString&)),2114 deviceid, SLOT( SetIP(const QString&)));2115 connect(cardtuner, SIGNAL(NewTuner(const QString&)),2116 deviceid, SLOT( SetTuner(const QString&)));2117 1976 }; 2118 1977 2119 1978 void HDHomeRunConfigurationGroup::FillDeviceList(void) … … void HDHomeRunConfigurationGroup::FillDeviceList(void) 2132 1991 QStringList devinfo = dev.split(" "); 2133 1992 QString devid = devinfo.at(0); 2134 1993 QString devip = devinfo.at(1); 2135 QString devtuner = devinfo.at(2); 1994 QString devtuner = ""; 1995 if (devinfo.size() > 2) 1996 devtuner = devinfo.at(2); 2136 1997 2137 1998 HDHomeRunDevice tmpdevice; 2138 tmpdevice.deviceid = devid;2139 1999 tmpdevice.desc = CardUtil::GetHDHRdesc(devid); 2140 2000 tmpdevice.cardip = devip; 2141 2001 tmpdevice.inuse = false; 2142 2002 tmpdevice.discovered = true; 2143 tmpdevice.cardtuner = devtuner; 2144 tmpdevice.mythdeviceid = 2145 tmpdevice.deviceid + "-" + tmpdevice.cardtuner; 2003 tmpdevice.mythdeviceid = devid; 2146 2004 devicelist[tmpdevice.mythdeviceid] = tmpdevice; 2147 2005 } 2148 2006 uint found_device_count = devicelist.size(); … … void HDHomeRunConfigurationGroup::FillDeviceList(void) 2190 2048 QMap<QString, HDHomeRunDevice>::iterator debugit; 2191 2049 for (debugit = devicelist.begin(); debugit != devicelist.end(); ++debugit) 2192 2050 { 2193 LOG(VB_GENERAL, LOG_DEBUG, QString("%1: %2 %3 %4 %5 %6 %7")2051 LOG(VB_GENERAL, LOG_DEBUG, QString("%1: %2 %3 %4 %5 %6") 2194 2052 .arg(debugit.key()) 2195 2053 .arg((*debugit).mythdeviceid) 2196 2054 .arg((*debugit).deviceid) 2197 .arg((*debugit).cardip) 2198 .arg((*debugit).cardtuner) 2055 .arg((*debugit).deviceid) 2199 2056 .arg((*debugit).inuse) 2200 2057 .arg((*debugit).discovered)); 2201 2058 } … … bool HDHomeRunConfigurationGroup::ProbeCard(HDHomeRunDevice &tmpdevice) 2213 2070 { 2214 2071 uint device_id = hdhomerun_device_get_device_id(thisdevice); 2215 2072 uint device_ip = hdhomerun_device_get_device_ip(thisdevice); 2216 uint tuner = hdhomerun_device_get_tuner(thisdevice);2217 2073 hdhomerun_device_destroy(thisdevice); 2218 2074 2219 if (device_id == 0) 2220 tmpdevice.deviceid = "NOTFOUND"; 2221 else 2075 if (device_id != 0) 2222 2076 { 2223 tmpdevice.deviceid = QString("%1").arg(device_id, 8, 16); 2224 tmpdevice.desc = CardUtil::GetHDHRdesc(tmpdevice.deviceid); 2077 tmpdevice.desc = CardUtil::GetHDHRdesc(tmpdevice.mythdeviceid); 2225 2078 } 2226 2079 2227 tmpdevice.deviceid = tmpdevice.deviceid.toUpper();2228 2229 2080 tmpdevice.cardip = QString("%1.%2.%3.%4") 2230 2081 .arg((device_ip>>24) & 0xFF).arg((device_ip>>16) & 0xFF) 2231 2082 .arg((device_ip>> 8) & 0xFF).arg((device_ip>> 0) & 0xFF); 2232 2083 2233 tmpdevice.cardtuner = QString("%1").arg(tuner);2234 2084 return true; 2235 2085 } 2236 2086 #endif // USING_HDHOMERUN -
mythtv/libs/libmythtv/videosource.h
diff --git a/mythtv/libs/libmythtv/videosource.h b/mythtv/libs/libmythtv/videosource.h index a18fde4ee7..4682846157 100644
a b class HDHomeRunDevice 384 384 { 385 385 public: 386 386 QString mythdeviceid; 387 QString deviceid;388 387 QString desc; 389 388 QString cardip; 390 QString cardtuner;389 QString deviceid; 391 390 bool inuse; 392 391 bool discovered; 393 392 }; … … typedef QMap<QString, HDHomeRunDevice> HDHomeRunDeviceList; 396 395 397 396 class HDHomeRunDeviceIDList; 398 397 class HDHomeRunDeviceID; 399 class HDHomeRunIP;400 class HDHomeRunTunerIndex;401 398 class HDHomeRunConfigurationGroup : public GroupSetting 402 399 { 403 400 Q_OBJECT … … class HDHomeRunConfigurationGroup : public GroupSetting 414 411 private: 415 412 CaptureCard &parent; 416 413 StandardSetting *desc; 414 StandardSetting *cardip; 417 415 HDHomeRunDeviceIDList *deviceidlist; 418 416 HDHomeRunDeviceID *deviceid; 419 HDHomeRunIP *cardip;420 HDHomeRunTunerIndex *cardtuner;421 417 HDHomeRunDeviceList devicelist; 422 418 }; 423 419 … … class CardInput : public GroupSetting 878 874 MythUICheckBoxSetting *schedgroup; 879 875 }; 880 876 881 class HDHomeRunDeviceID; 882 class HDHomeRunTunerIndex; 883 884 class HDHomeRunIP : public MythUITextEditSetting 885 { 886 Q_OBJECT 887 888 public: 889 HDHomeRunIP(); 890 891 void setEnabled(bool e) override; // StandardSetting 892 void SetOldValue(const QString &s) 893 { _oldValue = s; _oldValue.detach(); }; 894 895 signals: 896 void NewIP(const QString&); 897 898 public slots: 899 void UpdateDevices(const QString&); 900 901 private: 902 QString _oldValue; 903 }; 904 905 class HDHomeRunTunerIndex : public MythUITextEditSetting 877 class HDHomeRunDeviceID : public MythUITextEditSetting 906 878 { 907 879 Q_OBJECT 908 880 909 881 public: 910 HDHomeRunTunerIndex(); 911 912 void setEnabled(bool e) override; // StandardSetting 913 void SetOldValue(const QString &s) 914 { _oldValue = s; _oldValue.detach(); }; 882 HDHomeRunDeviceID(const CaptureCard &parent); 915 883 916 884 signals: 917 void New Tuner(const QString&);885 void NewDeviceID(const QString&); 918 886 919 887 public slots: 920 888 void UpdateDevices(const QString&); 921 922 private:923 QString _oldValue;924 889 }; 925 890 926 927 891 class HDHomeRunDeviceIDList : public TransMythUIComboBoxSetting 928 892 { 929 893 Q_OBJECT 930 894 931 895 public: 932 HDHomeRunDeviceIDList(HDHomeRunDeviceID *deviceid, 933 StandardSetting *desc, 934 HDHomeRunIP *cardip, 935 HDHomeRunTunerIndex *cardtuner, 896 HDHomeRunDeviceIDList(StandardSetting *desc, 897 StandardSetting *cardip, 898 HDHomeRunDeviceID *deviceid, 936 899 HDHomeRunDeviceList *devicelist, 937 900 const CaptureCard &parent); 938 901 … … class HDHomeRunDeviceIDList : public TransMythUIComboBoxSetting 944 907 void UpdateDevices(const QString&); 945 908 946 909 private: 947 HDHomeRunDeviceID *_deviceid;948 910 StandardSetting *_desc; 949 HDHomeRunIP*_cardip;950 HDHomeRun TunerIndex *_cardtuner;911 StandardSetting *_cardip; 912 HDHomeRunDeviceID *_deviceid; 951 913 HDHomeRunDeviceList *_devicelist; 952 914 const CaptureCard &m_parent; 953 915 954 916 QString _oldValue; 955 917 }; 956 918 957 class HDHomeRunDeviceID : public MythUITextEditSetting958 {959 Q_OBJECT960 961 public:962 explicit HDHomeRunDeviceID(const CaptureCard &parent);963 964 void Load(void) override; // StandardSetting965 966 public slots:967 void SetIP(const QString&);968 void SetTuner(const QString&);969 void SetOverrideDeviceID(const QString&);970 971 private:972 QString _ip;973 QString _tuner;974 QString _overridedeviceid;975 };976 977 919 /// 978 920 class VBoxDeviceID; 979 921 class VBoxTunerIndex;