Ticket #1945: diseqc-sigmon-rotor.patch

File diseqc-sigmon-rotor.patch, 2.1 KB (added by yeasah@…, 19 years ago)

I like the idea of having the alterable rotor target position (so it can just use the WaitForPos flag like a normal signal monitor value), but the rotor monitor code wasn't quite right. This should fix it, and hopefully improve the clarity of the code.

  • libs/libmythtv/dvbsignalmonitor.cpp

     
    509509    }
    510510
    511511    // Rotor position
    512     const DiSEqCDevRotor *rotor = dvbchan->GetRotor();
    513     if (rotor && rotor->IsPositionKnown())
     512    if (HasFlags(kDVBSigMon_WaitForPos))
    514513    {
    515         double progress = rotor->GetProgress();
    516         QMutexLocker locker(&statusLock);
    517         if (progress >= 1.0 && !rotorPosition.IsGood())
     514        const DiSEqCDevRotor *rotor = dvbchan->GetRotor();
     515        if (rotor)
    518516        {
    519             DBG_SM("UpdateValues", "Retuning for rotor completion");
    520             dvbchan->Retune();
     517            bool was_moving, is_moving;
     518            {
     519                QMutexLocker locker(&statusLock);
     520                was_moving = rotorPosition.GetValue() < 100;
     521                rotorPosition.SetValue((int)truncf(rotor->GetProgress() * 100));
     522                is_moving  = rotorPosition.GetValue() < 100;
     523            }
     524           
     525            // Retune if move completes normally
     526            if (was_moving && !is_moving)
     527            {
     528                DBG_SM("UpdateValues", "Retuning for rotor completion");
     529                dvbchan->Retune();
    521530
    522             rotorPosition.SetValue(100);
     531                // No need to wait for SDT anymore
     532                RemoveFlags(kDTVSigMon_WaitForSDT);
     533            }
    523534        }
    524         else if (progress < 1.0)
     535       
     536        // If no rotor is present, pretend the movement is completed
     537        else
    525538        {
    526             if (rotorPosition.IsGood())
    527                 DBG_SM("UpdateValues", "Rotor is moving");
    528 
    529539            QMutexLocker locker(&statusLock);
    530             rotorPosition.SetValue((int)truncf(progress * 100));
     540            rotorPosition.SetValue(100);
    531541        }
    532542    }
    533     else if (!rotor && HasFlags(kDVBSigMon_WaitForPos))
    534     {
    535         QMutexLocker locker(&statusLock);
    536         rotorPosition.SetValue(100);
    537     }
    538543
    539544    // Periodically retune if card can't recover
    540545    if (!dvbchan->IsSelfRetuning() && !is_locked &&