Ticket #12229: 20170410_sleepfix.patch

File 20170410_sleepfix.patch, 3.3 KB (added by Peter Bennett, 3 years ago)

Patch with code for LIRC added

  • mythtv/libs/libmyth/mythmediamonitor.cpp

    diff --git a/mythtv/libs/libmyth/mythmediamonitor.cpp b/mythtv/libs/libmyth/mythmediamonitor.cpp
    index f459dfe..c5faccc 100644
    a b MonitorThread::MonitorThread(MediaMonitor* pMon, unsigned long interval) : 
    4444{
    4545    m_Monitor = pMon;
    4646    m_Interval = interval;
     47    m_lastCheckTime = QDateTime::currentDateTimeUtc();
    4748}
    4849
    4950// Nice and simple, as long as our monitor is valid and active,
    void MonitorThread::run(void) 
    5758    {
    5859        m_Monitor->CheckDevices();
    5960        m_Monitor->m_wait.wait(&mtx, m_Interval);
     61        QDateTime now(QDateTime::currentDateTimeUtc());
     62        if (m_lastCheckTime.secsTo(now) > 60)
     63        {
     64            gCoreContext->ResetSockets();
     65            if (HasMythMainWindow())
     66            {
     67                LOG(VB_GENERAL, LOG_INFO, "Restarting LIRC handler");
     68                GetMythMainWindow()->StartLIRC();
     69            }
     70        }
     71        m_lastCheckTime = now;
    6072    }
    6173    mtx.unlock();
    6274    RunEpilog();
  • mythtv/libs/libmyth/mythmediamonitor.h

    diff --git a/mythtv/libs/libmyth/mythmediamonitor.h b/mythtv/libs/libmyth/mythmediamonitor.h
    index 66e8baa..bd681a3 100644
    a b  
    66#include <QMutex>
    77#include <QWaitCondition>
    88#include <QList>
     9#include <QDateTime>
    910
    1011#include "mthread.h"
    1112#include "mythexp.h"
    class MonitorThread : public MThread 
    3233  protected:
    3334    QPointer<MediaMonitor> m_Monitor;
    3435    unsigned long m_Interval;
     36    QDateTime m_lastCheckTime;
    3537};
    3638
    3739class MPUBLIC MediaMonitor : public QObject
  • mythtv/libs/libmythbase/mythcorecontext.cpp

    diff --git a/mythtv/libs/libmythbase/mythcorecontext.cpp b/mythtv/libs/libmythbase/mythcorecontext.cpp
    index 703916c..26926a0 100644
    a b void MythCoreContext::ResetLanguage(void) 
    17311731    d->language.clear();
    17321732}
    17331733
     1734void MythCoreContext::ResetSockets(void)
     1735{
     1736    QMutexLocker locker(&d->m_sockLock);
     1737    LOG(VB_GENERAL, LOG_INFO, "Restarting Backend Connections");
     1738    if (d->m_serverSock)
     1739        d->m_serverSock->DisconnectFromHost();
     1740    if (d->m_eventSock)
     1741        d->m_eventSock->DisconnectFromHost();
     1742    dispatch(MythEvent("BACKEND_SOCKETS_CLOSED"));
     1743}
     1744
    17341745void MythCoreContext::InitLocale(void )
    17351746{
    17361747    if (!d->m_locale)
  • mythtv/libs/libmythbase/mythcorecontext.h

    diff --git a/mythtv/libs/libmythbase/mythcorecontext.h b/mythtv/libs/libmythbase/mythcorecontext.h
    index 14d631c..4ca77e2 100644
    a b class MBASE_PUBLIC MythCoreContext : public QObject, public MythObservable, publ 
    202202    QString GetLanguage(void);
    203203    QString GetLanguageAndVariant(void);
    204204    void ResetLanguage(void);
     205    void ResetSockets(void);
    205206
    206207    void RegisterForPlayback(QObject *sender, const char *method);
    207208    void UnregisterForPlayback(QObject *sender);
    class MBASE_PUBLIC MythCoreContext : public QObject, public MythObservable, publ 
    236237    void emitTVPlaybackAborted(void)            { emit TVPlaybackAborted(); }
    237238    void emitTVPlaybackPlaying(void)            { emit TVPlaybackPlaying(); }
    238239
     240
    239241  signals:
    240242    void TVPlaybackStarted(void);
    241243    //// TVPlaybackStopped signal should be used in combination with