From 2168ed112e593c604c8bbf908ccef0069ee48d70 Mon Sep 17 00:00:00 2001 From: Denny Date: Sun, 22 Jan 2017 07:28:37 -0500 Subject: [PATCH 1/3] #111 - import cleanup --- src/channel/metadata/ChannelMetadataPanel.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/channel/metadata/ChannelMetadataPanel.java b/src/channel/metadata/ChannelMetadataPanel.java index c3a07090..d16161de 100644 --- a/src/channel/metadata/ChannelMetadataPanel.java +++ b/src/channel/metadata/ChannelMetadataPanel.java @@ -20,7 +20,6 @@ package channel.metadata; import alias.Alias; import channel.state.State; -import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory; import controller.channel.Channel; import controller.channel.ChannelProcessingManager; import icon.IconManager; From 6e94d9ce51a2fa63c7e72feda6c664a0bce28414 Mon Sep 17 00:00:00 2001 From: Denny Date: Sun, 22 Jan 2017 09:33:47 -0500 Subject: [PATCH 2/3] #108 [WIP] Created new ThreadPool class with a static ScheduledThreadExecutor that is now shared by all components. Removed ThreadPoolManager from all classes. Consolidating into 1 pool seems to have reduced CPU usage by ~15-20%. Overall memory usage is also reduced. --- src/alias/action/AliasAction.java | 47 +- src/alias/action/AliasActionManager.java | 91 +- src/alias/action/RecurringAction.java | 335 +- src/audio/AudioManager.java | 28 +- src/audio/broadcast/AudioBroadcaster.java | 22 +- src/audio/broadcast/BroadcastFactory.java | 34 +- src/audio/broadcast/BroadcastModel.java | 18 +- src/audio/broadcast/StreamManager.java | 15 +- .../icecast/IcecastAudioBroadcaster.java | 9 +- .../IcecastBroadcastMetadataUpdater.java | 8 +- .../icecast/IcecastHTTPAudioBroadcaster.java | 22 +- .../icecast/IcecastTCPAudioBroadcaster.java | 19 +- .../v1/ShoutcastV1AudioBroadcaster.java | 23 +- .../ShoutcastV1BroadcastMetadataUpdater.java | 8 +- .../v2/ShoutcastV2AudioBroadcaster.java | 10 +- src/audio/output/AudioOutput.java | 19 +- src/audio/output/MonoAudioOutput.java | 105 +- src/audio/output/StereoAudioOutput.java | 138 +- src/controller/ThreadPoolManager.java | 113 - src/gui/SDRTrunk.java | 151 +- src/icon/IconManager.java | 12 +- src/instrument/gui/DecoderSelectionFrame.java | 128 +- src/map/MapService.java | 11 +- src/module/ProcessingChain.java | 23 +- src/playlist/PlaylistManager.java | 13 +- src/properties/SystemProperties.java | 12 +- src/record/RecorderManager.java | 10 +- src/record/mp3/MP3Recorder.java | 22 - src/settings/SettingsManager.java | 10 +- src/source/SourceManager.java | 136 +- src/source/tuner/TunerChannelSource.java | 616 ++- src/source/tuner/TunerManager.java | 791 ++- .../tuner/airspy/AirspyTunerController.java | 2741 +++++----- .../tuner/hackrf/HackRFTunerController.java | 2085 ++++---- .../tuner/rtl/RTL2832TunerController.java | 3479 +++++++------ .../tuner/rtl/e4k/E4KTunerController.java | 4491 ++++++++--------- .../tuner/rtl/r820t/R820TTunerController.java | 2053 ++++---- src/spectrum/DFTProcessor.java | 38 +- src/util/ThreadPool.java | 54 + 39 files changed, 8822 insertions(+), 9118 deletions(-) delete mode 100644 src/controller/ThreadPoolManager.java create mode 100644 src/util/ThreadPool.java diff --git a/src/alias/action/AliasAction.java b/src/alias/action/AliasAction.java index 4d10dd29..c353da28 100644 --- a/src/alias/action/AliasAction.java +++ b/src/alias/action/AliasAction.java @@ -1,32 +1,33 @@ /******************************************************************************* - * SDR Trunk - * Copyright (C) 2014-2016 Dennis Sheirer - * - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see + * sdrtrunk + * Copyright (C) 2014-2017 Dennis Sheirer + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + * ******************************************************************************/ package alias.action; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSeeAlso; -import javax.xml.bind.annotation.XmlTransient; - -import message.Message; import alias.Alias; import alias.action.beep.BeepAction; import alias.action.clip.ClipAction; import alias.action.script.ScriptAction; -import controller.ThreadPoolManager; +import message.Message; + +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.bind.annotation.XmlTransient; +import java.util.concurrent.ScheduledExecutorService; /** * Alias action defines an action to execute when an alias is detected active. @@ -48,9 +49,7 @@ public abstract class AliasAction * action attached. The alias argument is the parent alias containing the * alias action. */ - public abstract void execute( ThreadPoolManager threadPoolManager, - Alias alias, - Message message ); + public abstract void execute( ScheduledExecutorService scheduledExecutorService, Alias alias, Message message ); /** * Dismiss a persistent alias action diff --git a/src/alias/action/AliasActionManager.java b/src/alias/action/AliasActionManager.java index 20a63440..0ba644d1 100644 --- a/src/alias/action/AliasActionManager.java +++ b/src/alias/action/AliasActionManager.java @@ -1,54 +1,69 @@ +/******************************************************************************* + * sdrtrunk + * Copyright (C) 2014-2017 Dennis Sheirer + * + * 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + * + ******************************************************************************/ package alias.action; -import java.util.List; - +import alias.Alias; import message.Message; import sample.Listener; -import alias.Alias; -import controller.ThreadPoolManager; +import util.ThreadPool; + +import java.util.List; /** * Manages all alias action events. Each received message is interrogated for * any alias entries and then each alias is interrogated for any alias actions. - * - * Each alias action is executed and provided a copy of the source message so + * + * Each alias action is executed and provided a copy of the source message so * that the contents of the message can be used as part of the action. */ public class AliasActionManager implements Listener { - private ThreadPoolManager mThreadPoolManager; - - public AliasActionManager( ThreadPoolManager threadPoolManager ) - { - mThreadPoolManager = threadPoolManager; - } - - @Override - public void receive( Message message ) - { - if( message.isValid() ) - { - List aliases = message.getAliases(); - - if( aliases != null ) - { - for( Alias alias: aliases ) - { - if( alias.hasActions() ) - { - List actions = alias.getAction(); - - for( AliasAction action: actions ) - { - /* Provide access to the thread pool manager in case the + public AliasActionManager() + { + } + + @Override + public void receive(Message message) + { + if(message.isValid()) + { + List aliases = message.getAliases(); + + if(aliases != null) + { + for(Alias alias : aliases) + { + if(alias.hasActions()) + { + List actions = alias.getAction(); + + for(AliasAction action : actions) + { + /* Provide access to the thread pool manager in case the * action needs to setup a timer, and provide the original * message to be used as part of the action (e.g. sending * the message as a text message to a cell phone */ - action.execute( mThreadPoolManager, alias, message ); - } - } - } - } - } - } + action.execute(ThreadPool.SCHEDULED, alias, message); + } + } + } + } + } + } } diff --git a/src/alias/action/RecurringAction.java b/src/alias/action/RecurringAction.java index 8d6298c2..c8e54d62 100644 --- a/src/alias/action/RecurringAction.java +++ b/src/alias/action/RecurringAction.java @@ -1,188 +1,181 @@ package alias.action; -import java.awt.EventQueue; +import alias.Alias; +import message.Message; + +import javax.swing.*; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlTransient; +import java.awt.*; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; -import javax.swing.JOptionPane; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlTransient; - -import message.Message; -import alias.Alias; -import controller.ThreadPoolManager; -import controller.ThreadPoolManager.ThreadType; - public abstract class RecurringAction extends AliasAction { - @XmlTransient - protected AtomicBoolean mRunning = new AtomicBoolean( false ); - @XmlTransient - private ScheduledFuture mPerpetualAction; - - protected Interval mInterval = Interval.ONCE; - protected int mPeriod = 5; - - protected ThreadPoolManager mThreadPoolManager; - - public abstract void performAction( Alias alias, Message message ); + @XmlTransient + protected AtomicBoolean mRunning = new AtomicBoolean(false); + @XmlTransient + private ScheduledFuture mPerpetualAction; + @XmlTransient + protected ScheduledExecutorService mScheduledExecutorService; - @Override - public void execute( ThreadPoolManager threadPoolManager, - Alias alias, - Message message ) - { - mThreadPoolManager = threadPoolManager; + protected Interval mInterval = Interval.ONCE; + protected int mPeriod = 5; - if( mRunning.compareAndSet( false, true ) ) - { - switch( mInterval ) - { - case ONCE: - performThreadedAction( alias, message ); - /* Don't reset */ - break; - case DELAYED_RESET: - performThreadedAction( alias, message ); - mThreadPoolManager.scheduleOnce( new ResetTask(), - mPeriod, TimeUnit.SECONDS ); - break; - case UNTIL_DISMISSED: - mPerpetualAction = mThreadPoolManager - .scheduleFixedRate( ThreadType.DECODER, - new PerformActionTask( alias, message ), - mPeriod, TimeUnit.SECONDS ); + public abstract void performAction(Alias alias, Message message); - StringBuilder sb = new StringBuilder(); - sb.append( "
Alias [" ); - sb.append( alias.getName() ); - sb.append( "] is active in message [" ); - sb.append( message.toString() ); - sb.append( "]
" ); - - final String text = sb.toString(); - - EventQueue.invokeLater( new Runnable() - { - @Override - public void run() - { - JOptionPane.showMessageDialog( null, text, - "Alias Alert", JOptionPane.INFORMATION_MESSAGE ); - - dismiss( false ); - - mThreadPoolManager.scheduleOnce( new ResetTask(), - 15, TimeUnit.SECONDS ); - } - } ); - break; - default: - } - } - } + @Override + public void execute(ScheduledExecutorService scheduledExecutorService, Alias alias, Message message) + { + mScheduledExecutorService = scheduledExecutorService; - /** - * Spawns the performAction() event into a new thread so that it doesn't - * delay any decoder actions. - */ - private void performThreadedAction( final Alias alias, final Message message ) - { - mThreadPoolManager.scheduleOnce( new Runnable() { + if(mRunning.compareAndSet(false, true)) + { + switch(mInterval) + { + case ONCE: + performThreadedAction(alias, message); + /* Don't reset */ + break; + case DELAYED_RESET: + performThreadedAction(alias, message); + mScheduledExecutorService.schedule(new ResetTask(), mPeriod, TimeUnit.SECONDS); + break; + case UNTIL_DISMISSED: + mPerpetualAction = mScheduledExecutorService.scheduleAtFixedRate( + new PerformActionTask(alias, message), mPeriod, mPeriod, TimeUnit.SECONDS); - @Override - public void run() - { - performAction( alias, message ); - }}, 0, TimeUnit.SECONDS ); - } - - @Override - public void dismiss( boolean reset ) - { - if( mPerpetualAction != null ) - { - mPerpetualAction.cancel( true ); - - mPerpetualAction = null; - } - - if( reset ) - { - mRunning.set( false ); - } - } - - @XmlAttribute - public int getPeriod() - { - return mPeriod; - } - - public void setPeriod( int period ) - { - mPeriod = period; - } - - @XmlAttribute - public Interval getInterval() - { - return mInterval; - } - - public void setInterval( Interval interval ) - { - mInterval = interval; - - mRunning.set( false ); - } - - public enum Interval - { - ONCE( "Once" ), - DELAYED_RESET( "Once, Reset After Delay" ), - UNTIL_DISMISSED( "Until Dismissed" ); - - private String mLabel; - - private Interval( String label ) - { - mLabel = label; - } - - public String toString() - { - return mLabel; - } - } - - public class PerformActionTask implements Runnable - { - private Alias mAlias; - private Message mMessage; + StringBuilder sb = new StringBuilder(); + sb.append("
Alias ["); + sb.append(alias.getName()); + sb.append("] is active in message ["); + sb.append(message.toString()); + sb.append("]
"); - public PerformActionTask( Alias alias, Message message ) - { - mAlias = alias; - mMessage = message; - } - - @Override - public void run() - { + final String text = sb.toString(); + + EventQueue.invokeLater(new Runnable() + { + @Override + public void run() + { + JOptionPane.showMessageDialog(null, text, + "Alias Alert", JOptionPane.INFORMATION_MESSAGE); + + dismiss(false); + + mScheduledExecutorService.schedule(new ResetTask(), 15, TimeUnit.SECONDS); + } + }); + break; + default: + } + } + } + + /** + * Spawns the performAction() event into a new thread so that it doesn't + * delay any decoder actions. + */ + private void performThreadedAction(final Alias alias, final Message message) + { + mScheduledExecutorService.schedule(new Runnable() + { + @Override + public void run() + { + performAction(alias, message); + } + }, 0, TimeUnit.SECONDS); + } + + @Override + public void dismiss(boolean reset) + { + if(mPerpetualAction != null) + { + mPerpetualAction.cancel(true); + + mPerpetualAction = null; + } + + if(reset) + { + mRunning.set(false); + } + } + + @XmlAttribute + public int getPeriod() + { + return mPeriod; + } + + public void setPeriod(int period) + { + mPeriod = period; + } + + @XmlAttribute + public Interval getInterval() + { + return mInterval; + } + + public void setInterval(Interval interval) + { + mInterval = interval; + + mRunning.set(false); + } + + public enum Interval + { + ONCE("Once"), + DELAYED_RESET("Once, Reset After Delay"), + UNTIL_DISMISSED("Until Dismissed"); + + private String mLabel; + + private Interval(String label) + { + mLabel = label; + } + + public String toString() + { + return mLabel; + } + } + + public class PerformActionTask implements Runnable + { + private Alias mAlias; + private Message mMessage; + + public PerformActionTask(Alias alias, Message message) + { + mAlias = alias; + mMessage = message; + } + + @Override + public void run() + { /* Don't use the performThreadedAction() method, since this is * already running in a separate thread */ - performAction( mAlias, mMessage ); - } - } - - public class ResetTask implements Runnable - { - @Override - public void run() - { - mRunning.set( false ); - } - } + performAction(mAlias, mMessage); + } + } + + public class ResetTask implements Runnable + { + @Override + public void run() + { + mRunning.set(false); + } + } } diff --git a/src/audio/AudioManager.java b/src/audio/AudioManager.java index 02578da0..2cab2400 100644 --- a/src/audio/AudioManager.java +++ b/src/audio/AudioManager.java @@ -22,8 +22,6 @@ import audio.AudioEvent.Type; import audio.output.AudioOutput; import audio.output.MonoAudioOutput; import audio.output.StereoAudioOutput; -import controller.ThreadPoolManager; -import controller.ThreadPoolManager.ThreadType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import properties.SystemProperties; @@ -32,6 +30,7 @@ import sample.Listener; import source.mixer.MixerChannel; import source.mixer.MixerChannelConfiguration; import source.mixer.MixerManager; +import util.ThreadPool; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Mixer; @@ -70,7 +69,6 @@ public class AudioManager implements Listener, IAudioController private Broadcaster mControllerBroadcaster = new Broadcaster<>(); - private ThreadPoolManager mThreadPoolManager; private ScheduledFuture mProcessingTask; private MixerManager mMixerManager; private MixerChannelConfiguration mMixerChannelConfiguration; @@ -81,9 +79,8 @@ public class AudioManager implements Listener, IAudioController * packets to any combination of outputs based on any alias audio routing * options specified by the user. */ - public AudioManager(ThreadPoolManager manager, MixerManager mixerManager) + public AudioManager(MixerManager mixerManager) { - mThreadPoolManager = manager; mMixerManager = mixerManager; loadSettings(); @@ -145,14 +142,13 @@ public class AudioManager implements Listener, IAudioController public void dispose() { - if(mThreadPoolManager != null && mProcessingTask != null) + if(mProcessingTask != null) { - mThreadPoolManager.cancel(mProcessingTask); + mProcessingTask.cancel(true); } mAudioPacketQueue.clear(); - mThreadPoolManager = null; mProcessingTask = null; mChannelConnectionMap.clear(); @@ -224,9 +220,9 @@ public class AudioManager implements Listener, IAudioController { mControllerBroadcaster.broadcast(CONFIGURATION_CHANGE_STARTED); - if(mThreadPoolManager != null && mProcessingTask != null) + if(mProcessingTask != null) { - mThreadPoolManager.cancel(mProcessingTask); + mProcessingTask.cancel(true); } disposeCurrentConfiguration(); @@ -234,19 +230,18 @@ public class AudioManager implements Listener, IAudioController switch(entry.getMixerChannel()) { case MONO: - AudioOutput mono = new MonoAudioOutput(mThreadPoolManager, - entry.getMixer()); + AudioOutput mono = new MonoAudioOutput(entry.getMixer()); mAudioOutputConnections.add(new AudioOutputConnection(mono)); mAvailableConnectionCount++; mAudioOutputMap.put(mono.getChannelName(), mono); break; case STEREO: - AudioOutput left = new StereoAudioOutput(mThreadPoolManager, entry.getMixer(), MixerChannel.LEFT); + AudioOutput left = new StereoAudioOutput(entry.getMixer(), MixerChannel.LEFT); mAudioOutputConnections.add(new AudioOutputConnection(left)); mAvailableConnectionCount++; mAudioOutputMap.put(left.getChannelName(), left); - AudioOutput right = new StereoAudioOutput(mThreadPoolManager, entry.getMixer(), MixerChannel.RIGHT); + AudioOutput right = new StereoAudioOutput(entry.getMixer(), MixerChannel.RIGHT); mAudioOutputConnections.add(new AudioOutputConnection(right)); mAvailableConnectionCount++; mAudioOutputMap.put(right.getChannelName(), right); @@ -256,9 +251,8 @@ public class AudioManager implements Listener, IAudioController + "configuration: " + entry.getMixerChannel()); } - mProcessingTask = mThreadPoolManager.scheduleFixedRate( - ThreadType.AUDIO_PROCESSING, new AudioPacketProcessor(), 15, - TimeUnit.MILLISECONDS); + mProcessingTask = ThreadPool.SCHEDULED.scheduleAtFixedRate(new AudioPacketProcessor(), + 0, 15, TimeUnit.MILLISECONDS); mControllerBroadcaster.broadcast(CONFIGURATION_CHANGE_COMPLETE); diff --git a/src/audio/broadcast/AudioBroadcaster.java b/src/audio/broadcast/AudioBroadcaster.java index 8644e4da..050168c8 100644 --- a/src/audio/broadcast/AudioBroadcaster.java +++ b/src/audio/broadcast/AudioBroadcaster.java @@ -20,10 +20,10 @@ package audio.broadcast; import audio.convert.ISilenceGenerator; import channel.metadata.Metadata; -import controller.ThreadPoolManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import sample.Listener; +import util.ThreadPool; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -40,7 +40,6 @@ public abstract class AudioBroadcaster implements Listener public static final int PROCESSOR_RUN_INTERVAL_MS = 1000; - private ThreadPoolManager mThreadPoolManager; private ScheduledFuture mScheduledTask; private RecordingQueueProcessor mRecordingQueueProcessor = new RecordingQueueProcessor(); @@ -77,19 +76,13 @@ public abstract class AudioBroadcaster implements Listener * The last audio packet's metadata is automatically attached to the closed audio recording when it is enqueued for * broadcast. That metadata will be updated on the remote server once the audio recording is opened for streaming. */ - public AudioBroadcaster(ThreadPoolManager threadPoolManager, BroadcastConfiguration broadcastConfiguration) + public AudioBroadcaster(BroadcastConfiguration broadcastConfiguration) { - mThreadPoolManager = threadPoolManager; mBroadcastConfiguration = broadcastConfiguration; mDelay = mBroadcastConfiguration.getDelay(); mSilenceGenerator = BroadcastFactory.getSilenceGenerator(broadcastConfiguration.getBroadcastFormat()); } - protected ThreadPoolManager getThreadPoolManager() - { - return mThreadPoolManager; - } - /** * Broadcast binary audio data frames or sequences. */ @@ -129,11 +122,8 @@ public abstract class AudioBroadcaster implements Listener { if(mScheduledTask == null) { - if(mThreadPoolManager != null) - { - mScheduledTask = mThreadPoolManager.scheduleFixedRate(ThreadPoolManager.ThreadType.AUDIO_PROCESSING, - mRecordingQueueProcessor, PROCESSOR_RUN_INTERVAL_MS, TimeUnit.MILLISECONDS); - } + ThreadPool.SCHEDULED.scheduleAtFixedRate(mRecordingQueueProcessor, 0, + PROCESSOR_RUN_INTERVAL_MS, TimeUnit.MILLISECONDS); } } } @@ -145,9 +135,9 @@ public abstract class AudioBroadcaster implements Listener { if(mStreaming.compareAndSet(true, false)) { - if(mThreadPoolManager != null && mScheduledTask != null) + if(mScheduledTask != null) { - mThreadPoolManager.cancel(mScheduledTask); + mScheduledTask.cancel(true); } disconnect(); diff --git a/src/audio/broadcast/BroadcastFactory.java b/src/audio/broadcast/BroadcastFactory.java index 745be778..75caef3b 100644 --- a/src/audio/broadcast/BroadcastFactory.java +++ b/src/audio/broadcast/BroadcastFactory.java @@ -37,7 +37,6 @@ import audio.convert.IAudioConverter; import audio.convert.ISilenceGenerator; import audio.convert.MP3AudioConverter; import audio.convert.MP3SilenceGenerator; -import controller.ThreadPoolManager; import gui.editor.Editor; import gui.editor.EmptyEditor; import icon.IconManager; @@ -45,25 +44,23 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import record.AudioRecorder; import record.mp3.MP3Recorder; -import settings.SettingsManager; import java.nio.file.Path; public class BroadcastFactory { - private final static Logger mLog = LoggerFactory.getLogger( BroadcastFactory.class ); + private final static Logger mLog = LoggerFactory.getLogger(BroadcastFactory.class); public static final int MP3_MONO_16_KHZ_BITRATE = 16; public static final boolean MP3_CONSTANT_BITRATE = false; /** * Creates an audio streaming broadcaster for the configuration - * @param threadPoolManager for creating an audio broadcasting connection thread + * * @param configuration describing the server and audio types * @return configured broadcaster or null */ - public static AudioBroadcaster getBroadcaster(ThreadPoolManager threadPoolManager, - BroadcastConfiguration configuration) + public static AudioBroadcaster getBroadcaster(BroadcastConfiguration configuration) { if(configuration != null) { @@ -74,20 +71,15 @@ public class BroadcastFactory switch(configuration.getBroadcastServerType()) { case BROADCASTIFY: - return new IcecastTCPAudioBroadcaster(threadPoolManager, - (BroadcastifyConfiguration)configuration); + return new IcecastTCPAudioBroadcaster((BroadcastifyConfiguration) configuration); case ICECAST_TCP: - return new IcecastTCPAudioBroadcaster(threadPoolManager, - (IcecastTCPConfiguration)configuration); + return new IcecastTCPAudioBroadcaster((IcecastTCPConfiguration) configuration); case ICECAST_HTTP: - return new IcecastHTTPAudioBroadcaster(threadPoolManager, - (IcecastHTTPConfiguration)configuration); + return new IcecastHTTPAudioBroadcaster((IcecastHTTPConfiguration) configuration); case SHOUTCAST_V1: - return new ShoutcastV1AudioBroadcaster(threadPoolManager, - (ShoutcastV1Configuration)configuration); + return new ShoutcastV1AudioBroadcaster((ShoutcastV1Configuration) configuration); case SHOUTCAST_V2: - return new ShoutcastV2AudioBroadcaster(threadPoolManager, - (ShoutcastV2Configuration)configuration); + return new ShoutcastV2AudioBroadcaster((ShoutcastV2Configuration) configuration); case UNKNOWN: default: mLog.info("Unrecognized broadcastAudio configuration: " + configuration.getBroadcastFormat().name()); @@ -101,6 +93,7 @@ public class BroadcastFactory /** * Creates an audio convert to convert from 8 kHz PCM audio to the specified format + * * @param configuration containing the requested output audio format * @return audio convert or null */ @@ -149,6 +142,7 @@ public class BroadcastFactory /** * Constructs an editor for the specified broadcastAudio configuration + * * @param configuration to modify or view * @param broadcastModel model for broadcastAudio configurations * @return an editor for the specified broadcastAudio configuration @@ -160,10 +154,10 @@ public class BroadcastFactory { Editor editor; - switch (configuration.getBroadcastServerType()) + switch(configuration.getBroadcastServerType()) { case BROADCASTIFY: - editor = new BroadcastifyConfigurationEditor(broadcastModel, aliasModel, iconManager); + editor = new BroadcastifyConfigurationEditor(broadcastModel, aliasModel, iconManager); break; case ICECAST_TCP: editor = new IcecastTCPConfigurationEditor(broadcastModel, aliasModel, iconManager); @@ -192,7 +186,7 @@ public class BroadcastFactory */ public static AudioRecorder getAudioRecorder(Path path, BroadcastFormat broadcastFormat) { - switch (broadcastFormat) + switch(broadcastFormat) { case MP3: return new MP3Recorder(path); @@ -204,7 +198,7 @@ public class BroadcastFactory public static ISilenceGenerator getSilenceGenerator(BroadcastFormat format) { - switch (format) + switch(format) { case MP3: return new MP3SilenceGenerator(); diff --git a/src/audio/broadcast/BroadcastModel.java b/src/audio/broadcast/BroadcastModel.java index ad79cf9a..d4b449bf 100644 --- a/src/audio/broadcast/BroadcastModel.java +++ b/src/audio/broadcast/BroadcastModel.java @@ -21,13 +21,13 @@ package audio.broadcast; import alias.id.broadcast.BroadcastChannel; import audio.AudioPacket; import channel.metadata.Metadata; -import controller.ThreadPoolManager; import icon.IconManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import properties.SystemProperties; import sample.Broadcaster; import sample.Listener; +import util.ThreadPool; import javax.swing.*; import javax.swing.table.AbstractTableModel; @@ -66,7 +66,6 @@ public class BroadcastModel extends AbstractTableModel implements Listener