mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Resolves issue with audio metadata updates that was causing the audio
playback panel to not detect changes in FROM/TO values for the current audio playback.
This commit is contained in:
@@ -1,19 +1,6 @@
|
|||||||
package audio.metadata;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import sample.Listener;
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.priority.Priority;
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2016 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
|
||||||
@@ -28,15 +15,30 @@ import alias.priority.Priority;
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
package audio.metadata;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import sample.Listener;
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.priority.Priority;
|
||||||
|
|
||||||
public class AudioMetadata implements Listener<Metadata>
|
public class AudioMetadata implements Listener<Metadata>
|
||||||
{
|
{
|
||||||
protected static final Logger mLog = LoggerFactory.getLogger( AudioMetadata.class );
|
protected static final Logger mLog = LoggerFactory.getLogger( AudioMetadata.class );
|
||||||
|
|
||||||
private int mSource;
|
private int mSource;
|
||||||
private List<Metadata> mMetadata = new ArrayList<>();
|
private Map<MetadataType,Metadata> mMetadata = new HashMap<>();
|
||||||
private boolean mUpdated = false;
|
private boolean mUpdated = false;
|
||||||
|
|
||||||
/* Channel Selectect == highest priority */
|
/* Channel Selected == highest priority */
|
||||||
private boolean mSelected = false;
|
private boolean mSelected = false;
|
||||||
|
|
||||||
/* Call Priority */
|
/* Call Priority */
|
||||||
@@ -92,7 +94,8 @@ public class AudioMetadata implements Listener<Metadata>
|
|||||||
copy.mPriority = mPriority;
|
copy.mPriority = mPriority;
|
||||||
copy.mSelected = mSelected;
|
copy.mSelected = mSelected;
|
||||||
copy.mRecordable = mRecordable;
|
copy.mRecordable = mRecordable;
|
||||||
copy.mMetadata.addAll( mMetadata );
|
|
||||||
|
copy.mMetadata.putAll( mMetadata );
|
||||||
copy.mUpdated = mUpdated;
|
copy.mUpdated = mUpdated;
|
||||||
copy.mIdentifier = new String( mIdentifier );
|
copy.mIdentifier = new String( mIdentifier );
|
||||||
|
|
||||||
@@ -106,25 +109,34 @@ public class AudioMetadata implements Listener<Metadata>
|
|||||||
*/
|
*/
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
Iterator<Metadata> it = mMetadata.iterator();
|
|
||||||
|
|
||||||
while( it.hasNext() )
|
|
||||||
{
|
|
||||||
if( it.next().isTemporal() )
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reset recordable state, identifier and audio call priority levels
|
/* Reset recordable state, identifier and audio call priority levels
|
||||||
* and reprocess the metadata */
|
* and reprocess the metadata */
|
||||||
mRecordable = mSourceRecordable;
|
mRecordable = mSourceRecordable;
|
||||||
setIdentifier( mSource );
|
setIdentifier( mSource );
|
||||||
mPriority = Priority.DEFAULT_PRIORITY;
|
mPriority = Priority.DEFAULT_PRIORITY;
|
||||||
|
|
||||||
for( Metadata metadata: mMetadata )
|
List<MetadataType> toRemove = new ArrayList<>();
|
||||||
|
|
||||||
|
for( MetadataType type: mMetadata.keySet() )
|
||||||
{
|
{
|
||||||
processMetadata( metadata );
|
Metadata metadata = mMetadata.get( type );
|
||||||
|
|
||||||
|
if( metadata != null )
|
||||||
|
{
|
||||||
|
if( metadata.isTemporal() )
|
||||||
|
{
|
||||||
|
toRemove.add( type );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
processMetadata( metadata );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( MetadataType type: toRemove )
|
||||||
|
{
|
||||||
|
mMetadata.remove( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
mUpdated = true;
|
mUpdated = true;
|
||||||
@@ -185,8 +197,14 @@ public class AudioMetadata implements Listener<Metadata>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mMetadata.add( metadata );
|
Metadata existing = mMetadata.get( metadata.getMetadataType() );
|
||||||
processMetadata( metadata );
|
|
||||||
|
if( existing == null || !existing.equals( metadata ) )
|
||||||
|
{
|
||||||
|
mMetadata.put( metadata.getMetadataType(), metadata );
|
||||||
|
processMetadata( metadata );
|
||||||
|
setUpdated( true );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mUpdated = true;
|
mUpdated = true;
|
||||||
@@ -195,26 +213,17 @@ public class AudioMetadata implements Listener<Metadata>
|
|||||||
/**
|
/**
|
||||||
* Returns the complete set of metadata
|
* Returns the complete set of metadata
|
||||||
*/
|
*/
|
||||||
public List<Metadata> getMetadata()
|
public Map<MetadataType,Metadata> getMetadata()
|
||||||
{
|
{
|
||||||
return mMetadata;
|
return mMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first metadata object matching the type, or null if the
|
* Returns the metadata object matching the type or null
|
||||||
* metadata type is not found.
|
|
||||||
*/
|
*/
|
||||||
public Metadata getMetadata( MetadataType type )
|
public Metadata getMetadata( MetadataType type )
|
||||||
{
|
{
|
||||||
for( Metadata metadata: mMetadata )
|
return mMetadata.get( type );
|
||||||
{
|
|
||||||
if( metadata.getMetadataType() == type )
|
|
||||||
{
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -296,11 +305,11 @@ public class AudioMetadata implements Listener<Metadata>
|
|||||||
sb.append( getPriority() );
|
sb.append( getPriority() );
|
||||||
sb.append( " updated:" + isUpdated() );
|
sb.append( " updated:" + isUpdated() );
|
||||||
sb.append( " " );
|
sb.append( " " );
|
||||||
for( Metadata m: getMetadata() )
|
for( Entry<MetadataType,Metadata> entry: getMetadata().entrySet() )
|
||||||
{
|
{
|
||||||
sb.append( m.getKey() );
|
sb.append( entry.getValue().getKey() );
|
||||||
sb.append( ":" );
|
sb.append( ":" );
|
||||||
sb.append( m.getValue() );
|
sb.append( entry.getValue().getValue() );
|
||||||
sb.append( " " );
|
sb.append( " " );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,4 +103,44 @@ public class Metadata
|
|||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals( Metadata other )
|
||||||
|
{
|
||||||
|
if( mMetadataType != other.getMetadataType() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mTemporal != other.isTemporal() )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mValue != null && other.getValue() != null &&
|
||||||
|
!mValue.contentEquals( other.getValue() ))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( mValue == null && other.getValue() != null ) ||
|
||||||
|
( mValue != null && other.getValue() == null ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mValueAlias != null && other.getAlias() != null &&
|
||||||
|
!mValueAlias.getName().contentEquals( other.getAlias().getName() ))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( mValueAlias == null && other.getAlias() != null ) ||
|
||||||
|
( mValueAlias != null && other.getAlias() == null ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user