Resolves issue with Audio Channel display showing a call in progress

with TO/FROM identifiers displayed, but no audio playing.  This occurred
when the decoder sent a few audio buffers which caused the display to
update from the metadata, however the decoder stopped sending buffers
and the audio start threshold is never met.  Clear display is invoked
upon audio stop, so the panel was never started or stopped or cleared
until the next call came in.

Changed to store the incoming metadata and only display it once the
audio playback starts and reset the display once the audio stops.
This commit is contained in:
denny
2016-02-04 20:49:11 -05:00
parent 4460f1ee30
commit 9c94266adb

View File

@@ -49,7 +49,10 @@ public class AudioChannelPanel extends JPanel
private JLabel mFrom = new JLabel( "" ); private JLabel mFrom = new JLabel( "" );
private JLabel mFromAlias = new JLabel( "" ); private JLabel mFromAlias = new JLabel( "" );
private boolean mConfigured = false; private enum AudioStatus { STARTED,STOPPED };
private AudioStatus mAudioStatus = AudioStatus.STOPPED;
private AudioMetadata mAudioMetadata;
public AudioChannelPanel( SettingsManager settingsManager, AudioOutput audioOutput ) public AudioChannelPanel( SettingsManager settingsManager, AudioOutput audioOutput )
{ {
@@ -134,15 +137,19 @@ public class AudioChannelPanel extends JPanel
{ {
switch( audioEvent.getType() ) switch( audioEvent.getType() )
{ {
case AUDIO_STOPPED: case AUDIO_STARTED:
EventQueue.invokeLater( new Runnable() synchronized( mAudioStatus )
{ {
@Override mAudioStatus = AudioStatus.STARTED;
public void run() updateLabels();
{ }
resetLabels(); break;
} case AUDIO_STOPPED:
} ); synchronized( mAudioStatus )
{
mAudioStatus = AudioStatus.STOPPED;
resetLabels();
}
break; break;
case AUDIO_MUTED: case AUDIO_MUTED:
case AUDIO_UNMUTED: case AUDIO_UNMUTED:
@@ -166,13 +173,55 @@ public class AudioChannelPanel extends JPanel
*/ */
private void resetLabels() private void resetLabels()
{ {
mFrom.setText( "" ); EventQueue.invokeLater( new Runnable()
updateAlias( mFromAlias, null ); {
@Override
public void run()
{
mFrom.setText( "" );
updateAlias( mFromAlias, null );
mTo.setText( "" ); mTo.setText( "" );
updateAlias( mToAlias, null ); updateAlias( mToAlias, null );
}
} );
}
mConfigured = false; private void updateLabels()
{
if( mAudioMetadata != null )
{
final Metadata from = mAudioMetadata.getMetadata( MetadataType.FROM );
final Metadata to = mAudioMetadata.getMetadata( MetadataType.TO );
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
if( from != null )
{
mFrom.setText( from.getValue() );
updateAlias( mFromAlias, from.getAlias() );
}
else
{
mFrom.setText( "-----" );
}
if( to != null )
{
mTo.setText( to.getValue() );
updateAlias( mToAlias, to.getAlias() );
}
else
{
mTo.setText( "-----" );
}
}
} );
}
} }
/** /**
@@ -214,40 +263,17 @@ public class AudioChannelPanel extends JPanel
@Override @Override
public void receive( AudioMetadata audioMetadata ) public void receive( AudioMetadata audioMetadata )
{ {
if( !mConfigured || audioMetadata.isUpdated() ) mAudioMetadata = audioMetadata;
if( audioMetadata.isUpdated() )
{ {
final Metadata from = audioMetadata.getMetadata( MetadataType.FROM ); synchronized( mAudioStatus )
final Metadata to = audioMetadata.getMetadata( MetadataType.TO );
EventQueue.invokeLater( new Runnable()
{ {
@Override if( mAudioStatus == AudioStatus.STARTED )
public void run()
{ {
if( from != null ) updateLabels();
{
mFrom.setText( from.getValue() );
updateAlias( mFromAlias, from.getAlias() );
}
else
{
mFrom.setText( "-----" );
}
if( to != null )
{
mTo.setText( to.getValue() );
updateAlias( mToAlias, to.getAlias() );
}
else
{
mTo.setText( "-----" );
}
} }
} ); }
mConfigured = true;
} }
} }
} }