#817 Resolves issue with jittery audio playback and recording for MPT1327 channels. (#830)

Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
Denny Sheirer
2020-05-24 07:58:59 -04:00
committed by GitHub
parent 3d816c3570
commit 2c3648f8c2
11 changed files with 131 additions and 52 deletions

View File

@@ -227,11 +227,13 @@ public class DecoderFactory
Sync sync = mptConfig.getSync();
modules.add(new MPT1327Decoder(sync));
final int timeout = mptConfig.getCallTimeout() * 1000;
final int callTimeoutMilliseconds = mptConfig.getCallTimeoutSeconds() * 1000;
// Set max segment audio sample length slightly above call timeout to
// not create a new segment if the processing chain finishes a bit after
// actual call timeout.
modules.add(new AudioModule(aliasList, timeout + 5000));
int maxAudioSegmentLengthMillis = (callTimeoutMilliseconds + 5000);
modules.add(new AudioModule(aliasList, maxAudioSegmentLengthMillis));
SourceType sourceType = channel.getSourceConfiguration().getSourceType();
if(sourceType == SourceType.TUNER || sourceType == SourceType.TUNER_MULTIPLE_FREQUENCIES)
@@ -243,11 +245,11 @@ public class DecoderFactory
{
MPT1327TrafficChannelManager trafficChannelManager = new MPT1327TrafficChannelManager(channel, channelMap);
modules.add(trafficChannelManager);
modules.add(new MPT1327DecoderState(trafficChannelManager, channelType, timeout));
modules.add(new MPT1327DecoderState(trafficChannelManager, channelType, callTimeoutMilliseconds));
}
else
{
modules.add(new MPT1327DecoderState(channelType, timeout));
modules.add(new MPT1327DecoderState(channelType, callTimeoutMilliseconds));
}
//Add a channel rotation monitor when we have multiple control channel frequencies specified
@@ -483,7 +485,7 @@ public class DecoderFactory
case MPT1327:
DecodeConfigMPT1327 originalMPT = (DecodeConfigMPT1327)config;
DecodeConfigMPT1327 copyMPT = new DecodeConfigMPT1327();
copyMPT.setCallTimeout(originalMPT.getCallTimeout());
copyMPT.setCallTimeoutSeconds(originalMPT.getCallTimeoutSeconds());
copyMPT.setChannelMapName(originalMPT.getChannelMapName());
copyMPT.setSync(originalMPT.getSync());
copyMPT.setTrafficChannelPoolSize(originalMPT.getTrafficChannelPoolSize());

View File

@@ -30,5 +30,5 @@ public interface WithCallTimeout
/**
* @return call timeout in seconds
*/
int getCallTimeout();
int getCallTimeoutSeconds();
}

View File

@@ -33,7 +33,7 @@ public class DecodeConfigMPT1327 extends DecodeConfiguration implements WithCall
private String mChannelMapName;
private Sync mSync = Sync.NORMAL;
private int mCallTimeout = DEFAULT_CALL_TIMEOUT_DELAY_SECONDS;
private int mCallTimeoutSeconds = DEFAULT_CALL_TIMEOUT_DELAY_SECONDS;
private int mTrafficChannelPoolSize = TRAFFIC_CHANNEL_LIMIT_DEFAULT;
public DecodeConfigMPT1327()
@@ -69,9 +69,9 @@ public class DecodeConfigMPT1327 extends DecodeConfiguration implements WithCall
}
@JacksonXmlProperty(isAttribute = true, localName = "call_timeout")
public int getCallTimeout()
public int getCallTimeoutSeconds()
{
return mCallTimeout;
return mCallTimeoutSeconds;
}
/**
@@ -79,15 +79,15 @@ public class DecodeConfigMPT1327 extends DecodeConfiguration implements WithCall
*
* @param timeout
*/
public void setCallTimeout(int timeout)
public void setCallTimeoutSeconds(int timeout)
{
if(CALL_TIMEOUT_MINIMUM <= timeout && timeout <= CALL_TIMEOUT_MAXIMUM)
{
mCallTimeout = timeout;
mCallTimeoutSeconds = timeout;
}
else
{
mCallTimeout = DEFAULT_CALL_TIMEOUT_DELAY_SECONDS;
mCallTimeoutSeconds = DEFAULT_CALL_TIMEOUT_DELAY_SECONDS;
}
}

View File

@@ -42,7 +42,6 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.TreeSet;
@@ -59,26 +58,30 @@ public class MPT1327DecoderState extends DecoderState
private ChannelType mChannelType;
private long mFrequency = 0;
private long mCallTimeout;
private long mCallTimeoutMilliseconds;
private MPT1327TrafficChannelManager mMPT1327TrafficChannelManager;
/**
* Constructs an MPT-1327 decoder state with an optional traffic channel manager for allocating traffic channels
* when go to channel (GTC) messages are detected.
* when go to channel (GTC) messages are detected. This constructor assumes that channel type is STANDARD.
*
* @param trafficChannelManager for managing MPT1327 Traffic Channels
* @param callTimeoutMilliseconds for when traffic channels should automatically be stopped.
*/
public MPT1327DecoderState(MPT1327TrafficChannelManager trafficChannelManager, ChannelType channelType, long callTimeout)
public MPT1327DecoderState(MPT1327TrafficChannelManager trafficChannelManager, ChannelType channelType,
long callTimeoutMilliseconds)
{
mMPT1327TrafficChannelManager = trafficChannelManager;
mChannelType = channelType;
mCallTimeout = callTimeout;
mCallTimeoutMilliseconds = callTimeoutMilliseconds;
}
/**
* Constructs an MPT1327 decoder state that does not allocate traffic channels
*/
public MPT1327DecoderState(ChannelType channelType, long callTimeout)
public MPT1327DecoderState(ChannelType channelType, long callTimeoutMilliseconds)
{
this(null, channelType, callTimeout);
this(null, channelType, callTimeoutMilliseconds);
}
@Override
@@ -250,7 +253,7 @@ public class MPT1327DecoderState extends DecoderState
{
//When we receive a MAINT message and we're configured as a standard channel, apply the call
// timeout specified by the user. Otherwise we'll be using the shorter default call timeout
broadcast(new ChangeChannelTimeoutEvent(this, mChannelType, mCallTimeout));
broadcast(new ChangeChannelTimeoutEvent(this, mChannelType, mCallTimeoutMilliseconds));
MutableIdentifierCollection ic = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
ic.remove(IdentifierClass.USER);