#39 WIP - rolls back embedding source events in buffers. The channel

calculator must be updated immediately any time the tuner's center
frequency changes so that a channel can be allocated immediately.  So,
I changed source event handling to two parts where the channel calculator
is immediately updated and the channelizer configuration is deferred so
that it can happen on the buffer processor execution thread and we can
avoid any sync() locking on the channelizer or polyphase channel
sources.
This commit is contained in:
Denny
2018-01-13 11:43:26 -05:00
parent 05fa5c25fd
commit d4761be00a
9 changed files with 80 additions and 320 deletions

View File

@@ -15,25 +15,9 @@
******************************************************************************/
package io.github.dsheirer.sample;
import io.github.dsheirer.source.SourceEvent;
public class Buffer
{
private float[] mSamples;
private SourceEvent mSourceEvent;
/**
* Buffer containing float sample data and a source event that should be processed prior to processing the
* sample data.
*
* @param samples data
* @param sourceEvent indicating a change to the sample data that should be processed first
*/
public Buffer(float[] samples, SourceEvent sourceEvent)
{
mSamples = samples;
mSourceEvent = sourceEvent;
}
/**
* Buffer containing float sample data
@@ -52,32 +36,11 @@ public class Buffer
return mSamples;
}
/**
* Optional source event that should be processed before processing the included samples. Use the hasSourceEvent()
* method to check for the existence of an event before accessing.
*
* @return optional source event or null
*/
public SourceEvent getSourceEvent()
{
return mSourceEvent;
}
/**
* Indicates if this buffer contains an optional source event that should be processed prior to processing the
* included float samples array.
*/
public boolean hasSourceEvent()
{
return mSourceEvent != null;
}
/**
* Cleanup method to nullify all data and references
*/
public void dispose()
{
mSamples = null;
mSourceEvent = null;
}
}

View File

@@ -16,21 +16,12 @@
package io.github.dsheirer.sample.complex;
import io.github.dsheirer.sample.Buffer;
import io.github.dsheirer.source.SourceEvent;
public class ComplexBuffer extends Buffer
{
//Default timestamp - we use a static variable here so that there is only ever 1 instance in memory
private static final long DEFAULT_TIMESTAMP = 0;
/**
* Wrapper around float array containing interleaved I/Q samples and an optional source event that should be
* processed prior to processing the sample data.
*/
public ComplexBuffer(float[] samples, SourceEvent sourceEvent)
{
super(samples, sourceEvent);
}
/**
* Wrapper around float array containing interleaved I/Q samples
*/

View File

@@ -15,26 +15,10 @@
******************************************************************************/
package io.github.dsheirer.sample.complex;
import io.github.dsheirer.source.SourceEvent;
public class TimestampedComplexBuffer extends ComplexBuffer
{
private long mTimestamp;
/**
* Constructs a timestamped complex buffer using the specified time in milliseconds. Also includes a source event
* that should be processed prior to processing the sample data.
*
* @param samples of data
* @param sourceEvent - optional source event to embed with this buffer
* @param timestamp relative to the first sample in the sample array
*/
public TimestampedComplexBuffer(float[] samples, SourceEvent sourceEvent, long timestamp)
{
super(samples, sourceEvent);
mTimestamp = timestamp;
}
/**
* Constructs a timestamped complex buffer using the specified time in milliseconds.
*
@@ -42,18 +26,9 @@ public class TimestampedComplexBuffer extends ComplexBuffer
*/
public TimestampedComplexBuffer(float[] samples, long timestamp)
{
this(samples, null, timestamp);
}
super(samples);
/**
* Constructs a timestamped complex buffer using the current system time in milliseconds. Also includes a source
* event that should be processed prior to processing the sample data.
*
* @param samples of data
*/
public TimestampedComplexBuffer(float[] samples, SourceEvent sourceEvent)
{
this(samples, sourceEvent, System.currentTimeMillis());
mTimestamp = timestamp;
}
/**
@@ -63,7 +38,7 @@ public class TimestampedComplexBuffer extends ComplexBuffer
*/
public TimestampedComplexBuffer(float[] samples)
{
this(samples, null, System.currentTimeMillis());
this(samples, System.currentTimeMillis());
}
/**

View File

@@ -16,21 +16,11 @@
package io.github.dsheirer.sample.real;
import io.github.dsheirer.sample.Buffer;
import io.github.dsheirer.source.SourceEvent;
import java.util.Arrays;
public class RealBuffer extends Buffer
{
/**
* Wrapper around float array containing real float samples and an optional source event that should be processed
* prior to processing the sample array data.
*/
public RealBuffer(float[] samples, SourceEvent sourceEvent)
{
super(samples, sourceEvent);
}
/**
* Wrapper around float array containing real float samples
*/
@@ -46,6 +36,6 @@ public class RealBuffer extends Buffer
{
float[] copy = Arrays.copyOf(getSamples(), getSamples().length);
return new RealBuffer(copy, getSourceEvent());
return new RealBuffer(copy);
}
}