mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
#660 Updates audio processing subsystem to use audio segments. Updates audio playback, recording and streaming to use audio segments. Adds support to UserPreferences for sound card selection and audio tone insertion during playback. Adds record preference for WAVE or MP3. Resolves issues with metadata in recordings. (#675)
This commit is contained in:
@@ -1,76 +1,108 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2020 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 <http://www.gnu.org/licenses/>
|
||||
* ****************************************************************************
|
||||
*/
|
||||
|
||||
package io.github.dsheirer.source.mixer;
|
||||
|
||||
import javax.sound.sampled.Mixer;
|
||||
|
||||
public class MixerChannelConfiguration
|
||||
{
|
||||
private Mixer mMixer;
|
||||
private MixerChannel mMixerChannel;
|
||||
|
||||
public MixerChannelConfiguration( Mixer mixer, MixerChannel channel )
|
||||
{
|
||||
mMixer = mixer;
|
||||
mMixerChannel = channel;
|
||||
}
|
||||
|
||||
public Mixer getMixer()
|
||||
{
|
||||
return mMixer;
|
||||
}
|
||||
|
||||
public MixerChannel getMixerChannel()
|
||||
{
|
||||
return mMixerChannel;
|
||||
}
|
||||
|
||||
public boolean matches( String mixer, String channels )
|
||||
{
|
||||
return mixer != null &&
|
||||
channels != null &&
|
||||
mMixer.getMixerInfo().getName().contentEquals( mixer ) &&
|
||||
mMixerChannel.name().contentEquals( channels );
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( mMixer.getMixerInfo().getName() );
|
||||
sb.append( " - " );
|
||||
sb.append( mMixerChannel.name() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
private Mixer mMixer;
|
||||
private MixerChannel mMixerChannel;
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ( ( mMixer == null ) ? 0 : mMixer.hashCode() );
|
||||
result = prime * result
|
||||
+ ( ( mMixerChannel == null ) ? 0 : mMixerChannel.hashCode() );
|
||||
return result;
|
||||
}
|
||||
public MixerChannelConfiguration(Mixer mixer, MixerChannel channel)
|
||||
{
|
||||
mMixer = mixer;
|
||||
mMixerChannel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
return true;
|
||||
if ( obj == null )
|
||||
return false;
|
||||
if ( getClass() != obj.getClass() )
|
||||
return false;
|
||||
MixerChannelConfiguration other = (MixerChannelConfiguration) obj;
|
||||
if ( mMixer == null )
|
||||
public Mixer getMixer()
|
||||
{
|
||||
return mMixer;
|
||||
}
|
||||
|
||||
public MixerChannel getMixerChannel()
|
||||
{
|
||||
return mMixerChannel;
|
||||
}
|
||||
|
||||
public boolean matches(String mixer, String channels)
|
||||
{
|
||||
return mixer != null &&
|
||||
channels != null &&
|
||||
mMixer.getMixerInfo().getName().contentEquals(mixer) &&
|
||||
mMixerChannel.name().contentEquals(channels);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(mMixer.getMixerInfo().getName());
|
||||
sb.append(" - ");
|
||||
sb.append(mMixerChannel.name());
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((mMixer == null) ? 0 : mMixer.hashCode());
|
||||
result = prime * result
|
||||
+ ((mMixerChannel == null) ? 0 : mMixerChannel.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
{
|
||||
if ( other.mMixer != null )
|
||||
return true;
|
||||
}
|
||||
if(obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(getClass() != obj.getClass())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MixerChannelConfiguration other = (MixerChannelConfiguration)obj;
|
||||
if(mMixer == null)
|
||||
{
|
||||
if(other.mMixer != null)
|
||||
{
|
||||
return false;
|
||||
} else if ( !mMixer.equals( other.mMixer ) )
|
||||
}
|
||||
}
|
||||
else if(!mMixer.equals(other.mMixer))
|
||||
{
|
||||
return false;
|
||||
if ( mMixerChannel != other.mMixerChannel )
|
||||
}
|
||||
if(mMixerChannel != other.mMixerChannel)
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,26 +36,19 @@ import javax.sound.sampled.SourceDataLine;
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Utility class for accessing input, output and tuner mixers
|
||||
*/
|
||||
public class MixerManager
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(MixerManager.class);
|
||||
|
||||
private List<InputMixerConfiguration> mInputMixers = new ArrayList<>();
|
||||
private List<MixerChannelConfiguration> mOutputMixers = new ArrayList<>();
|
||||
private Map<String,MixerTunerDataLine> mMixerTuners = new HashMap<>();
|
||||
public MixerManager() {}
|
||||
|
||||
public MixerManager()
|
||||
{
|
||||
loadMixers();
|
||||
}
|
||||
|
||||
public RealMixerSource getSource(SourceConfiguration config)
|
||||
public static RealMixerSource getSource(SourceConfiguration config)
|
||||
{
|
||||
RealMixerSource retVal = null;
|
||||
|
||||
@@ -131,14 +124,31 @@ public class MixerManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public InputMixerConfiguration[] getInputMixers()
|
||||
public static List<InputMixerConfiguration> getInputMixers()
|
||||
{
|
||||
return mInputMixers.toArray(new InputMixerConfiguration[mInputMixers.size()]);
|
||||
List<InputMixerConfiguration> inputMixers = new ArrayList<>();
|
||||
|
||||
for(Mixer.Info mixerInfo : AudioSystem.getMixerInfo())
|
||||
{
|
||||
Mixer mixer = AudioSystem.getMixer(mixerInfo);
|
||||
|
||||
if(mixer != null)
|
||||
{
|
||||
EnumSet<MixerChannel> inputChannels = getSupportedTargetChannels(mixer);
|
||||
|
||||
if(inputChannels != null)
|
||||
{
|
||||
inputMixers.add(new InputMixerConfiguration(mixer, inputChannels));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return inputMixers;
|
||||
}
|
||||
|
||||
public InputMixerConfiguration getInputMixer(String name)
|
||||
public static InputMixerConfiguration getInputMixer(String name)
|
||||
{
|
||||
for(InputMixerConfiguration mixer : mInputMixers)
|
||||
for(InputMixerConfiguration mixer : getInputMixers())
|
||||
{
|
||||
if(mixer.getMixerName().contentEquals(name))
|
||||
{
|
||||
@@ -149,67 +159,50 @@ public class MixerManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public MixerChannelConfiguration[] getOutputMixers()
|
||||
public static MixerChannelConfiguration getDefaultOutputMixer()
|
||||
{
|
||||
return mOutputMixers.toArray(new MixerChannelConfiguration[mOutputMixers.size()]);
|
||||
List<MixerChannelConfiguration> outputMixers = getOutputMixers();
|
||||
|
||||
if(outputMixers.size() >= 1)
|
||||
{
|
||||
return outputMixers.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<MixerTunerDataLine> getMixerTunerDataLines()
|
||||
public static List<MixerChannelConfiguration> getOutputMixers()
|
||||
{
|
||||
if(mMixerTuners.isEmpty())
|
||||
List<MixerChannelConfiguration> outputMixers = new ArrayList<>();
|
||||
|
||||
for(Mixer.Info mixerInfo : AudioSystem.getMixerInfo())
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return mMixerTuners.values();
|
||||
Mixer mixer = AudioSystem.getMixer(mixerInfo);
|
||||
|
||||
if(mixer != null)
|
||||
{
|
||||
List<MixerChannel> outputChannels = getSupportedSourceChannels(mixer);
|
||||
|
||||
for(MixerChannel channel : outputChannels)
|
||||
{
|
||||
outputMixers.add(new MixerChannelConfiguration(mixer, channel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return outputMixers;
|
||||
}
|
||||
|
||||
private void loadMixers()
|
||||
public static Collection<MixerTunerDataLine> getMixerTunerDataLines()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("loading system mixer devices\n");
|
||||
List<MixerTunerDataLine> tuners = new ArrayList<>();
|
||||
|
||||
for(Mixer.Info mixerInfo : AudioSystem.getMixerInfo())
|
||||
{
|
||||
//Sort between the mixers and the tuner mixers, and load each
|
||||
MixerTunerType mixerTunerType = MixerTunerType.getMixerTunerType(mixerInfo);
|
||||
|
||||
if(mixerTunerType == MixerTunerType.UNKNOWN)
|
||||
{
|
||||
Mixer mixer = AudioSystem.getMixer(mixerInfo);
|
||||
|
||||
if(mixer != null)
|
||||
{
|
||||
EnumSet<MixerChannel> inputChannels = getSupportedTargetChannels(mixer);
|
||||
|
||||
if(inputChannels != null)
|
||||
{
|
||||
mInputMixers.add(new InputMixerConfiguration(mixer, inputChannels));
|
||||
|
||||
sb.append("\t[LOADED] Input: " + mixerInfo.getName() + " CHANNELS: " + inputChannels + "\n");
|
||||
}
|
||||
|
||||
EnumSet<MixerChannel> outputChannels = getSupportedSourceChannels(mixer);
|
||||
|
||||
if(outputChannels != null)
|
||||
{
|
||||
for(MixerChannel channel : outputChannels)
|
||||
{
|
||||
mOutputMixers.add(new MixerChannelConfiguration(mixer, channel));
|
||||
}
|
||||
|
||||
sb.append("\t[LOADED] Output: " + mixerInfo.getName() + " CHANNELS: " + outputChannels + "\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("\t[NOT LOADED] Mixer:" + mixerInfo.getName() + " - couldn't get mixer\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
if(mixerTunerType != MixerTunerType.UNKNOWN)
|
||||
{
|
||||
TargetDataLine tdl = getTargetDataLine(mixerInfo, mixerTunerType.getAudioFormat());
|
||||
|
||||
@@ -219,28 +212,17 @@ public class MixerManager
|
||||
{
|
||||
case FUNCUBE_DONGLE_PRO:
|
||||
case FUNCUBE_DONGLE_PRO_PLUS:
|
||||
mMixerTuners.put(mixerInfo.getName(),
|
||||
new MixerTunerDataLine(tdl, mixerTunerType));
|
||||
sb.append("\t[LOADED] FunCube Dongle Mixer Tuner:" + mixerInfo.getName() + "[" + mixerTunerType.getDisplayString() + "]\n");
|
||||
break;
|
||||
case UNKNOWN:
|
||||
default:
|
||||
sb.append("\t[NOT LOADED] Tuner:" + mixerInfo.getName() + " - unrecognized tuner type\n");
|
||||
tuners.add(new MixerTunerDataLine(tdl, mixerTunerType));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mLog.info(sb.toString());
|
||||
return tuners;
|
||||
}
|
||||
|
||||
public Map<String,MixerTunerDataLine> getMixerTuners()
|
||||
{
|
||||
return mMixerTuners;
|
||||
}
|
||||
|
||||
private TargetDataLine getTargetDataLine(Mixer.Info mixerInfo, AudioFormat format)
|
||||
private static TargetDataLine getTargetDataLine(Mixer.Info mixerInfo, AudioFormat format)
|
||||
{
|
||||
TargetDataLine retVal = null;
|
||||
|
||||
@@ -263,7 +245,7 @@ public class MixerManager
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private EnumSet<MixerChannel> getSupportedTargetChannels(Mixer mixer)
|
||||
private static EnumSet<MixerChannel> getSupportedTargetChannels(Mixer mixer)
|
||||
{
|
||||
DataLine.Info stereoInfo = new DataLine.Info(TargetDataLine.class,
|
||||
AudioFormats.PCM_SIGNED_8KHZ_16BITS_STEREO);
|
||||
@@ -296,8 +278,10 @@ public class MixerManager
|
||||
* (MONO and/or STEREO) supported by the mixer, or null if the mixer doesn't
|
||||
* have any source data lines.
|
||||
*/
|
||||
private EnumSet<MixerChannel> getSupportedSourceChannels(Mixer mixer)
|
||||
private static List<MixerChannel> getSupportedSourceChannels(Mixer mixer)
|
||||
{
|
||||
List<MixerChannel> channels = new ArrayList<>();
|
||||
|
||||
DataLine.Info stereoInfo = new DataLine.Info(SourceDataLine.class,
|
||||
AudioFormats.PCM_SIGNED_8KHZ_16BITS_STEREO);
|
||||
|
||||
@@ -307,20 +291,17 @@ public class MixerManager
|
||||
|
||||
boolean monoSupported = mixer.isLineSupported(monoInfo);
|
||||
|
||||
if(stereoSupported && monoSupported)
|
||||
if(stereoSupported)
|
||||
{
|
||||
return EnumSet.of(MixerChannel.MONO, MixerChannel.STEREO);
|
||||
}
|
||||
else if(stereoSupported)
|
||||
{
|
||||
return EnumSet.of(MixerChannel.STEREO);
|
||||
}
|
||||
else if(monoSupported)
|
||||
{
|
||||
return EnumSet.of(MixerChannel.MONO);
|
||||
channels.add(MixerChannel.STEREO);
|
||||
}
|
||||
|
||||
return null;
|
||||
if(monoSupported)
|
||||
{
|
||||
channels.add(MixerChannel.MONO);
|
||||
}
|
||||
|
||||
return channels;
|
||||
}
|
||||
|
||||
public static String getMixerDevices()
|
||||
@@ -369,7 +350,7 @@ public class MixerManager
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public class InputMixerConfiguration
|
||||
public static class InputMixerConfiguration
|
||||
{
|
||||
private Mixer mMixer;
|
||||
private EnumSet<MixerChannel> mChannels;
|
||||
@@ -405,4 +386,12 @@ public class MixerManager
|
||||
return mMixer.getMixerInfo().getName();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
for(MixerChannelConfiguration config : getOutputMixers())
|
||||
{
|
||||
mLog.debug(config.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
@@ -24,7 +24,9 @@ import io.github.dsheirer.source.config.SourceConfigMixer;
|
||||
import io.github.dsheirer.source.config.SourceConfiguration;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.EnumSet;
|
||||
@@ -33,140 +35,141 @@ public class MixerSourceEditor extends Editor<Channel>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JComboBox<MixerManager.InputMixerConfiguration> mComboMixers;
|
||||
private JComboBox<MixerChannel>mComboChannels;
|
||||
|
||||
private JComboBox<MixerChannel> mComboChannels;
|
||||
|
||||
private SourceManager mSourceManager;
|
||||
|
||||
public MixerSourceEditor( SourceManager sourceManager )
|
||||
{
|
||||
mSourceManager = sourceManager;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 0 0 0 0,wrap 4", "[right][grow,fill][right][grow,fill]", "" ) );
|
||||
public MixerSourceEditor(SourceManager sourceManager)
|
||||
{
|
||||
mSourceManager = sourceManager;
|
||||
init();
|
||||
}
|
||||
|
||||
mComboMixers = new JComboBox<MixerManager.InputMixerConfiguration>();
|
||||
MixerManager.InputMixerConfiguration[] inputMixers = mSourceManager.getMixerManager().getInputMixers();
|
||||
mComboMixers.setModel( new DefaultComboBoxModel<MixerManager.InputMixerConfiguration>( inputMixers ) );
|
||||
mComboMixers.setEnabled( false );
|
||||
mComboMixers.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
MixerManager.InputMixerConfiguration selected = (MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
|
||||
|
||||
repaint();
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("insets 0 0 0 0,wrap 4", "[right][grow,fill][right][grow,fill]", ""));
|
||||
|
||||
add( new JLabel( "Mixer:" ) );
|
||||
add( mComboMixers );
|
||||
mComboMixers = new JComboBox<MixerManager.InputMixerConfiguration>();
|
||||
DefaultComboBoxModel<MixerManager.InputMixerConfiguration> model = new DefaultComboBoxModel<>();
|
||||
model.addAll(MixerManager.getInputMixers());
|
||||
mComboMixers.setModel(model);
|
||||
mComboMixers.setEnabled(false);
|
||||
mComboMixers.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
MixerManager.InputMixerConfiguration selected = (MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
|
||||
mComboChannels = new JComboBox<MixerChannel>();
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
MixerManager.InputMixerConfiguration selected = (MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
mComboChannels.setModel(new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray(new MixerChannel[channels.size()])));
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
mComboChannels.setModel( new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray( new MixerChannel[ channels.size() ] ) ) );
|
||||
}
|
||||
|
||||
mComboChannels.setEnabled( false );
|
||||
mComboChannels.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
repaint();
|
||||
|
||||
add( new JLabel( "Channel:" ) );
|
||||
add( mComboChannels );
|
||||
}
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void setItem( Channel item )
|
||||
{
|
||||
super.setItem( item );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mComboMixers.setEnabled( true );
|
||||
mComboChannels.setEnabled( true );
|
||||
|
||||
SourceConfiguration config = item.getSourceConfiguration();
|
||||
|
||||
if( config instanceof SourceConfigMixer)
|
||||
{
|
||||
SourceConfigMixer mixer = (SourceConfigMixer)config;
|
||||
add(new JLabel("Mixer:"));
|
||||
add(mComboMixers);
|
||||
|
||||
for( MixerManager.InputMixerConfiguration inputMixer: mSourceManager.getMixerManager().getInputMixers() )
|
||||
{
|
||||
if( inputMixer.getMixerName().equalsIgnoreCase( mixer.getMixer() ) )
|
||||
{
|
||||
mComboMixers.setSelectedItem( inputMixer );
|
||||
|
||||
for( MixerChannel channel: inputMixer.getChannels() )
|
||||
{
|
||||
if( channel.getLabel() != null && mixer.getChannel() != null )
|
||||
{
|
||||
if( channel.getLabel().equalsIgnoreCase( mixer.getChannel().getLabel() ) )
|
||||
{
|
||||
mComboChannels.setSelectedItem( channel );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mComboMixers.setEnabled( false );
|
||||
mComboChannels.setEnabled( false );
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
}
|
||||
mComboChannels = new JComboBox<MixerChannel>();
|
||||
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
SourceConfigMixer config = new SourceConfigMixer();
|
||||
|
||||
MixerManager.InputMixerConfiguration selected =
|
||||
(MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
config.setMixer( selected.getMixerName() );
|
||||
|
||||
MixerChannel channel = (MixerChannel)mComboChannels.getSelectedItem();
|
||||
config.setChannel( channel );
|
||||
|
||||
getItem().setSourceConfiguration( config );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
MixerManager.InputMixerConfiguration selected = (MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
|
||||
if(selected != null)
|
||||
{
|
||||
EnumSet<MixerChannel> channels = selected.getChannels();
|
||||
|
||||
mComboChannels.setModel(new DefaultComboBoxModel<MixerChannel>(
|
||||
channels.toArray(new MixerChannel[channels.size()])));
|
||||
}
|
||||
|
||||
mComboChannels.setEnabled(false);
|
||||
mComboChannels.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
|
||||
add(new JLabel("Channel:"));
|
||||
add(mComboChannels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(Channel item)
|
||||
{
|
||||
super.setItem(item);
|
||||
|
||||
if(hasItem())
|
||||
{
|
||||
mComboMixers.setEnabled(true);
|
||||
mComboChannels.setEnabled(true);
|
||||
|
||||
SourceConfiguration config = item.getSourceConfiguration();
|
||||
|
||||
if(config instanceof SourceConfigMixer)
|
||||
{
|
||||
SourceConfigMixer mixer = (SourceConfigMixer)config;
|
||||
|
||||
for(MixerManager.InputMixerConfiguration inputMixer : MixerManager.getInputMixers())
|
||||
{
|
||||
if(inputMixer.getMixerName().equalsIgnoreCase(mixer.getMixer()))
|
||||
{
|
||||
mComboMixers.setSelectedItem(inputMixer);
|
||||
|
||||
for(MixerChannel channel : inputMixer.getChannels())
|
||||
{
|
||||
if(channel.getLabel() != null && mixer.getChannel() != null)
|
||||
{
|
||||
if(channel.getLabel().equalsIgnoreCase(mixer.getChannel().getLabel()))
|
||||
{
|
||||
mComboChannels.setSelectedItem(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mComboMixers.setEnabled(false);
|
||||
mComboChannels.setEnabled(false);
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
if(hasItem() && isModified())
|
||||
{
|
||||
SourceConfigMixer config = new SourceConfigMixer();
|
||||
|
||||
MixerManager.InputMixerConfiguration selected =
|
||||
(MixerManager.InputMixerConfiguration)mComboMixers.getSelectedItem();
|
||||
config.setMixer(selected.getMixerName());
|
||||
|
||||
MixerChannel channel = (MixerChannel)mComboChannels.getSelectedItem();
|
||||
config.setChannel(channel);
|
||||
|
||||
getItem().setSourceConfiguration(config);
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user