Example #1
0
        private static BDAGraph checkTunerAvailability(Tuner tuner, TuningSpec tuningSpec, bool repeatDiseqc, bool switchAfterPlay, string dumpFileName)
        {
            if (!RunParameters.Instance.DebugIDs.Contains("USEDVBLINK"))
            {
                if (tuner.Name.ToUpperInvariant().StartsWith("DVBLINK"))
                    return (null);
            }

            BDAGraph graph = new BDAGraph("BDA", tuningSpec, tuner, dumpFileName);
            graph.LogFilters();

            if (tuningSpec.Frequency.TunerType == TunerType.Satellite && ((SatelliteFrequency)tuningSpec.Frequency).SatelliteDish.DiseqcSwitch != null)
                return (checkDiseqcAvailability(graph, tuner, tuningSpec, repeatDiseqc, switchAfterPlay));
            else
            {
                if (graph.Play())
                    return (graph);
                else
                {
                    Logger.Instance.Write("Tuner in use - ignored: " + tuner.Name);
                    graph.Dispose();
                    return (null);
                }
            }
        }
Example #2
0
        private static bool tuneFrequency(TuningFrequency frequency)
        {
            Logger.Instance.Write("Tuning to frequency " + frequency.Frequency + " on " + frequency.TunerType);

            TuningSpec tuningSpec;
            TunerNodeType tunerNodeType;
            int frequencyRetries = 0;

            if (frequency.TunerType == TunerType.Satellite)
            {
                tuningSpec = new TuningSpec(Satellite.CurrentSatellite, (SatelliteFrequency)frequency);
                tunerNodeType = TunerNodeType.Satellite;
            }
            else if (frequency.TunerType == TunerType.Terrestrial)
            {
                tuningSpec = new TuningSpec((TerrestrialFrequency)frequency);
                tunerNodeType = TunerNodeType.Terrestrial;
            }
            else
            {
                tuningSpec = new TuningSpec((CableFrequency)frequency);
                tunerNodeType = TunerNodeType.Cable;
            }

            bool finished = false;

            while (!finished)
            {
                graph = BDAGraph.FindTuner(RunParameters.SelectedTuner, tunerNodeType, tuningSpec);
                if (graph == null)
                {
                    Logger.Instance.Write("Tuner not available");
                    return (false);
                }

                TimeSpan timeout = new TimeSpan();
                bool done = false;
                bool locked = false;

                if (RunParameters.Options.Contains("NOSIGLOCK"))
                {
                    Logger.Instance.Write("Option NOSIGLOCK: No lock check, wait 5 seconds instead");
                    locked = true;
                    Thread.Sleep(5000);
                }
                else
                {
                    while (!done)
                    {
                        if (cancelGraph)
                        {
                            graph.Dispose();
                            return (false);
                        }

                        locked = graph.SignalLocked;
                        if (!locked)
                        {
                            int signalQuality = graph.SignalQuality;
                            if (signalQuality > 0)
                            {
                                Logger.Instance.Write("Signal not locked but signal quality > 0");
                                locked = true;
                                done = true;
                            }
                            else
                            {
                                Logger.Instance.Write("Signal not locked and signal quality not > 0");
                                Thread.Sleep(1000);
                                timeout = timeout.Add(new TimeSpan(0, 0, 1));
                                done = (timeout.TotalSeconds == RunParameters.LockTimeout.TotalSeconds);
                            }
                        }
                        else
                            done = true;
                    }
                }

                if (!locked)
                {
                    Logger.Instance.Write("Failed to acquire signal");
                    graph.Dispose();

                    if (frequencyRetries == 1)
                        return (false);
                    else
                    {
                        frequencyRetries++;
                        Logger.Instance.Write("Retrying frequency");
                    }
                }
                else
                {
                    finished = true;
                    Logger.Instance.Write("Signal acquired: lock is " + graph.SignalLocked + " quality is " + graph.SignalQuality + " strength is " + graph.SignalStrength);
                }
            }

            return (true);
        }
Example #3
0
        private static BDAGraph checkDiseqcAvailability(BDAGraph graph, Tuner tuner, TuningSpec tuningSpec, bool repeatDiseqc, bool switchAfterPlay)
        {
            if (RunParameters.Instance.Options.Contains("USESAFEDISEQC"))
            {
                Logger.Instance.Write("Processing using safe DiSEqC switching method");

                if (!graph.Play())
                {
                    Logger.Instance.Write("Tuner in use - ignored: " + tuner.Name);
                    graph.Dispose();
                    return (null);
                }

                graph.Dispose();
                graph = new BDAGraph("BDA", tuningSpec, tuner);
            }
            else
                Logger.Instance.Write("Processing using unsafe DiSEqC switching method");

            SwitchReply switchReply = SwitchReply.NotSet;

            if (!switchAfterPlay)
            {
                Logger.Instance.Write("Processing Diseqc command before running graph");
                switchReply = DiseqcHandlerBase.ProcessDisEqcSwitch(tuningSpec, tuner, graph.tunerFilter);
                Thread.Sleep(500);
            }

            if (!graph.Play())
            {
                Logger.Instance.Write("Tuner in use - ignored: " + tuner.Name);
                graph.Dispose();
                return (null);
            }

            if (switchReply == SwitchReply.Failed && repeatDiseqc)
            {
                Logger.Instance.Write("Repeating DiSEqC command due to initial failure");
                switchReply = DiseqcHandlerBase.ProcessDisEqcSwitch(tuningSpec, tuner, graph.tunerFilter);
            }
            else
            {
                if (switchAfterPlay)
                {
                    Logger.Instance.Write("Processing Diseqc command after running graph");
                    switchReply = DiseqcHandlerBase.ProcessDisEqcSwitch(tuningSpec, tuner, graph.tunerFilter);
                }
            }

            return (graph);
        }