Ticket #12229: 20170408_sleepfix.patch

File 20170408_sleepfix.patch, 3.0 KB (added by Peter Bennett, 3 years ago)

Possible fix for sleep problem

  • mythtv/libs/libmyth/mythmediamonitor.cpp

    diff --git a/mythtv/libs/libmyth/mythmediamonitor.cpp b/mythtv/libs/libmyth/mythmediamonitor.cpp
    index f459dfe..3154e93 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            gCoreContext->ResetSockets();
     64        m_lastCheckTime = now;
    6065    }
    6166    mtx.unlock();
    6267    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..92683b8 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    if (d->m_serverSock)
     1738        d->m_serverSock->DisconnectFromHost();
     1739    if (d->m_eventSock)
     1740        d->m_eventSock->DisconnectFromHost();
     1741    dispatch(MythEvent("BACKEND_SOCKETS_CLOSED"));
     1742}
     1743
    17341744void MythCoreContext::InitLocale(void )
    17351745{
    17361746    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