Ticket #13339: hdhr-locking-pooling-2.patch
File hdhr-locking-pooling-2.patch, 30.4 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..9380d4a15d 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::GetMasterId(void) 841 { 842 return m_pParent ? m_pParent->GetMasterId() : 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..2898090a5a 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 master input ID 104 int GetMasterId(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 faca66682e..111576d8d8 100644
a b bool HDHRChannel::Open(void) 59 59 if (IsOpen()) 60 60 return true; 61 61 62 _stream_handler = HDHRStreamHandler::Get(_device_id );62 _stream_handler = HDHRStreamHandler::Get(_device_id, GetMasterId()); 63 63 64 64 _tuner_types = _stream_handler->GetTunerTypes(); 65 65 tunerType = (_tuner_types.empty()) ? … … void HDHRChannel::Close(void) 86 86 87 87 bool HDHRChannel::EnterPowerSavingMode(void) 88 88 { 89 if (IsOpen()) 90 return _stream_handler->EnterPowerSavingMode(); 91 else 92 return true; 89 Close(); 90 return true; 93 91 } 94 92 95 93 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..dfe079022a 100644
a b bool HDHRRecorder::Open(void) 36 36 ResetForNewFile(); 37 37 38 38 _stream_handler = HDHRStreamHandler::Get(_channel->GetDevice(), 39 _channel->GetMasterId(), 39 40 (tvrec ? tvrec->GetInputId() : -1)); 40 41 41 42 LOG(VB_RECORD, LOG_INFO, LOC + "HDHR opened successfully"); -
mythtv/libs/libmythtv/recorders/hdhrsignalmonitor.cpp
diff --git a/mythtv/libs/libmythtv/recorders/hdhrsignalmonitor.cpp b/mythtv/libs/libmythtv/recorders/hdhrsignalmonitor.cpp index e15fe16538..fbddd3821a 100644
a b HDHRSignalMonitor::HDHRSignalMonitor(int db_cardnum, 51 51 52 52 AddFlags(kSigMon_WaitForSig); 53 53 54 streamHandler = HDHRStreamHandler::Get(_channel->GetDevice()); 54 streamHandler = HDHRStreamHandler::Get(_channel->GetDevice(), 55 _channel->GetMasterId()); 55 56 } 56 57 57 58 /** \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 7eed3abf80..63061cb837 100644
a b 19 19 #include "cardutil.h" 20 20 #include "mythlogging.h" 21 21 22 #define LOC QString("HDHRSH%1(%2 ): ").arg(_recorder_ids_string) \23 .arg(_device)22 #define LOC QString("HDHRSH%1(%2,%3): ").arg(_recorder_ids_string) \ 23 .arg(_devkey).arg(_device) 24 24 25 QMap< QString,HDHRStreamHandler*>HDHRStreamHandler::_handlers;26 QMap< QString,uint>HDHRStreamHandler::_handlers_refcnt;25 QMap<int,HDHRStreamHandler*> HDHRStreamHandler::_handlers; 26 QMap<int,uint> HDHRStreamHandler::_handlers_refcnt; 27 27 QMutex HDHRStreamHandler::_handlers_lock; 28 HDHRDevSelectorCache HDHRStreamHandler::_selectors; 28 29 29 HDHRStreamHandler *HDHRStreamHandler::Get(const QString &devname, 30 HDHRStreamHandler *HDHRStreamHandler::Get(const QString &devname, int devkey, 30 31 int recorder_id) 31 32 { 32 33 QMutexLocker locker(&_handlers_lock); 33 34 34 QString devkey = devname.toUpper(); 35 36 QMap<QString,HDHRStreamHandler*>::iterator it = _handlers.find(devkey); 35 QMap<int,HDHRStreamHandler*>::iterator it = _handlers.find(devkey); 37 36 38 37 if (it == _handlers.end()) 39 38 { 40 HDHRStreamHandler *newhandler = new HDHRStreamHandler(dev key);39 HDHRStreamHandler *newhandler = new HDHRStreamHandler(devname, devkey); 41 40 newhandler->Open(); 42 41 _handlers[devkey] = newhandler; 43 42 _handlers_refcnt[devkey] = 1; … … void HDHRStreamHandler::Return(HDHRStreamHandler * & ref, int recorder_id) 64 63 { 65 64 QMutexLocker locker(&_handlers_lock); 66 65 67 QString devname = ref->_device;66 int devkey = ref->_devkey; 68 67 69 QMap< QString,uint>::iterator rit = _handlers_refcnt.find(devname);68 QMap<int,uint>::iterator rit = _handlers_refcnt.find(devkey); 70 69 if (rit == _handlers_refcnt.end()) 71 70 return; 72 71 73 QMap< QString,HDHRStreamHandler*>::iterator it = _handlers.find(devname);72 QMap<int,HDHRStreamHandler*>::iterator it = _handlers.find(devkey); 74 73 if (it != _handlers.end()) 75 74 (*it)->DelRecorderId(recorder_id); 76 75 … … void HDHRStreamHandler::Return(HDHRStreamHandler * & ref, int recorder_id) 84 83 if ((it != _handlers.end()) && (*it == ref)) 85 84 { 86 85 LOG(VB_RECORD, LOG_INFO, QString("HDHRSH: Closing handler for %1") 87 .arg(dev name));86 .arg(devkey)); 88 87 ref->Close(); 89 88 delete *it; 90 89 _handlers.erase(it); … … void HDHRStreamHandler::Return(HDHRStreamHandler * & ref, int recorder_id) 93 92 { 94 93 LOG(VB_GENERAL, LOG_ERR, 95 94 QString("HDHRSH Error: Couldn't find handler for %1") 96 .arg(dev name));95 .arg(devkey)); 97 96 } 98 97 99 98 _handlers_refcnt.erase(rit); 100 99 ref = nullptr; 101 100 } 102 101 103 HDHRStreamHandler::HDHRStreamHandler(const QString &device ) :102 HDHRStreamHandler::HDHRStreamHandler(const QString &device, int devkey) : 104 103 StreamHandler(device), 105 104 _hdhomerun_device(nullptr), 106 105 _tuner(-1), 107 106 _tune_mode(hdhrTuneModeNone), 107 _devkey(devkey), 108 108 _hdhr_lock(QMutex::Recursive) 109 109 { 110 110 setObjectName("HDHRStreamHandler"); … … HDHRStreamHandler::HDHRStreamHandler(const QString &device) : 115 115 */ 116 116 void HDHRStreamHandler::run(void) 117 117 { 118 int tunerLock = 0;119 char *error = nullptr;120 121 118 RunProlog(); 122 /* Get a tuner lock */ 123 tunerLock = hdhomerun_device_tuner_lockkey_request(_hdhomerun_device, &error); 124 if(tunerLock < 1) 125 { 126 LOG(VB_GENERAL, LOG_ERR, LOC + 127 QString("Get tuner lock failed. Aborting. Error: %1").arg(error)); 128 _error = true; 129 RunEpilog(); 130 return; 131 } 119 132 120 /* Create TS socket. */ 133 121 if (!hdhomerun_device_stream_start(_hdhomerun_device)) 134 122 { … … void HDHRStreamHandler::run(void) 226 214 227 215 LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): " + "end"); 228 216 229 if(tunerLock == 1)230 {231 LOG(VB_RECORD, LOG_INFO, LOC + "Release tuner lock.");232 hdhomerun_device_tuner_lockkey_release(_hdhomerun_device);233 }234 235 217 SetRunning(false, false, false); 218 236 219 RunEpilog(); 237 220 } 238 221 … … void HDHRStreamHandler::Close(void) 366 349 if (_hdhomerun_device) 367 350 { 368 351 TuneChannel("none"); 369 hdhomerun_device_ destroy(_hdhomerun_device);352 hdhomerun_device_tuner_lockkey_release(_hdhomerun_device); 370 353 _hdhomerun_device = nullptr; 371 354 } 372 355 } 373 356 374 357 bool HDHRStreamHandler::Connect(void) 375 358 { 376 _hdhomerun_device = hdhomerun_device_create_from_str( 377 _device.toLocal8Bit().constData(), nullptr); 378 379 if (!_hdhomerun_device) 359 hdhomerun_device_selector_t *selector = _selectors.Get(_devkey, _device); 360 if (!selector) 380 361 { 381 LOG(VB_GENERAL, LOG_ERR, LOC + "Unable to create hdhomerun object"); 362 LOG(VB_GENERAL, LOG_ERR, LOC + 363 QString("Unable to get device selector")); 382 364 return false; 383 365 } 384 366 385 _ tuner = hdhomerun_device_get_tuner(_hdhomerun_device);386 387 if ( hdhomerun_device_get_local_machine_addr(_hdhomerun_device) == 0)367 _hdhomerun_device = hdhomerun_device_selector_choose_and_lock( 368 selector, nullptr); 369 if (!_hdhomerun_device) 388 370 { 389 LOG(VB_GENERAL, LOG_ERR, LOC + "Unable to connect to device"); 371 LOG(VB_GENERAL, LOG_ERR, LOC + 372 QString("Unable to find a free device")); 390 373 return false; 391 374 } 392 375 393 LOG(VB_RECORD, LOG_INFO, LOC + "Successfully connected to device"); 394 return true; 395 } 376 _tuner = hdhomerun_device_get_tuner(_hdhomerun_device); 396 377 397 bool HDHRStreamHandler::EnterPowerSavingMode(void) 398 { 399 QMutexLocker locker(&_listener_lock);378 LOG(VB_GENERAL, LOG_INFO, LOC + 379 QString("Connected to device(%1)") 380 .arg(hdhomerun_device_get_name(_hdhomerun_device))); 400 381 401 if (!_stream_data_list.empty()) 402 { 403 LOG(VB_RECORD, LOG_INFO, LOC + 404 "Ignoring request - video streaming active"); 405 return false; 406 } 407 else 408 { 409 locker.unlock(); // _listener_lock 410 return TuneChannel("none"); 411 } 382 return true; 412 383 } 413 384 414 385 QString HDHRStreamHandler::TunerGet( … … bool HDHRStreamHandler::TuneVChannel(const QString &vchn) 551 522 LOG(VB_RECORD, LOG_INFO, LOC + QString("Tuning vchannel %1").arg(vchn)); 552 523 return !TunerSet("vchannel", vchn).isEmpty(); 553 524 } 525 526 HDHRDevSelectorCache::HDHRDevSelectorCache(void) 527 : _map() 528 { 529 } 530 531 HDHRDevSelectorCache::~HDHRDevSelectorCache(void) 532 { 533 while (_map.size()) 534 { 535 hdhomerun_device_selector_t *selector = _map.first(); 536 hdhomerun_device_selector_destroy(selector, true); 537 _map.erase(_map.begin()); 538 } 539 } 540 541 hdhomerun_device_selector_t *HDHRDevSelectorCache::Get(int devkey, 542 QString device) 543 { 544 QMap<int, hdhomerun_device_selector_t*>::iterator iter; 545 iter = _map.find(devkey); 546 if (iter != _map.end()) 547 return *iter; 548 549 hdhomerun_device_selector_t *selector = 550 hdhomerun_device_selector_create(nullptr); 551 _map[devkey] = selector; 552 553 if (!selector) 554 { 555 LOG(VB_GENERAL, LOG_ERR, 556 QString("HDHRDevSelectorCache::Get(%1): " 557 "Unable to create device selector").arg(device)); 558 return nullptr; 559 } 560 561 QStringList devices = device.split(","); 562 for (int i = 0; i < devices.size(); ++i) 563 { 564 QByteArray ba = devices[i].toUtf8(); 565 int n = hdhomerun_device_selector_load_from_str(selector, ba.data()); 566 LOG(VB_GENERAL, LOG_INFO, 567 QString("HDHRDevSelectorCache::Get(%1): " 568 "Added %2 devices from %3") 569 .arg(device).arg(n).arg(devices[i])); 570 } 571 572 return selector; 573 } -
mythtv/libs/libmythtv/recorders/hdhrstreamhandler.h
diff --git a/mythtv/libs/libmythtv/recorders/hdhrstreamhandler.h b/mythtv/libs/libmythtv/recorders/hdhrstreamhandler.h index fd14751948..d3f8fc38aa 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 36 class HDHRDevSelectorCache 37 { 38 public: 39 HDHRDevSelectorCache(void); 40 ~HDHRDevSelectorCache(void); 41 hdhomerun_device_selector_t *Get(int devkey, QString device); 42 43 private: 44 HDHRDevSelectorCache(const HDHRDevSelectorCache&); 45 HDHRDevSelectorCache& operator=(const HDHRDevSelectorCache&); 46 47 QMap<int, hdhomerun_device_selector_t*> _map; 48 }; 49 35 50 enum HDHRTuneMode { 36 51 hdhrTuneModeNone = 0, 37 52 hdhrTuneModeFrequency, … … enum HDHRTuneMode { 49 64 class HDHRStreamHandler : public StreamHandler 50 65 { 51 66 public: 52 static HDHRStreamHandler *Get(const QString &devicename, 67 static HDHRStreamHandler *Get(const QString &devicename, int devkey, 53 68 int recorder_id = -1); 54 69 static void Return(HDHRStreamHandler * & ref, int recorder_id = -1); 55 70 … … class HDHRStreamHandler : public StreamHandler 69 84 bool TuneChannel(const QString &chanid); 70 85 bool TuneProgram(uint mpeg_prog_num); 71 86 bool TuneVChannel(const QString &vchn); 72 bool EnterPowerSavingMode(void);73 87 74 88 private: 75 explicit HDHRStreamHandler(const QString & );89 explicit HDHRStreamHandler(const QString &, int devkey); 76 90 77 91 bool Connect(void); 78 92 … … class HDHRStreamHandler : public StreamHandler 95 109 int _tuner; 96 110 vector<DTVTunerType> _tuner_types; 97 111 HDHRTuneMode _tune_mode; // debug self check 112 int _devkey; 98 113 99 114 mutable QMutex _hdhr_lock; 100 115 101 116 // for implementing Get & Return 102 117 static QMutex _handlers_lock; 103 static QMap<QString, HDHRStreamHandler*> _handlers; 104 static QMap<QString, uint> _handlers_refcnt; 118 static QMap<int, HDHRStreamHandler*> _handlers; 119 static QMap<int, uint> _handlers_refcnt; 120 static HDHRDevSelectorCache _selectors; 105 121 }; 106 122 107 123 #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..4d0ca5aa54 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 GetMasterId(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;