Ticket #12664: 20170913_ticket_12664_slow_setup.patch

File 20170913_ticket_12664_slow_setup.patch, 2.9 KB (added by Peter Bennett, 2 years ago)

Cache probe results to speed card setup

  • mythtv/libs/libmythtv/cardutil.cpp

    diff --git a/mythtv/libs/libmythtv/cardutil.cpp b/mythtv/libs/libmythtv/cardutil.cpp
    index e6efacf..79f7bcc 100644
    a b QStringList CardUtil::GetVideoDevices(const QString &rawtype, QString hostname) 
    377377    return list;
    378378}
    379379
     380QMap <QString,QStringList> CardUtil::videoDeviceCache;
     381
     382void CardUtil::ClearVideoDeviceCache()
     383{
     384    videoDeviceCache.clear();
     385}
     386
     387
    380388QStringList CardUtil::ProbeVideoDevices(const QString &rawtype)
    381389{
     390    if (videoDeviceCache.contains(rawtype))
     391        return videoDeviceCache[rawtype];
     392
    382393    QStringList devs;
    383394
    384395    if (rawtype.toUpper() == "DVB")
    385396    {
    386397        QDir dir("/dev/dvb", "adapter*", QDir::Name, QDir::Dirs);
    387398        const QFileInfoList il = dir.entryInfoList();
    388         if (il.isEmpty())
    389             return devs;
    390399
    391400        QFileInfoList::const_iterator it = il.begin();
    392401
    QStringList CardUtil::ProbeVideoDevices(const QString &rawtype) 
    406415    {
    407416        QDir dir("/dev/", "asirx*", QDir::Name, QDir::System);
    408417        const QFileInfoList il = dir.entryInfoList();
    409         if (il.isEmpty())
    410             return devs;
    411418
    412419        QFileInfoList::const_iterator it = il.begin();
    413420        for (; it != il.end(); ++it)
    QStringList CardUtil::ProbeVideoDevices(const QString &rawtype) 
    435442        if (result == -1)
    436443        {
    437444            LOG(VB_GENERAL, LOG_ERR, "Error finding HDHomerun devices");
    438             return devs;
    439445        }
    440446
    441447        if (result >= max_count)
    QStringList CardUtil::ProbeVideoDevices(const QString &rawtype) 
    483489                                     .arg(rawtype));
    484490    }
    485491
     492    videoDeviceCache.insert(rawtype,devs);
    486493    return devs;
    487494}
    488495
  • mythtv/libs/libmythtv/cardutil.h

    diff --git a/mythtv/libs/libmythtv/cardutil.h b/mythtv/libs/libmythtv/cardutil.h
    index 79d4b9f..e74c4d5 100644
    a b class MTV_PUBLIC CardUtil 
    350350
    351351    // General info from OS
    352352    static QStringList  ProbeVideoDevices(const QString &rawtype);
     353    static void ClearVideoDeviceCache();
    353354
    354355    // Other
    355356    static bool         CloneCard(uint src_inputid, uint dst_inputid);
    class MTV_PUBLIC CardUtil 
    412413    static QStringList  ProbeV4LVideoInputs(QString device);
    413414    static QStringList  ProbeV4LAudioInputs(QString device);
    414415    static QStringList  ProbeDVBInputs(QString device);
     416    static QMap <QString,QStringList> videoDeviceCache;
    415417};
    416418
    417419#endif //_CARDUTIL_H_
  • mythtv/libs/libmythtv/videosource.cpp

    diff --git a/mythtv/libs/libmythtv/videosource.cpp b/mythtv/libs/libmythtv/videosource.cpp
    index 368f8b7..596f5e4 100644
    a b void CaptureCard::fillSelections(GroupSetting *setting) 
    28062806        return;
    28072807    }
    28082808
     2809    CardUtil::ClearVideoDeviceCache();
     2810
    28092811    while (query.next())
    28102812    {
    28112813        uint    cardid      = query.value(0).toUInt();