mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 17:17:29 -05:00
Resolves issue #260 - applies changes to Shoutcast V1 and v2 that were
applied to the Icecast streamer for issue releated to reconnecting.
This commit is contained in:
@@ -101,7 +101,7 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
if(mSocketConnector == null)
|
if(mSocketConnector == null)
|
||||||
{
|
{
|
||||||
mSocketConnector = new NioSocketConnector();
|
mSocketConnector = new NioSocketConnector();
|
||||||
mSocketConnector.setConnectTimeoutCheckInterval(1000);
|
mSocketConnector.setConnectTimeoutCheckInterval(CONNECTION_ATTEMPT_TIMEOUT);
|
||||||
|
|
||||||
// LoggingFilter loggingFilter = new LoggingFilter(IcecastTCPAudioBroadcaster.class);
|
// LoggingFilter loggingFilter = new LoggingFilter(IcecastTCPAudioBroadcaster.class);
|
||||||
// loggingFilter.setMessageSentLogLevel(LogLevel.NONE);
|
// loggingFilter.setMessageSentLogLevel(LogLevel.NONE);
|
||||||
@@ -151,12 +151,12 @@ public class IcecastTCPAudioBroadcaster extends IcecastAudioBroadcaster
|
|||||||
else if(throwableCause != null)
|
else if(throwableCause != null)
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.ERROR);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
mLog.debug("[" + getStreamName() + "]Failed to connect", rie);
|
mLog.debug("[" + getStreamName() + "] failed to connect", rie);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.ERROR);
|
setBroadcastState(BroadcastState.ERROR);
|
||||||
mLog.debug("[" + getStreamName() + "]Failed to connect - no exception is available");
|
mLog.debug("[" + getStreamName() + "] failed to connect - no exception is available");
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect();
|
disconnect();
|
||||||
|
|||||||
@@ -189,12 +189,13 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
|
|||||||
*/
|
*/
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
{
|
{
|
||||||
if(connected())
|
if(connected() && mStreamingSession != null)
|
||||||
{
|
{
|
||||||
if(mStreamingSession != null)
|
mStreamingSession.closeNow();
|
||||||
{
|
}
|
||||||
mStreamingSession.closeNow();
|
else
|
||||||
}
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,15 +231,15 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
|
|||||||
@Override
|
@Override
|
||||||
public void sessionClosed(IoSession session) throws Exception
|
public void sessionClosed(IoSession session) throws Exception
|
||||||
{
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
|
|
||||||
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
||||||
if(!getBroadcastState().isErrorState())
|
if(!getBroadcastState().isErrorState())
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.DISCONNECTED);
|
setBroadcastState(BroadcastState.DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSocketConnector.dispose();
|
|
||||||
mStreamingSession = null;
|
mStreamingSession = null;
|
||||||
mSocketConnector = null;
|
|
||||||
|
|
||||||
mConnecting.set(false);
|
mConnecting.set(false);
|
||||||
super.sessionClosed(session);
|
super.sessionClosed(session);
|
||||||
@@ -259,13 +260,11 @@ public class ShoutcastV1AudioBroadcaster extends AudioBroadcaster
|
|||||||
{
|
{
|
||||||
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else if(reason.startsWith("Operation timed out"))
|
else if(reason.startsWith("Operation timed out"))
|
||||||
{
|
{
|
||||||
mLog.info("Streaming connection timed out - resetting connection");
|
mLog.info("Streaming connection timed out - resetting connection");
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -225,13 +225,13 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
*/
|
*/
|
||||||
public void disconnect()
|
public void disconnect()
|
||||||
{
|
{
|
||||||
if(connected())
|
if(connected() && mStreamingSession != null)
|
||||||
{
|
{
|
||||||
if(mStreamingSession != null)
|
mStreamingSession.closeNow();
|
||||||
{
|
}
|
||||||
mStreamingSession.write(new TerminateBroadcast());
|
else
|
||||||
mStreamingSession.closeNow();
|
{
|
||||||
}
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,15 +353,15 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
@Override
|
@Override
|
||||||
public void sessionClosed(IoSession session) throws Exception
|
public void sessionClosed(IoSession session) throws Exception
|
||||||
{
|
{
|
||||||
|
mLastConnectionAttempt = System.currentTimeMillis();
|
||||||
|
|
||||||
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
//If there is already an error state, don't override it. Otherwise, set state to disconnected
|
||||||
if(!getBroadcastState().isErrorState())
|
if(!getBroadcastState().isErrorState())
|
||||||
{
|
{
|
||||||
setBroadcastState(BroadcastState.DISCONNECTED);
|
setBroadcastState(BroadcastState.DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSocketConnector.dispose();
|
|
||||||
mStreamingSession = null;
|
mStreamingSession = null;
|
||||||
mSocketConnector = null;
|
|
||||||
|
|
||||||
mConnecting.set(false);
|
mConnecting.set(false);
|
||||||
super.sessionClosed(session);
|
super.sessionClosed(session);
|
||||||
@@ -382,13 +382,11 @@ public class ShoutcastV2AudioBroadcaster extends AudioBroadcaster implements IBr
|
|||||||
{
|
{
|
||||||
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
mLog.info("Streaming connection reset by remote server - reestablishing connection");
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else if(reason.startsWith("Operation timed out"))
|
else if(reason.startsWith("Operation timed out"))
|
||||||
{
|
{
|
||||||
mLog.info("Streaming connection timed out - resetting connection");
|
mLog.info("Streaming connection timed out - resetting connection");
|
||||||
disconnect();
|
disconnect();
|
||||||
connect();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user