mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-20 04:27:48 -05:00
Adds additional unresolved address exception handler to metadata updater
This commit is contained in:
1
.idea/dictionaries/denny.xml
generated
1
.idea/dictionaries/denny.xml
generated
@@ -7,6 +7,7 @@
|
|||||||
<w>fleetsync</w>
|
<w>fleetsync</w>
|
||||||
<w>icecast</w>
|
<w>icecast</w>
|
||||||
<w>ident</w>
|
<w>ident</w>
|
||||||
|
<w>overflowable</w>
|
||||||
<w>polyphase</w>
|
<w>polyphase</w>
|
||||||
<w>remez</w>
|
<w>remez</w>
|
||||||
<w>samplerate</w>
|
<w>samplerate</w>
|
||||||
|
|||||||
@@ -18,20 +18,27 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package sample;
|
package sample;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import source.tuner.TunerChannelSource;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.LinkedTransferQueue;
|
import java.util.concurrent.LinkedTransferQueue;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class OverflowableTransferQueue<E>
|
public class OverflowableTransferQueue<E>
|
||||||
{
|
{
|
||||||
|
private final static Logger mLog = LoggerFactory.getLogger(OverflowableTransferQueue.class);
|
||||||
|
|
||||||
public enum State {NORMAL, OVERFLOW};
|
public enum State {NORMAL, OVERFLOW};
|
||||||
private Listener<State> mStateListener;
|
private Listener<State> mStateListener;
|
||||||
|
|
||||||
private LinkedTransferQueue<E> mQueue = new LinkedTransferQueue<E>();
|
private LinkedTransferQueue<E> mQueue = new LinkedTransferQueue<E>();
|
||||||
private AtomicInteger mCounter = new AtomicInteger();
|
private AtomicInteger mCounter = new AtomicInteger();
|
||||||
|
private AtomicBoolean mOverflow = new AtomicBoolean();
|
||||||
private int mMaximumSize;
|
private int mMaximumSize;
|
||||||
private int mResetThreshold;
|
private int mResetThreshold;
|
||||||
private boolean mOverflow = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concurrent transfer queue that couples a higher-throughput linked transfer queue with an atomic integer for
|
* Concurrent transfer queue that couples a higher-throughput linked transfer queue with an atomic integer for
|
||||||
@@ -53,7 +60,7 @@ public class OverflowableTransferQueue<E>
|
|||||||
*/
|
*/
|
||||||
public void offer(E e)
|
public void offer(E e)
|
||||||
{
|
{
|
||||||
if(!mOverflow)
|
if(!mOverflow.get())
|
||||||
{
|
{
|
||||||
mQueue.offer(e);
|
mQueue.offer(e);
|
||||||
|
|
||||||
@@ -73,14 +80,16 @@ public class OverflowableTransferQueue<E>
|
|||||||
{
|
{
|
||||||
int drainCount = mQueue.drainTo(collection, maxElements);
|
int drainCount = mQueue.drainTo(collection, maxElements);
|
||||||
|
|
||||||
if(drainCount > 0)
|
int size = mCounter.addAndGet(-drainCount);
|
||||||
{
|
|
||||||
int size = mCounter.addAndGet(-drainCount);
|
|
||||||
|
|
||||||
if(mOverflow && size <= mResetThreshold)
|
if(mOverflow.get())
|
||||||
{
|
{
|
||||||
setOverflow(false);
|
mLog.debug("Overflow - current size:" + size + " threshold:" + mResetThreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mOverflow.get() && size <= mResetThreshold)
|
||||||
|
{
|
||||||
|
setOverflow(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return drainCount;
|
return drainCount;
|
||||||
@@ -100,7 +109,7 @@ public class OverflowableTransferQueue<E>
|
|||||||
*/
|
*/
|
||||||
public State getState()
|
public State getState()
|
||||||
{
|
{
|
||||||
return mOverflow ? State.OVERFLOW : State.NORMAL;
|
return mOverflow.get() ? State.OVERFLOW : State.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,11 +117,12 @@ public class OverflowableTransferQueue<E>
|
|||||||
*/
|
*/
|
||||||
private void setOverflow(boolean overflow)
|
private void setOverflow(boolean overflow)
|
||||||
{
|
{
|
||||||
mOverflow = overflow;
|
if(mOverflow.compareAndSet(!overflow, overflow))
|
||||||
|
|
||||||
if(mStateListener != null)
|
|
||||||
{
|
{
|
||||||
mStateListener.receive(getState());
|
if(mStateListener != null)
|
||||||
|
{
|
||||||
|
mStateListener.receive(overflow ? State.OVERFLOW : State.NORMAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +135,7 @@ public class OverflowableTransferQueue<E>
|
|||||||
{
|
{
|
||||||
mQueue.clear();
|
mQueue.clear();
|
||||||
mCounter.set(0);
|
mCounter.set(0);
|
||||||
mOverflow = false;
|
mOverflow.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
private static final int BUFFER_MAX_CAPACITY = 300;
|
private static final int BUFFER_MAX_CAPACITY = 300;
|
||||||
|
|
||||||
//Threshold for resetting buffer overflow condition
|
//Threshold for resetting buffer overflow condition
|
||||||
private static final int BUFFER_OVERFLOW_RESET_THRESHOLD = 200;
|
private static final int BUFFER_OVERFLOW_RESET_THRESHOLD = 100;
|
||||||
|
|
||||||
private static int CHANNEL_RATE = 48000;
|
private static int CHANNEL_RATE = 48000;
|
||||||
private static int CHANNEL_PASS_FREQUENCY = 12000;
|
private static int CHANNEL_PASS_FREQUENCY = 12000;
|
||||||
@@ -108,11 +108,11 @@ public class TunerChannelSource extends ComplexSource implements IFrequencyChang
|
|||||||
{
|
{
|
||||||
if(state == OverflowableTransferQueue.State.NORMAL)
|
if(state == OverflowableTransferQueue.State.NORMAL)
|
||||||
{
|
{
|
||||||
mLog.debug("Channel [" + mTunerFrequency + "] buffer overflow - temporary pause until processing catches up");
|
mLog.debug("Channel [" + mTunerChannel.getFrequency() + "] buffer overflow - temporary pause until processing catches up");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLog.debug("Channel [" + mTunerFrequency + "] buffer overflow cleared - resuming normal processing");
|
mLog.debug("Channel [" + mTunerChannel.getFrequency() + "] buffer overflow cleared - resuming normal processing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class USBTransferProcessor implements TransferCallback
|
|||||||
private static final int FILLED_BUFFER_MAX_CAPACITY = 300;
|
private static final int FILLED_BUFFER_MAX_CAPACITY = 300;
|
||||||
|
|
||||||
//Threshold for resetting buffer overflow condition
|
//Threshold for resetting buffer overflow condition
|
||||||
private static final int FILLED_BUFFER_OVERFLOW_RESET_THRESHOLD = 200;
|
private static final int FILLED_BUFFER_OVERFLOW_RESET_THRESHOLD = 100;
|
||||||
|
|
||||||
private String mDeviceName;
|
private String mDeviceName;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user