Resolves #676 Do Not Monitor feature not working. (#684)

Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
Denny Sheirer
2020-03-21 09:32:12 +00:00
committed by GitHub
parent 1c6f91f101
commit 1bc462b300

View File

@@ -75,6 +75,7 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
private long mStartTimestamp = System.currentTimeMillis(); private long mStartTimestamp = System.currentTimeMillis();
private boolean mDisposing = false; private boolean mDisposing = false;
private AudioSegment mLinkedAudioSegment; private AudioSegment mLinkedAudioSegment;
private int mTimeslot;
/** /**
* Constructs an instance * Constructs an instance
@@ -84,9 +85,18 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
public AudioSegment(AliasList aliasList, int timeslot) public AudioSegment(AliasList aliasList, int timeslot)
{ {
mAliasList = aliasList; mAliasList = aliasList;
mTimeslot = timeslot;
mIdentifierCollection.setTimeslot(timeslot); mIdentifierCollection.setTimeslot(timeslot);
} }
/**
* Timeslot for this audio segment
*/
public int getTimeslot()
{
return mTimeslot;
}
/** /**
* Creation timestamp for this audio segment * Creation timestamp for this audio segment
* @return long milliseconds since epoch * @return long milliseconds since epoch
@@ -211,7 +221,7 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
} }
/** /**
* Identifier collection for this audio segment * Immutable identifier collection for this audio segment
*/ */
public IdentifierCollection getIdentifierCollection() public IdentifierCollection getIdentifierCollection()
{ {
@@ -226,7 +236,7 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
{ {
for(Identifier identifier: identifiers) for(Identifier identifier: identifiers)
{ {
mIdentifierCollection.update(identifier); addIdentifier(identifier);
} }
} }
@@ -354,6 +364,40 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
mIdentifierUpdateNotificationBroadcaster.removeListener(listener); mIdentifierUpdateNotificationBroadcaster.removeListener(listener);
} }
/**
* Adds the identifier to this audio segment and updates record, priority and streaming properties.
*
* Note: identifiers pass to this method must be checked for timeslot match.
*/
public void addIdentifier(Identifier identifier)
{
mIdentifierCollection.update(identifier);
List<Alias> aliases = mAliasList.getAliases(identifier);
for(Alias alias: aliases)
{
if(alias.isRecordable())
{
mRecordAudio.set(true);
}
//Add all broadcast channels for the alias ... let the set handle duplication.
for(BroadcastChannel broadcastChannel: alias.getBroadcastChannels())
{
mBroadcastChannels.add(broadcastChannel);
}
//Only assign a playback priority if it is lower priority than the current setting.
int playbackPriority = alias.getPlaybackPriority();
if(playbackPriority < mMonitorPriority.get())
{
mMonitorPriority.set(playbackPriority);
}
}
}
/** /**
* Processes identifier update notifications and updates audio segment properties using the associated aliases * Processes identifier update notifications and updates audio segment properties using the associated aliases
* from the alias list. * from the alias list.
@@ -363,38 +407,11 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
@Override @Override
public void receive(IdentifierUpdateNotification identifierUpdateNotification) public void receive(IdentifierUpdateNotification identifierUpdateNotification)
{ {
IdentifierUpdateNotification.Operation operation = identifierUpdateNotification.getOperation(); //Only process add updates that match this timeslot
if(identifierUpdateNotification.getTimeslot() == getTimeslot() &&
//Only process ADD updates. Ignore REMOVE to preserve the full metadata set (identifierUpdateNotification.isAdd() || identifierUpdateNotification.isSilentAdd()))
if(operation == IdentifierUpdateNotification.Operation.ADD ||
operation == IdentifierUpdateNotification.Operation.SILENT_ADD)
{ {
mIdentifierCollection.receive(identifierUpdateNotification); addIdentifier(identifierUpdateNotification.getIdentifier());
List<Alias> aliases = mAliasList.getAliases(identifierUpdateNotification.getIdentifier());
for(Alias alias: aliases)
{
if(alias.isRecordable())
{
mRecordAudio.set(true);
}
//Add all broadcast channels for the alias ... let the set handle duplication.
for(BroadcastChannel broadcastChannel: alias.getBroadcastChannels())
{
mBroadcastChannels.add(broadcastChannel);
}
//Only assign a playback priority if it is lower priority than the current setting.
int playbackPriority = alias.getPlaybackPriority();
if(playbackPriority < mMonitorPriority.get())
{
mMonitorPriority.set(playbackPriority);
}
}
mIdentifierUpdateNotificationBroadcaster.broadcast(identifierUpdateNotification); mIdentifierUpdateNotificationBroadcaster.broadcast(identifierUpdateNotification);
} }
} }