Merge pull request #182 from DSheirer/176-streaming-handle-additional-io-exceptions

Resolves #176 - resolves 2 streaming related issues
This commit is contained in:
Denny Sheirer
2017-02-10 22:06:32 +00:00
committed by GitHub
4 changed files with 115 additions and 71 deletions

View File

@@ -49,6 +49,29 @@ public class BroadcastChannel extends AliasID implements Comparable<BroadcastCha
}
}
@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(!(o instanceof BroadcastChannel))
{
return false;
}
BroadcastChannel that = (BroadcastChannel)o;
return getChannelName() != null ? getChannelName().equals(that.getChannelName()) : that.getChannelName() == null;
}
@Override
public int hashCode()
{
return getChannelName() != null ? getChannelName().hashCode() : 0;
}
/**
* Creates a named broadcast channel
*/

View File

@@ -707,7 +707,9 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
if(metadata != null && metadata.isStreamable())
{
for(BroadcastChannel broadcastChannel : metadata.getBroadcastChannels())
List<BroadcastChannel> broadcastChannels = metadata.getBroadcastChannels();
for(BroadcastChannel broadcastChannel : broadcastChannels)
{
String channelName = broadcastChannel.getChannelName();

View File

@@ -248,6 +248,12 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
{
String reason = ioe.getMessage();
if(connected())
{
mLog.info("Streaming connection error detected - resetting connection - " + reason);
disconnect();
connect();
}
if(reason.startsWith("Connection reset"))
{
mLog.info("Streaming connection reset by remote server - reestablishing connection");
@@ -264,14 +270,14 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
{
setBroadcastState(BroadcastState.ERROR);
disconnect();
mLog.error("Unrecognized IO error: " + reason + ". Streaming halted.");
mLog.error("Unrecognized IO error: " + reason + ". Streaming halted.", cause);
}
}
else
{
setBroadcastState(BroadcastState.ERROR);
disconnect();
mLog.error("Unspecified IO error - streaming halted.");
mLog.error("Unspecified IO error - streaming halted.", cause);
}
}
else

View File

@@ -163,7 +163,10 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
/**
* Closes the recording file. Upon successful closing of the recording file, the listener is notified that the
* audio recorder is closed.
* audio recorder is closed. There is potential for the calling thread (here) and the buffer processor thread to
* both inform the recording closed listener that the recording is ended. So, we synchronize on the listener and
* the first thread to get the lock informs the listener and then nullifies the listener pointer so that if the
* second thread attempts a duplicate notification the listener would be null at that point.
*/
public void close(Listener<AudioRecorder> listener)
{
@@ -171,8 +174,14 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
if(!mRunning.compareAndSet(true, false))
{
//If this recorder has already been stopped/closed, immediately inform the listener
mRecordingClosedListener.receive(this);
synchronized(mRecordingClosedListener)
{
if(mRecordingClosedListener != null)
{
mRecordingClosedListener.receive(AudioRecorder.this);
mRecordingClosedListener = null;
}
}
}
}
@@ -303,9 +312,13 @@ public abstract class AudioRecorder extends Module implements Listener<AudioPack
}
}
synchronized(mRecordingClosedListener)
{
if(mRecordingClosedListener != null)
{
mRecordingClosedListener.receive(AudioRecorder.this);
mRecordingClosedListener = null;
}
}
if(mProcessorHandle != null)