- Clears stale patch groups
- Reworks the audio playback panel label update code to properly update
  talkgroups and aliases in concert with the audio playback.
- Removes code that was truncating playback aliases at 32 characters.
This commit is contained in:
Denny Sheirer
2019-01-28 00:58:01 +00:00
committed by GitHub
parent c4bf089667
commit d5c3ecc7df
6 changed files with 83 additions and 40 deletions

View File

@@ -83,8 +83,6 @@ public class AudioChannelPanel extends JPanel implements Listener<AudioEvent>, S
private JLabel mIdentifierLabel = new JLabel("-----"); private JLabel mIdentifierLabel = new JLabel("-----");
private Identifier mIdentifier; private Identifier mIdentifier;
private List<Alias> mAliases = Collections.EMPTY_LIST; private List<Alias> mAliases = Collections.EMPTY_LIST;
private boolean mConfigured = false;
private AliasModel mAliasModel; private AliasModel mAliasModel;
public AudioChannelPanel(IconManager iconManager, UserPreferences userPreferences, SettingsManager settingsManager, public AudioChannelPanel(IconManager iconManager, UserPreferences userPreferences, SettingsManager settingsManager,
@@ -191,31 +189,71 @@ public class AudioChannelPanel extends JPanel implements Listener<AudioEvent>, S
} }
/** /**
* Resets the from and to labels. Note: this does not happen on the swing * Resets the from and to labels.
* event thread. Only invoke from the swing thread.
*/ */
private void resetLabels() private void resetLabels()
{ {
boolean updated = mIdentifier != null;
mIdentifier = null; mIdentifier = null;
mAliases = Collections.EMPTY_LIST; mAliases = Collections.EMPTY_LIST;
updateLabels();
mConfigured = false; if(updated)
{
updateLabels();
}
} }
/** private void updateIdentifiers(IdentifierCollection identifierCollection)
* Truncates the string to the specified length using an ellipses at the end
* @param value to optionally truncate
* @param length of the final formatted string
* @return formatted string or null
*/
private static String truncate(String value, int length)
{ {
if(value != null && value.length() > length) if(identifierCollection == null || identifierCollection.isEmpty())
{ {
return value.substring(0, length - 3) + "..."; resetLabels();
return;
} }
return value; List<Identifier> toIds = identifierCollection.getIdentifiers(IdentifierClass.USER, Role.TO);
if(toIds.isEmpty())
{
resetLabels();
return;
}
boolean updated = false;
if(toIds.size() == 1)
{
Identifier currentIdentifier = mIdentifier;
if(currentIdentifier == null || currentIdentifier != toIds.get(0))
{
mIdentifier = toIds.get(0);
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
if(aliasList != null)
{
mAliases = aliasList.getAliases(mIdentifier);
}
updated = true;
}
}
else
{
mLog.warn("Multiple To Identifiers in Collection: " + Joiner.on(",").join(toIds));
mIdentifier = toIds.get(0);
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
if(aliasList != null)
{
mAliases = aliasList.getAliases(mIdentifier);
}
updated = true;
}
if(updated)
{
updateLabels();
}
} }
/** /**
@@ -249,7 +287,8 @@ public class AudioChannelPanel extends JPanel implements Listener<AudioEvent>, S
} }
final ImageIcon icon = iconName != null ? mIconManager.getIcon(iconName, 18) : null; final ImageIcon icon = iconName != null ? mIconManager.getIcon(iconName, 18) : null;
final String identifierText = truncate(identifier, 33);
final String identifierText = identifier;
EventQueue.invokeLater(new Runnable() EventQueue.invokeLater(new Runnable()
{ {
@@ -258,7 +297,6 @@ public class AudioChannelPanel extends JPanel implements Listener<AudioEvent>, S
{ {
mIdentifierLabel.setText(identifierText); mIdentifierLabel.setText(identifierText);
mIconLabel.setIcon(icon); mIconLabel.setIcon(icon);
mConfigured = true;
} }
}); });
@@ -272,23 +310,10 @@ public class AudioChannelPanel extends JPanel implements Listener<AudioEvent>, S
@Override @Override
public void receive(final IdentifierCollection identifierCollection) public void receive(final IdentifierCollection identifierCollection)
{ {
if(identifierCollection != null && (identifierCollection.isUpdated() || !mConfigured)) updateIdentifiers(identifierCollection);
{
List<Identifier> toIds = identifierCollection.getIdentifiers(IdentifierClass.USER, Role.TO);
mIdentifier = !toIds.isEmpty() ? toIds.get(0) : null;
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
if(aliasList != null)
{
mAliases = aliasList.getAliases(mIdentifier);
}
updateLabels();
}
} }
} }
@Override @Override
public void settingChanged(Setting setting) public void settingChanged(Setting setting)
{ {

View File

@@ -1,7 +1,7 @@
/* /*
* ****************************************************************************** * ******************************************************************************
* sdrtrunk * sdrtrunk
* Copyright (C) 2014-2018 Dennis Sheirer * Copyright (C) 2014-2019 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,8 @@ public class AudioChannelsPanel extends JPanel
public AudioChannelsPanel(IconManager iconManager, UserPreferences userPreferences, SettingsManager settingsManager, public AudioChannelsPanel(IconManager iconManager, UserPreferences userPreferences, SettingsManager settingsManager,
IAudioController controller, AliasModel aliasModel) IAudioController controller, AliasModel aliasModel)
{ {
setLayout(new MigLayout("insets 0 0 0 0", "[][sg abc,grow,fill][][sg abc,grow,fill]", "[grow,fill]")); setLayout(new MigLayout("insets 0 0 0 0",
"[][sizegroup abc,grow,fill][][sizegroup abc,grow,fill]", "[grow,fill]"));
setBackground(Color.BLACK); setBackground(Color.BLACK);

View File

@@ -1,7 +1,7 @@
/* /*
* ****************************************************************************** * ******************************************************************************
* sdrtrunk * sdrtrunk
* Copyright (C) 2014-2018 Dennis Sheirer * Copyright (C) 2014-2019 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -54,6 +54,11 @@ public abstract class AudioOutput implements Listener<ReusableAudioPacket>, Line
private LinkedTransferQueue<ReusableAudioPacket> mBuffer = new LinkedTransferQueue<>(); private LinkedTransferQueue<ReusableAudioPacket> mBuffer = new LinkedTransferQueue<>();
private int mBufferStartThreshold; private int mBufferStartThreshold;
private int mBufferStopThreshold; private int mBufferStopThreshold;
private static IdentifierCollection EMPTY_IDENTIFIER_COLLECTION = new IdentifierCollection();
static
{
EMPTY_IDENTIFIER_COLLECTION.setUpdated(true);
}
private Listener<IdentifierCollection> mIdentifierCollectionListener; private Listener<IdentifierCollection> mIdentifierCollectionListener;
private Broadcaster<AudioEvent> mAudioEventBroadcaster = new Broadcaster<>(); private Broadcaster<AudioEvent> mAudioEventBroadcaster = new Broadcaster<>();
@@ -380,12 +385,11 @@ public abstract class AudioOutput implements Listener<ReusableAudioPacket>, Line
*/ */
private void checkStop() private void checkStop()
{ {
if(mCanProcessAudio && if(mCanProcessAudio && mOutput.isRunning() && mOutput.available() >= mBufferStopThreshold)
mOutput.isRunning() &&
mOutput.available() >= mBufferStopThreshold)
{ {
mOutput.drain(); mOutput.drain();
mOutput.stop(); mOutput.stop();
broadcast(EMPTY_IDENTIFIER_COLLECTION);
} }
} }
} }

View File

@@ -28,6 +28,7 @@ import io.github.dsheirer.controller.channel.Channel;
import io.github.dsheirer.controller.channel.Channel.ChannelType; import io.github.dsheirer.controller.channel.Channel.ChannelType;
import io.github.dsheirer.controller.channel.ChannelEvent; import io.github.dsheirer.controller.channel.ChannelEvent;
import io.github.dsheirer.controller.channel.IChannelEventProvider; import io.github.dsheirer.controller.channel.IChannelEventProvider;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.IdentifierUpdateListener; import io.github.dsheirer.identifier.IdentifierUpdateListener;
import io.github.dsheirer.identifier.IdentifierUpdateNotification; import io.github.dsheirer.identifier.IdentifierUpdateNotification;
import io.github.dsheirer.identifier.IdentifierUpdateProvider; import io.github.dsheirer.identifier.IdentifierUpdateProvider;
@@ -203,6 +204,7 @@ public class ChannelState extends Module implements IChannelEventProvider, IDeco
{ {
mState = State.IDLE; mState = State.IDLE;
broadcast(new DecoderStateEvent(this, Event.RESET, State.IDLE)); broadcast(new DecoderStateEvent(this, Event.RESET, State.IDLE));
mIdentifierCollection.remove(IdentifierClass.USER);
mIdentifierCollection.update(ChannelStateIdentifier.IDLE); mIdentifierCollection.update(ChannelStateIdentifier.IDLE);
mSourceOverflow = false; mSourceOverflow = false;
} }

View File

@@ -1,7 +1,7 @@
/* /*
* ****************************************************************************** * ******************************************************************************
* sdrtrunk * sdrtrunk
* Copyright (C) 2014-2018 Dennis Sheirer * Copyright (C) 2014-2019 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -84,7 +84,7 @@ public class IdentifierCollection
return mUpdated; return mUpdated;
} }
protected void setUpdated(boolean updated) public void setUpdated(boolean updated)
{ {
mUpdated = updated; mUpdated = updated;
} }
@@ -114,6 +114,14 @@ public class IdentifierCollection
return Collections.unmodifiableList(mIdentifiers); return Collections.unmodifiableList(mIdentifiers);
} }
/**
* Indicates if this collection has no identifiers
*/
public boolean isEmpty()
{
return mIdentifiers.isEmpty();
}
/** /**
* Get a list of identifiers by identifier class from this collection. * Get a list of identifiers by identifier class from this collection.
* *

View File

@@ -22,6 +22,8 @@ package io.github.dsheirer.identifier;
import io.github.dsheirer.identifier.configuration.AliasListConfigurationIdentifier; import io.github.dsheirer.identifier.configuration.AliasListConfigurationIdentifier;
import io.github.dsheirer.sample.Listener; import io.github.dsheirer.sample.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
@@ -32,6 +34,7 @@ import java.util.Iterator;
public class MutableIdentifierCollection extends IdentifierCollection implements IdentifierUpdateProvider, public class MutableIdentifierCollection extends IdentifierCollection implements IdentifierUpdateProvider,
Listener<IdentifierUpdateNotification> Listener<IdentifierUpdateNotification>
{ {
private final static Logger mLog = LoggerFactory.getLogger(MutableIdentifierCollection.class);
private Listener<IdentifierUpdateNotification> mListener; private Listener<IdentifierUpdateNotification> mListener;
public MutableIdentifierCollection() public MutableIdentifierCollection()