mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-16 18:47:33 -05:00
Merge pull request #143 from DSheirer/141-streaming-temp-recordings-when-disabled
#141 - resolves issue with temporary streaming recordings being gener…
This commit is contained in:
@@ -40,7 +40,7 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
|
|||||||
|
|
||||||
public static final int PROCESSOR_RUN_INTERVAL_MS = 1000;
|
public static final int PROCESSOR_RUN_INTERVAL_MS = 1000;
|
||||||
|
|
||||||
private ScheduledFuture mScheduledTask;
|
private ScheduledFuture mRecordingQueueProcessorFuture;
|
||||||
|
|
||||||
private RecordingQueueProcessor mRecordingQueueProcessor = new RecordingQueueProcessor();
|
private RecordingQueueProcessor mRecordingQueueProcessor = new RecordingQueueProcessor();
|
||||||
private Queue<AudioRecording> mAudioRecordingQueue = new LinkedTransferQueue<>();
|
private Queue<AudioRecording> mAudioRecordingQueue = new LinkedTransferQueue<>();
|
||||||
@@ -120,10 +120,10 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
|
|||||||
{
|
{
|
||||||
if(mStreaming.compareAndSet(false, true))
|
if(mStreaming.compareAndSet(false, true))
|
||||||
{
|
{
|
||||||
if(mScheduledTask == null)
|
if(mRecordingQueueProcessorFuture == null)
|
||||||
{
|
{
|
||||||
ThreadPool.SCHEDULED.scheduleAtFixedRate(mRecordingQueueProcessor, 0,
|
mRecordingQueueProcessorFuture = ThreadPool.SCHEDULED.scheduleAtFixedRate(mRecordingQueueProcessor,
|
||||||
PROCESSOR_RUN_INTERVAL_MS, TimeUnit.MILLISECONDS);
|
0, PROCESSOR_RUN_INTERVAL_MS, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,9 +135,10 @@ public abstract class AudioBroadcaster implements Listener<AudioRecording>
|
|||||||
{
|
{
|
||||||
if(mStreaming.compareAndSet(true, false))
|
if(mStreaming.compareAndSet(true, false))
|
||||||
{
|
{
|
||||||
if(mScheduledTask != null)
|
if(mRecordingQueueProcessorFuture != null)
|
||||||
{
|
{
|
||||||
mScheduledTask.cancel(true);
|
mRecordingQueueProcessorFuture.cancel(true);
|
||||||
|
mRecordingQueueProcessorFuture = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect();
|
disconnect();
|
||||||
|
|||||||
@@ -274,10 +274,16 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
|||||||
@Override
|
@Override
|
||||||
public void receive(AudioPacket audioPacket)
|
public void receive(AudioPacket audioPacket)
|
||||||
{
|
{
|
||||||
if(audioPacket.hasMetadata() &&
|
if(audioPacket.hasMetadata() && audioPacket.getMetadata().isStreamable())
|
||||||
audioPacket.getMetadata().isStreamable())
|
|
||||||
{
|
{
|
||||||
mStreamManager.receive(audioPacket);
|
for(BroadcastChannel channel: audioPacket.getMetadata().getBroadcastChannels())
|
||||||
|
{
|
||||||
|
if(mBroadcasterMap.containsKey(channel.getChannelName()))
|
||||||
|
{
|
||||||
|
mStreamManager.receive(audioPacket);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,9 +292,7 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
|||||||
*/
|
*/
|
||||||
private void createBroadcaster(BroadcastConfiguration broadcastConfiguration)
|
private void createBroadcaster(BroadcastConfiguration broadcastConfiguration)
|
||||||
{
|
{
|
||||||
if(broadcastConfiguration != null &&
|
if(broadcastConfiguration != null && broadcastConfiguration.isEnabled() && broadcastConfiguration.isValid() &&
|
||||||
broadcastConfiguration.isEnabled() &&
|
|
||||||
broadcastConfiguration.isValid() &&
|
|
||||||
!mBroadcasterMap.containsKey(broadcastConfiguration.getName()))
|
!mBroadcasterMap.containsKey(broadcastConfiguration.getName()))
|
||||||
{
|
{
|
||||||
AudioBroadcaster audioBroadcaster = BroadcastFactory.getBroadcaster(broadcastConfiguration);
|
AudioBroadcaster audioBroadcaster = BroadcastFactory.getBroadcaster(broadcastConfiguration);
|
||||||
@@ -393,15 +397,20 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
|||||||
case CONFIGURATION_CHANGE:
|
case CONFIGURATION_CHANGE:
|
||||||
BroadcastConfiguration broadcastConfiguration = broadcastEvent.getBroadcastConfiguration();
|
BroadcastConfiguration broadcastConfiguration = broadcastEvent.getBroadcastConfiguration();
|
||||||
int index = mBroadcastConfigurations.indexOf(broadcastConfiguration);
|
int index = mBroadcastConfigurations.indexOf(broadcastConfiguration);
|
||||||
fireTableRowsUpdated(index, index);
|
|
||||||
|
|
||||||
//Delete and recreate the broadcaster for any broadcast configuration changes
|
//Delete the existing broadcaster for any broadcast configuration changes
|
||||||
String previousChannelName = cleanupMapAssociations(broadcastConfiguration);
|
String previousChannelName = cleanupMapAssociations(broadcastConfiguration);
|
||||||
deleteBroadcaster(previousChannelName);
|
deleteBroadcaster(previousChannelName);
|
||||||
|
|
||||||
//Delay restarting the broadcaster to allow remote server time to cleanup
|
//If the configuration is enabled, create a new broadcaster after a brief delay
|
||||||
ThreadPool.SCHEDULED.schedule(new DelayedBroadcasterStartup(broadcastConfiguration),
|
if(broadcastConfiguration.isEnabled())
|
||||||
1, TimeUnit.SECONDS);
|
{
|
||||||
|
//Delay restarting the broadcaster to allow remote server time to cleanup
|
||||||
|
ThreadPool.SCHEDULED.schedule(new DelayedBroadcasterStartup(broadcastConfiguration),
|
||||||
|
3, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
fireTableRowsUpdated(index, index);
|
||||||
break;
|
break;
|
||||||
case CONFIGURATION_DELETE:
|
case CONFIGURATION_DELETE:
|
||||||
deleteBroadcaster(broadcastEvent.getBroadcastConfiguration().getName());
|
deleteBroadcaster(broadcastEvent.getBroadcastConfiguration().getName());
|
||||||
|
|||||||
@@ -222,8 +222,8 @@ public class StreamManager implements Listener<AudioPacket>
|
|||||||
.filter(entry -> entry.getValue().getTimeRecordingStart() + MAXIMUM_RECORDER_LIFESPAN_MILLIS < now)
|
.filter(entry -> entry.getValue().getTimeRecordingStart() + MAXIMUM_RECORDER_LIFESPAN_MILLIS < now)
|
||||||
.forEach(entry ->
|
.forEach(entry ->
|
||||||
{
|
{
|
||||||
mLog.debug("Maximum recording time limit reached - removing recorder: " +
|
mLog.info("cycling recorder - max temporary streaming recording time limit reached [" +
|
||||||
entry.getValue().getPath().toString());
|
entry.getValue().getPath().toString() + "]");
|
||||||
|
|
||||||
removeRecorder(entry.getKey());
|
removeRecorder(entry.getKey());
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user