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);
} }
} }
@@ -355,23 +365,15 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
} }
/** /**
* Processes identifier update notifications and updates audio segment properties using the associated aliases * Adds the identifier to this audio segment and updates record, priority and streaming properties.
* from the alias list.
* *
* @param identifierUpdateNotification containing an identifier. * Note: identifiers pass to this method must be checked for timeslot match.
*/ */
@Override public void addIdentifier(Identifier identifier)
public void receive(IdentifierUpdateNotification identifierUpdateNotification)
{ {
IdentifierUpdateNotification.Operation operation = identifierUpdateNotification.getOperation(); mIdentifierCollection.update(identifier);
//Only process ADD updates. Ignore REMOVE to preserve the full metadata set List<Alias> aliases = mAliasList.getAliases(identifier);
if(operation == IdentifierUpdateNotification.Operation.ADD ||
operation == IdentifierUpdateNotification.Operation.SILENT_ADD)
{
mIdentifierCollection.receive(identifierUpdateNotification);
List<Alias> aliases = mAliasList.getAliases(identifierUpdateNotification.getIdentifier());
for(Alias alias: aliases) for(Alias alias: aliases)
{ {
@@ -394,7 +396,22 @@ public class AudioSegment implements Listener<IdentifierUpdateNotification>
mMonitorPriority.set(playbackPriority); mMonitorPriority.set(playbackPriority);
} }
} }
}
/**
* Processes identifier update notifications and updates audio segment properties using the associated aliases
* from the alias list.
*
* @param identifierUpdateNotification containing an identifier.
*/
@Override
public void receive(IdentifierUpdateNotification identifierUpdateNotification)
{
//Only process add updates that match this timeslot
if(identifierUpdateNotification.getTimeslot() == getTimeslot() &&
(identifierUpdateNotification.isAdd() || identifierUpdateNotification.isSilentAdd()))
{
addIdentifier(identifierUpdateNotification.getIdentifier());
mIdentifierUpdateNotificationBroadcaster.broadcast(identifierUpdateNotification); mIdentifierUpdateNotificationBroadcaster.broadcast(identifierUpdateNotification);
} }
} }