Skip to content

Commit d2b4dbb

Browse files
author
JMS
committed
Added infrastructure to disable CI during source scan
1 parent f1af197 commit d2b4dbb

8 files changed

Lines changed: 707 additions & 628 deletions

File tree

DVB.NET/Algorithms/TransponderScanner.cs

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -362,24 +362,27 @@ private void ScannerThread()
362362
using (HardwareManager.Open())
363363
{
364364
// Attach to the hardware itself
365-
Hardware device = HardwareManager.OpenHardware( Profile );
365+
var device = HardwareManager.OpenHardware( Profile );
366+
367+
// Tell it that we only do a scan
368+
device.PrepareSourceScan();
366369

367370
// Start loading location result list
368-
foreach (GroupLocation location in m_Locations)
371+
foreach (var location in m_Locations)
369372
m_ScanResults.Add( location.Clone() );
370373

371374
// Reset counters
372375
TotalLocations = m_Locations.Count;
373376

374377
// Last successfull inversion
375-
SpectrumInversions lastInversion = SpectrumInversions.On;
378+
var lastInversion = SpectrumInversions.On;
376379

377380
// Process all transponders
378381
for (CurrentLocation = 0; CurrentLocation < m_Locations.Count; )
379382
{
380383
// Get new and old
381-
GroupLocation location = m_Locations[CurrentLocation];
382-
GroupLocation newLocation = m_ScanResults[CurrentLocation];
384+
var location = m_Locations[CurrentLocation];
385+
var newLocation = m_ScanResults[CurrentLocation];
383386

384387
// Count
385388
++CurrentLocation;
@@ -393,26 +396,27 @@ private void ScannerThread()
393396
return;
394397

395398
// Allow NIT scan on...
396-
List<SourceGroup> enableNIT = new List<SourceGroup>(), foundInfo = new List<SourceGroup>();
399+
var enableNIT = new List<SourceGroup>();
400+
var foundInfo = new List<SourceGroup>();
397401

398402
// Startup and load the groups from the configuration
399403
foreach (SourceGroup group in location.Groups)
400404
enableNIT.Add( group );
401405

402406
// All we have to process
403-
List<SourceGroup> process = new List<SourceGroup>( enableNIT );
407+
var process = new List<SourceGroup>( enableNIT );
404408

405409
// Allowed group type
406-
Type groupType = (process.Count > 0) ? process[0].GetType() : null;
410+
var groupType = (process.Count > 0) ? process[0].GetType() : null;
407411

408412
// All we did so far
409-
Dictionary<SourceGroup, bool> done = new Dictionary<SourceGroup, bool>();
413+
var done = new HashSet<SourceGroup>();
410414

411415
// Process all groups
412416
while (process.Count > 0)
413417
{
414418
// Take the first one
415-
SourceGroup group = process[0];
419+
var group = process[0];
416420

417421
// Remove it
418422
process.RemoveAt( 0 );
@@ -424,18 +428,18 @@ private void ScannerThread()
424428
++CurrentLocationGroup;
425429

426430
// Already done
427-
if (done.ContainsKey( group ))
431+
if (done.Contains( group ))
428432
continue;
429433

430434
// Found group information on equivalent group
431-
if (null != foundInfo.FirstOrDefault( g => g.CompareTo( group, true ) ))
435+
if (foundInfo.FirstOrDefault( g => g.CompareTo( group, true ) ) != null)
432436
continue;
433437

434438
// Mark as done
435-
done[group] = true;
439+
done.Add( group );
436440

437441
// Check for external termination
438-
if (null == m_Worker)
442+
if (m_Worker == null)
439443
return;
440444

441445
// Not supported
@@ -449,10 +453,10 @@ private void ScannerThread()
449453
}
450454

451455
// Read the configuration
452-
SourceGroupFilter filter = Profile.GetFilter( group );
456+
var filter = Profile.GetFilter( group );
453457

454458
// See if this should be skiped
455-
if (null != filter)
459+
if (filter != null)
456460
if (filter.ExcludeFromScan)
457461
{
458462
// Remember
@@ -467,7 +471,7 @@ private void ScannerThread()
467471
return;
468472

469473
// See if we should process the NIT
470-
bool checkNIT = enableNIT.Contains( group );
474+
var checkNIT = enableNIT.Contains( group );
471475

472476
// See if we should process
473477
if (checkNIT || group.IsComplete)
@@ -476,16 +480,16 @@ private void ScannerThread()
476480
group = SourceGroup.FromString<SourceGroup>( group.ToString() );
477481

478482
// Attach to the group
479-
GroupInformation info = SelectGroup( device, location, group, ref lastInversion );
483+
var info = SelectGroup( device, location, group, ref lastInversion );
480484

481485
// Mark as done again - group may be updated for DVB-C and if unchanged this is simply a no-operation
482-
done[group] = true;
486+
done.Add( group );
483487

484488
// Read the configuration again - actually for DVB-C it may change
485489
filter = Profile.GetFilter( group );
486490

487491
// See if this should be skiped
488-
if (null != filter)
492+
if (filter != null)
489493
if (filter.ExcludeFromScan)
490494
{
491495
// Remember
@@ -496,32 +500,32 @@ private void ScannerThread()
496500
}
497501

498502
// Remember that we found a group information - transponder is not dead
499-
if (null != info)
503+
if (info != null)
500504
foundInfo.Add( group );
501505

502506
// See if NIT update is allowed
503507
if (checkNIT)
504-
if (null != info)
508+
if (info != null)
505509
{
506510
// See if we are a cable group
507-
CableGroup cableGroup = group as CableGroup;
511+
var cableGroup = group as CableGroup;
508512

509513
// Try load
510-
LocationInformation nit = device.GetLocationInformation();
511-
if (null != nit)
514+
var nit = device.GetLocationInformation();
515+
if (nit != null)
512516
foreach (SourceGroup other in nit.Groups)
513517
if (other.GetType() == groupType)
514518
{
515519
// See if this is a cable group
516-
CableGroup otherCable = other as CableGroup;
520+
var otherCable = other as CableGroup;
517521

518522
// Disable NIT scan on the group as is
519523
enableNIT.RemoveAll( g => g.CompareTo( other, true ) );
520524
process.RemoveAll( g => g.CompareTo( other, true ) );
521525

522526
// Set inversion
523-
if (null != otherCable)
524-
if (null != cableGroup)
527+
if (otherCable != null)
528+
if (cableGroup != null)
525529
{
526530
// Use same parameters
527531
otherCable.SpectrumInversion = cableGroup.SpectrumInversion;
@@ -551,19 +555,19 @@ private void ScannerThread()
551555
newLocation.Groups.Add( group );
552556

553557
// Process this group
554-
if (null == info)
558+
if (info == null)
555559
m_Protocol.Add( new ProtocolRecord { Mode = ProtocolRecordMode.EmptyGroup, Location = location, Group = group } );
556560
else
557-
foreach (SourceIdentifier source in info.Sources)
561+
foreach (var source in info.Sources)
558562
{
559563
// Only stations
560-
Station station = source as Station;
561-
if (null == station)
564+
var station = source as Station;
565+
if (station == null)
562566
continue;
563567

564568
// Attach to the filter
565-
SourceModifier modifiers = Profile.GetFilter( source );
566-
if (null != modifiers)
569+
var modifiers = Profile.GetFilter( source );
570+
if (modifiers != null)
567571
if (modifiers.ExcludeFromScan)
568572
continue;
569573
else

DVB.NET/BDA4/DataGraph.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public partial class DataGraph : IDisposable
103103
/// </summary>
104104
private SourceIdentifier[] m_currentDecryption = s_NoSources;
105105

106+
/// <summary>
107+
/// Gesetzt um zu verhindern, dass bei einem fehlgeschlagenen Wechsel der Quellgruppe die Entschlüsselung
108+
/// zurückgesetzt wird. Diese Einstellung kann den Sendersuchlauf erheblich beschleunigen.
109+
/// </summary>
110+
public bool DisableCIResetOnTuneFailure { get; set; }
111+
106112
/// <summary>
107113
/// Erzeugt einen neuen Graphen.
108114
/// </summary>
@@ -129,16 +135,16 @@ public void Tune( GroupLocation location, SourceGroup group )
129135
throw new NotSupportedException( Properties.Resources.Exception_NotStarted );
130136

131137
// PAT wait configuration - will use 1/10sec per retry
132-
int patRetries = Configuration.MinimumPATCountWaitTime;
133-
int patsExpected = Configuration.MinimumPATCount;
138+
var patRetries = Configuration.MinimumPATCountWaitTime;
139+
var patsExpected = Configuration.MinimumPATCount;
134140

135141
// Attach to helper
136142
var analyser = TransportStreamAnalyser;
137143
var manager = (analyser == null) ? null : analyser.DataManager;
138144
var parser = (manager == null) ? null : manager.TSParser;
139145

140146
// May want to retry at least four times
141-
for (int outerRetry = 4; outerRetry-- > 0; patsExpected += 5, patRetries += 25)
147+
for (var outerRetry = 4; outerRetry-- > 0; patsExpected += 5, patRetries += 25)
142148
{
143149
// Always stop raw dump
144150
if (manager != null)
@@ -162,7 +168,7 @@ public void Tune( GroupLocation location, SourceGroup group )
162168
try
163169
{
164170
// Set counter
165-
int tuneRetry = 10;
171+
var tuneRetry = 10;
166172

167173
// Wait
168174
for (; tuneRetry-- > 0; Thread.Sleep( 100 ))
@@ -199,9 +205,9 @@ public void Tune( GroupLocation location, SourceGroup group )
199205
parser.RestartPATCounter();
200206

201207
// Request the number of bytes currently processed
202-
long bytes = parser.BytesReceived;
203-
int limit = patsExpected;
204-
int retry = patRetries;
208+
var bytes = parser.BytesReceived;
209+
var limit = patsExpected;
210+
var retry = patRetries;
205211

206212
// Wait a bit
207213
for (; (parser.ValidPATCount < limit) && (retry-- > 0); )
@@ -225,7 +231,7 @@ public void Tune( GroupLocation location, SourceGroup group )
225231
Trace.WriteLine( Properties.Resources.Trace_TuneFailed, BDASettings.BDATraceSwitch.DisplayName );
226232

227233
// Inform all helpers on reset
228-
SendEmptyTuneRequest();
234+
SendEmptyTuneRequest( DisableCIResetOnTuneFailure );
229235
}
230236
}
231237

@@ -285,13 +291,16 @@ private void StartDump()
285291
/// Sendet eine leere Anfrage zum Wechsel der Quellgruppe. Diese kann von allen Aktionen
286292
/// verwendet werden, um interne Zustände zu (re-)initialisieren.
287293
/// </summary>
288-
private void SendEmptyTuneRequest()
294+
/// <param name="disableDecryptionReset">Gesetzt, um die Neuinitialisierung der Entschlüsselung
295+
/// zu deaktivieren.</param>
296+
private void SendEmptyTuneRequest( bool disableDecryptionReset = false )
289297
{
290298
// Process
291299
using (var tune = TuneToken.Create( TunePipeline, null, null ))
292300
tune.Execute();
293-
using (var crypt = DecryptToken.Create( DecryptionPipeline, null ))
294-
crypt.Execute();
301+
if (!disableDecryptionReset)
302+
using (var crypt = DecryptToken.Create( DecryptionPipeline, null ))
303+
crypt.Execute();
295304
using (var sig = SignalToken.Create( SignalPipeline ))
296305
sig.Execute();
297306

0 commit comments

Comments
 (0)