Ticket #13528: 20191204-masterlock.patch

File 20191204-masterlock.patch, 5.3 KB (added by Klaas de Waal, 3 months ago)

Single implementation of GetMasterLock? and ReturnMasterLock?

  • mythtv/libs/libmythtv/recorders/dvbchannel.cpp

    diff --git a/mythtv/libs/libmythtv/recorders/dvbchannel.cpp b/mythtv/libs/libmythtv/recorders/dvbchannel.cpp
    index 87e69fcfaa..b0c9950417 100644
    a b void DVBChannel::CheckOptions(DTVMultiplex &tuning) const 
    357357    // DVB-S needs a fully initialized diseqc tree and is checked later in Tune
    358358    if (!m_diseqc_tree)
    359359    {
    360         const DVBChannel *master = GetMasterLock();
     360        DVBChannel *master = GetMasterLock();
    361361        if (master == nullptr || !master->m_diseqc_tree)
    362362            CheckFrequency(tuning.m_frequency);
    363363        ReturnMasterLock(master);
    bool DVBChannel::IsTuningParamsProbeSupported(void) const 
    858858        return false;
    859859    }
    860860
    861     const DVBChannel *master = GetMasterLock();
     861    DVBChannel *master = GetMasterLock();
    862862    if (master != this)
    863863    {
    864864        bool ok = master->IsTuningParamsProbeSupported();
    bool DVBChannel::ProbeTuningParams(DTVMultiplex &tuning) const 
    904904        return false;
    905905    }
    906906
    907     const DVBChannel *master = GetMasterLock();
     907    DVBChannel *master = GetMasterLock();
    908908    if (master != this)
    909909    {
    910910        bool ok = master->ProbeTuningParams(tuning);
    const DiSEqCDevRotor *DVBChannel::GetRotor(void) const 
    10081008// documented in dvbchannel.h
    10091009bool DVBChannel::HasLock(bool *ok) const
    10101010{
    1011     const DVBChannel *master = GetMasterLock();
     1011    DVBChannel *master = GetMasterLock();
    10121012    if (master != this)
    10131013    {
    10141014        bool haslock = master->HasLock(ok);
    double DVBChannel::GetSignalStrengthDVBv5(bool *ok) const 
    10911091// documented in dvbchannel.h
    10921092double DVBChannel::GetSignalStrength(bool *ok) const
    10931093{
    1094     const DVBChannel *master = GetMasterLock();
     1094    DVBChannel *master = GetMasterLock();
    10951095    if (master != this)
    10961096    {
    10971097        double val = master->GetSignalStrength(ok);
    double DVBChannel::GetSNRDVBv5(bool *ok) const 
    11741174// documented in dvbchannel.h
    11751175double DVBChannel::GetSNR(bool *ok) const
    11761176{
    1177     const DVBChannel *master = GetMasterLock();
     1177    DVBChannel *master = GetMasterLock();
    11781178    if (master != this)
    11791179    {
    11801180        double val = master->GetSNR(ok);
    double DVBChannel::GetBitErrorRateDVBv5(bool *ok) const 
    12541254// documented in dvbchannel.h
    12551255double DVBChannel::GetBitErrorRate(bool *ok) const
    12561256{
    1257     const DVBChannel *master = GetMasterLock();
     1257    DVBChannel *master = GetMasterLock();
    12581258    if (master != this)
    12591259    {
    12601260        double val = master->GetBitErrorRate(ok);
    double DVBChannel::GetUncorrectedBlockCountDVBv5(bool *ok) const 
    13191319// documented in dvbchannel.h
    13201320double DVBChannel::GetUncorrectedBlockCount(bool *ok) const
    13211321{
    1322     const DVBChannel *master = GetMasterLock();
     1322    DVBChannel *master = GetMasterLock();
    13231323    if (master != this)
    13241324    {
    13251325        double val = master->GetUncorrectedBlockCount(ok);
    double DVBChannel::GetUncorrectedBlockCount(bool *ok) const 
    13461346    return (double) ublocks;
    13471347}
    13481348
    1349 DVBChannel *DVBChannel::GetMasterLock(void)
    1350 {
    1351     QString key = CardUtil::GetDeviceName(DVB_DEV_FRONTEND, m_device);
    1352     if (m_pParent)
    1353         key += QString(":%1")
    1354             .arg(CardUtil::GetSourceID(m_pParent->GetInputId()));
    1355     DTVChannel *master = DTVChannel::GetMasterLock(key);
    1356     auto *dvbm = dynamic_cast<DVBChannel*>(master);
    1357     if (master && !dvbm)
    1358         DTVChannel::ReturnMasterLock(master);
    1359     return dvbm;
    1360 }
    1361 
    1362 void DVBChannel::ReturnMasterLock(DVBChannelP &dvbm)
     1349void DVBChannel::ReturnMasterLock(DVBChannel* &dvbm)
    13631350{
    13641351    auto *chan = static_cast<DTVChannel*>(dvbm);
    13651352    DTVChannel::ReturnMasterLock(chan);
    13661353    dvbm = nullptr;
    13671354}
    13681355
    1369 const DVBChannel *DVBChannel::GetMasterLock(void) const
     1356DVBChannel *DVBChannel::GetMasterLock(void) const
    13701357{
    13711358    QString key = CardUtil::GetDeviceName(DVB_DEV_FRONTEND, m_device);
    13721359    if (m_pParent)
    const DVBChannel *DVBChannel::GetMasterLock(void) const 
    13791366    return dvbm;
    13801367}
    13811368
    1382 void DVBChannel::ReturnMasterLock(DVBChannelCP &dvbm)
    1383 {
    1384     auto *chan = static_cast<DTVChannel*>(const_cast<DVBChannel*>(dvbm));
    1385     DTVChannel::ReturnMasterLock(chan);
    1386     dvbm = nullptr;
    1387 }
    1388 
    13891369bool DVBChannel::IsMaster(void) const
    13901370{
    1391     const DVBChannel *master = GetMasterLock();
     1371    DVBChannel *master = GetMasterLock();
    13921372    bool is_master = (master == this);
    13931373    ReturnMasterLock(master);
    13941374    return is_master;
  • mythtv/libs/libmythtv/recorders/dvbchannel.h

    diff --git a/mythtv/libs/libmythtv/recorders/dvbchannel.h b/mythtv/libs/libmythtv/recorders/dvbchannel.h
    index abd4d125a2..665eaa6dec 100644
    a b class DVBChannel : public DTVChannel 
    102102    bool CheckModulation(DTVModulation modulation) const;
    103103    bool CheckCodeRate(DTVCodeRate rate) const;
    104104
    105     using DVBChannelP = DVBChannel*;
    106     DVBChannel *GetMasterLock(void);
    107     static void ReturnMasterLock(DVBChannelP &dvbm);
    108 
    109     using DVBChannelCP = const DVBChannel*;
    110     const DVBChannel *GetMasterLock(void) const;
    111     static void ReturnMasterLock(DVBChannelCP &dvbm);
     105    DVBChannel *GetMasterLock(void) const;
     106    static void ReturnMasterLock(DVBChannel* &dvbm);
    112107
    113108    /// \brief Get Signal strength from the DVBv5 interface [0-1.0]
    114109    /// It is transformed to a linear relative scale if provided in dB