@@ -5,6 +5,8 @@ public class EventTrigger : IEventTrigger
55 enum TriggerState { Unarmed , InCapture , InHoldoff }
66 private TriggerState triggerState = TriggerState . Unarmed ;
77
8+ private long windowWidth ;
9+
810 private long captureSamples ;
911 private long captureRemaining ;
1012
@@ -25,6 +27,8 @@ public void SetHorizontal(long windowWidth, long windowTriggerPosition, long add
2527 if ( windowTriggerPosition > windowWidth - 1 )
2628 windowTriggerPosition = windowWidth - 1 ;
2729
30+ this . windowWidth = windowWidth ;
31+
2832 captureSamples = windowWidth - windowTriggerPosition ;
2933 captureRemaining = 0 ;
3034
@@ -42,7 +46,7 @@ public void EnqueueEvent(ulong sampleIndex)
4246 eventQueue . Enqueue ( sampleIndex ) ;
4347 }
4448
45- public void Process ( int inputLength , ulong sampleStartIndex , ref EventTriggerResults results )
49+ public void Process ( int inputLength , ulong sampleStartIndex , int acquisitionSamplesInBuffer , ref EventTriggerResults results )
4650 {
4751 ulong chunkStart = sampleStartIndex ;
4852 ulong chunkEnd = sampleStartIndex + ( ulong ) inputLength ;
@@ -56,6 +60,7 @@ public void Process(int inputLength, ulong sampleStartIndex, ref EventTriggerRes
5660 {
5761 case TriggerState . Unarmed :
5862 {
63+
5964 // Empty stale events out of queue.
6065 // This does limit the scope of triggers to current & future chunks,
6166 // when in reality there's a whole acquisition buffer available.
@@ -66,6 +71,13 @@ public void Process(int inputLength, ulong sampleStartIndex, ref EventTriggerRes
6671 eventQueue . Dequeue ( ) ;
6772 }
6873
74+ // Only allow capture events once at least windowWidth samples have passed
75+ if ( acquisitionSamplesInBuffer < windowWidth )
76+ {
77+ i = inputLength ;
78+ break ;
79+ }
80+
6981 if ( eventQueue . TryPeek ( out var eventIndex ) && eventIndex >= chunkStart && eventIndex < chunkEnd )
7082 {
7183 eventQueue . Dequeue ( ) ;
0 commit comments