fix possible crash on task abort and work with new getCD return value
[enigma2.git] / lib / dvb / sec.cpp
index 70cbf0472a199db0eaf4c2a0c6fc2604c8113a82..c1caa3801f596f33e3b2d918751ee90c1d21327b 100644 (file)
@@ -128,6 +128,7 @@ eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(eSmartPtrList<eDVBR
 int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite &sat, iDVBFrontend *fe, int slot_id, int *highest_score_lnb)
 {
        bool simulate = ((eDVBFrontend*)fe)->is_simulate();
+       bool direct_connected = m_not_linked_slot_mask & slot_id;
        int score=0, satcount=0;
 
        if (highest_score_lnb)
@@ -153,7 +154,6 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite
                        if ( sit != lnb_param.m_satellites.end())
                        {
                                bool diseqc=false;
-                               bool direct_connected = m_not_linked_slot_mask & slot_id;
                                long band=0,
                                        linked_prev_ptr=-1,
                                        linked_next_ptr=-1,
@@ -268,12 +268,6 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite
                                        eSecDebugNoSimulate("ret4 %d", ret);
                                }
 
-                               if (ret && rotor && curRotorPos != -1 && direct_connected) {
-                                       ret -= abs(curRotorPos-sat.orbital_position);
-                               }
-
-                               eSecDebugNoSimulate("ret5 %d", ret);
-
                                if (ret)
                                        if (satpos_depends_ptr != -1)
                                        {
@@ -286,9 +280,14 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite
                                                        if (!rotor || curRotorPos != sat.orbital_position)
                                                                ret=0;
                                                }
-                                               eSecDebugNoSimulate("ret6 %d", ret);
+                                               eSecDebugNoSimulate("ret5 %d", ret);
                                        }
 
+                               if (ret && rotor && curRotorPos != -1 && (direct_connected || satpos_depends_ptr == -1) )  // direct conntected or loopthrough!
+                                       ret -= abs(curRotorPos-sat.orbital_position);
+
+                               eSecDebugNoSimulate("ret6 %d", ret);
+
                                if (ret)
                                {
                                        int lof = sat.frequency > lnb_param.m_lof_threshold ?
@@ -311,7 +310,7 @@ int eDVBSatelliteEquipmentControl::canTune(const eDVBFrontendParametersSatellite
        }
        if (score && satcount)
                score -= (satcount-1);
-       if (score && m_not_linked_slot_mask & slot_id)
+       if (score && direct_connected)
                score += 5; // increase score for tuners with direct sat connection
        eSecDebugNoSimulate("final score %d", score);
        return score;
@@ -689,6 +688,9 @@ RESULT eDVBSatelliteEquipmentControl::prepare(iDVBFrontend &frontend, FRONTENDPA
                                                                sec_sequence.push_back( eSecCommand(eSecCommand::SEND_TONEBURST, di_param.m_toneburst_param) );
                                                                sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_AFTER_TONEBURST]) );
                                                        }
+
+                                                       if (di_param.m_seq_repeat && seq_repeat == 0)
+                                                               sec_sequence.push_back( eSecCommand(eSecCommand::SLEEP, m_params[DELAY_BEFORE_SEQUENCE_REPEAT]) );
                                                }
                                                sendDiSEqC = true;
                                        }