mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Co-authored-by: Denny <denny@denny-desktop>
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 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.tuner;
|
||||
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
|
||||
public class MixerTunerDataLine
|
||||
{
|
||||
private TargetDataLine mTargetDataLine;
|
||||
protected MixerTunerType mMixerTunerType;
|
||||
|
||||
public MixerTunerDataLine( TargetDataLine line, MixerTunerType type )
|
||||
{
|
||||
mTargetDataLine = line;
|
||||
mMixerTunerType = type;
|
||||
}
|
||||
|
||||
public TargetDataLine getTargetDataLine()
|
||||
{
|
||||
return mTargetDataLine;
|
||||
}
|
||||
|
||||
public MixerTunerType getMixerTunerType()
|
||||
{
|
||||
return mMixerTunerType;
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,8 @@ import org.usb4java.DeviceDescriptor;
|
||||
import org.usb4java.DeviceList;
|
||||
import org.usb4java.LibUsb;
|
||||
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -285,13 +285,11 @@ public class TunerManager
|
||||
}
|
||||
}
|
||||
|
||||
private TunerInitStatus initTuner(Device device,
|
||||
DeviceDescriptor descriptor)
|
||||
private TunerInitStatus initTuner(Device device, DeviceDescriptor descriptor)
|
||||
{
|
||||
if(device != null && descriptor != null)
|
||||
{
|
||||
TunerClass tunerClass = TunerClass.valueOf(descriptor.idVendor(),
|
||||
descriptor.idProduct());
|
||||
TunerClass tunerClass = TunerClass.valueOf(descriptor.idVendor(), descriptor.idProduct());
|
||||
|
||||
switch(tunerClass)
|
||||
{
|
||||
@@ -358,8 +356,7 @@ public class TunerManager
|
||||
}
|
||||
}
|
||||
|
||||
private TunerInitStatus initAirspyTuner(Device device,
|
||||
DeviceDescriptor descriptor)
|
||||
private TunerInitStatus initAirspyTuner(Device device, DeviceDescriptor descriptor)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -381,35 +378,30 @@ public class TunerManager
|
||||
}
|
||||
|
||||
|
||||
private TunerInitStatus initEttusB100Tuner(Device device,
|
||||
DeviceDescriptor descriptor)
|
||||
private TunerInitStatus initEttusB100Tuner(Device device, DeviceDescriptor descriptor)
|
||||
{
|
||||
return new TunerInitStatus(null, "Ettus B100 tuner not currently "
|
||||
+ "supported");
|
||||
return new TunerInitStatus(null, "Ettus B100 tuner not currently supported");
|
||||
}
|
||||
|
||||
private TunerInitStatus initFuncubeProTuner(Device device, DeviceDescriptor descriptor)
|
||||
{
|
||||
String reason = "NOT LOADED";
|
||||
|
||||
MixerTunerDataLine dataline = getMixerTunerDataLine(TunerClass.FUNCUBE_DONGLE_PRO.getTunerType());
|
||||
TargetDataLine tdl = MixerManager.getTunerTargetDataLine(MixerTunerType.FUNCUBE_DONGLE_PRO);
|
||||
|
||||
if(dataline != null)
|
||||
if(tdl != null)
|
||||
{
|
||||
FCD1TunerController controller = new FCD1TunerController(dataline, device, descriptor);
|
||||
FCD1TunerController controller = new FCD1TunerController(tdl, device, descriptor);
|
||||
|
||||
try
|
||||
{
|
||||
controller.init();
|
||||
|
||||
FCDTuner tuner = new FCDTuner(controller, mUserPreferences);
|
||||
|
||||
return new TunerInitStatus(tuner, "LOADED");
|
||||
}
|
||||
catch(SourceException e)
|
||||
{
|
||||
mLog.error("couldn't load funcube dongle pro tuner", e);
|
||||
|
||||
reason = "error during initialization - " + e.getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
@@ -418,15 +410,14 @@ public class TunerManager
|
||||
reason = "couldn't find matching mixer dataline";
|
||||
}
|
||||
|
||||
return new TunerInitStatus(null, "Funcube Dongle Pro tuner not "
|
||||
+ "loaded - " + reason);
|
||||
return new TunerInitStatus(null, "Funcube Dongle Pro tuner not loaded - " + reason);
|
||||
}
|
||||
|
||||
private TunerInitStatus initFuncubeProPlusTuner(Device device, DeviceDescriptor descriptor)
|
||||
{
|
||||
String reason = "NOT LOADED";
|
||||
|
||||
MixerTunerDataLine dataline = getMixerTunerDataLine(TunerClass.FUNCUBE_DONGLE_PRO_PLUS.getTunerType());
|
||||
TargetDataLine dataline = MixerManager.getTunerTargetDataLine(MixerTunerType.FUNCUBE_DONGLE_PRO_PLUS);
|
||||
|
||||
if(dataline != null)
|
||||
{
|
||||
@@ -435,17 +426,13 @@ public class TunerManager
|
||||
try
|
||||
{
|
||||
controller.init();
|
||||
|
||||
FCDTuner tuner = new FCDTuner(controller, mUserPreferences);
|
||||
|
||||
return new TunerInitStatus(tuner, "LOADED");
|
||||
}
|
||||
catch(SourceException e)
|
||||
{
|
||||
mLog.error("couldn't load funcube dongle pro plus tuner", e);
|
||||
|
||||
reason = "error during initialization - " +
|
||||
e.getLocalizedMessage();
|
||||
reason = "error during initialization - " + e.getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -453,8 +440,7 @@ public class TunerManager
|
||||
reason = "couldn't find matching mixer dataline";
|
||||
}
|
||||
|
||||
return new TunerInitStatus(null, "Funcube Dongle Pro tuner not "
|
||||
+ "loaded - " + reason);
|
||||
return new TunerInitStatus(null, "Funcube Dongle Pro tuner not loaded - " + reason);
|
||||
}
|
||||
|
||||
private TunerInitStatus initHackRFTuner(Device device, DeviceDescriptor descriptor)
|
||||
@@ -473,14 +459,11 @@ public class TunerManager
|
||||
{
|
||||
mLog.error("couldn't construct HackRF controller/tuner", se);
|
||||
|
||||
return new TunerInitStatus(null,
|
||||
"error constructing HackRF tuner controller");
|
||||
return new TunerInitStatus(null, "error constructing HackRF tuner controller");
|
||||
}
|
||||
}
|
||||
|
||||
private TunerInitStatus initRTL2832Tuner(TunerClass tunerClass,
|
||||
Device device,
|
||||
DeviceDescriptor deviceDescriptor)
|
||||
private TunerInitStatus initRTL2832Tuner(TunerClass tunerClass, Device device, DeviceDescriptor deviceDescriptor)
|
||||
{
|
||||
String reason = "NOT LOADED";
|
||||
|
||||
@@ -540,8 +523,7 @@ public class TunerManager
|
||||
case RAFAELMICRO_R828D:
|
||||
case UNKNOWN:
|
||||
default:
|
||||
reason = "SDRTRunk doesn't currently support RTL2832 "
|
||||
+ "Dongle with [" + tunerType.toString() +
|
||||
reason = "SDRTRunk doesn't currently support RTL2832 Dongle with [" + tunerType.toString() +
|
||||
"] tuner for tuner class[" + tunerClass.toString() + "]";
|
||||
break;
|
||||
}
|
||||
@@ -549,32 +531,6 @@ public class TunerManager
|
||||
return new TunerInitStatus(null, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first tuner mixer dataline that corresponds to the tuner class.
|
||||
*
|
||||
* Note: this method is not currently able to align multiple tuner mixer
|
||||
* data lines of the same tuner type. If you have multiple Funcube Dongle
|
||||
* tuners of the same TYPE, there is no guarantee that you will get the
|
||||
* correct mixer.
|
||||
*
|
||||
* @param tunerClass
|
||||
* @return
|
||||
*/
|
||||
private MixerTunerDataLine getMixerTunerDataLine(TunerType tunerClass)
|
||||
{
|
||||
Collection<MixerTunerDataLine> datalines = MixerManager.getMixerTunerDataLines();
|
||||
|
||||
for(MixerTunerDataLine mixerTDL : datalines)
|
||||
{
|
||||
if(mixerTDL.getMixerTunerType().getTunerClass() == tunerClass)
|
||||
{
|
||||
return mixerTDL;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public class TunerInitStatus
|
||||
{
|
||||
private Tuner mTuner;
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.github.dsheirer.sample.adapter.ComplexShortAdapter;
|
||||
import io.github.dsheirer.sample.buffer.ReusableComplexBuffer;
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.mixer.ComplexMixer;
|
||||
import io.github.dsheirer.source.tuner.MixerTunerDataLine;
|
||||
import io.github.dsheirer.source.tuner.MixerTunerType;
|
||||
import io.github.dsheirer.source.tuner.TunerClass;
|
||||
import io.github.dsheirer.source.tuner.TunerController;
|
||||
import io.github.dsheirer.source.tuner.TunerType;
|
||||
@@ -36,7 +36,7 @@ import org.usb4java.DeviceHandle;
|
||||
import org.usb4java.LibUsb;
|
||||
import org.usb4java.LibUsbException;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
import javax.usb.UsbClaimException;
|
||||
import javax.usb.UsbException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -71,8 +71,8 @@ public abstract class FCDTunerController extends TunerController
|
||||
* @param minTunableFrequency
|
||||
* @param maxTunableFrequency
|
||||
*/
|
||||
public FCDTunerController(MixerTunerDataLine mixerTDL, Device device, DeviceDescriptor descriptor, String tunerName,
|
||||
int minTunableFrequency, int maxTunableFrequency, AudioFormat audioFormat)
|
||||
public FCDTunerController(MixerTunerType tunerType, TargetDataLine mixerTDL, Device device,
|
||||
DeviceDescriptor descriptor, int minTunableFrequency, int maxTunableFrequency)
|
||||
{
|
||||
super(minTunableFrequency, maxTunableFrequency, DC_SPIKE_AVOID_BUFFER, USABLE_BANDWIDTH_PERCENT);
|
||||
mDevice = device;
|
||||
@@ -80,17 +80,17 @@ public abstract class FCDTunerController extends TunerController
|
||||
|
||||
try
|
||||
{
|
||||
mFrequencyController.setSampleRate((int)audioFormat.getSampleRate());
|
||||
mFrequencyController.setSampleRate((int)tunerType.getAudioFormat().getSampleRate());
|
||||
}
|
||||
catch(SourceException se)
|
||||
{
|
||||
mLog.error("Error setting sample rate to [" + audioFormat.getSampleRate() + "]", se);
|
||||
mLog.error("Error setting sample rate to [" + tunerType.getAudioFormat().getSampleRate() + "]", se);
|
||||
}
|
||||
|
||||
mComplexMixer = new ComplexMixer( mixerTDL.getTargetDataLine(), audioFormat, tunerName,
|
||||
new ComplexShortAdapter(mixerTDL.getMixerTunerType().getDisplayString()));
|
||||
mComplexMixer = new ComplexMixer( mixerTDL, tunerType.getAudioFormat(), tunerType.getDisplayString(),
|
||||
new ComplexShortAdapter(tunerType.getDisplayString()));
|
||||
|
||||
mComplexMixer.setBufferSize(audioFormat.getFrameSize() * getBufferSampleCount());
|
||||
mComplexMixer.setBufferSize(tunerType.getAudioFormat().getFrameSize() * getBufferSampleCount());
|
||||
|
||||
mComplexMixer.setBufferListener(mReusableBufferBroadcaster);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package io.github.dsheirer.source.tuner.fcd.proV1;
|
||||
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.tuner.MixerTunerDataLine;
|
||||
import io.github.dsheirer.source.tuner.MixerTunerType;
|
||||
import io.github.dsheirer.source.tuner.TunerClass;
|
||||
import io.github.dsheirer.source.tuner.TunerType;
|
||||
@@ -30,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.usb4java.Device;
|
||||
import org.usb4java.DeviceDescriptor;
|
||||
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
import javax.usb.UsbClaimException;
|
||||
import javax.usb.UsbException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -53,10 +53,10 @@ public class FCD1TunerController extends FCDTunerController
|
||||
private FCD1TunerConfiguration mTunerConfiguration;
|
||||
private FCD1TunerEditor mEditor;
|
||||
|
||||
public FCD1TunerController(MixerTunerDataLine mixerTDL, Device device, DeviceDescriptor descriptor)
|
||||
public FCD1TunerController(TargetDataLine mixerTDL, Device device, DeviceDescriptor descriptor)
|
||||
{
|
||||
super(mixerTDL, device, descriptor, MixerTunerType.FUNCUBE_DONGLE_PRO.getDisplayString(), MINIMUM_TUNABLE_FREQUENCY,
|
||||
MAXIMUM_TUNABLE_FREQUENCY, MixerTunerType.FUNCUBE_DONGLE_PRO.getAudioFormat());
|
||||
super(MixerTunerType.FUNCUBE_DONGLE_PRO, mixerTDL, device, descriptor,
|
||||
MINIMUM_TUNABLE_FREQUENCY, MAXIMUM_TUNABLE_FREQUENCY);
|
||||
}
|
||||
|
||||
public void init() throws SourceException
|
||||
@@ -78,10 +78,7 @@ public class FCD1TunerController extends FCDTunerController
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
||||
throw new SourceException("FCDTunerController error " +
|
||||
"during construction", e);
|
||||
throw new SourceException("FCDTunerController error during construction", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package io.github.dsheirer.source.tuner.fcd.proplusV2;
|
||||
|
||||
import io.github.dsheirer.source.SourceException;
|
||||
import io.github.dsheirer.source.tuner.MixerTunerDataLine;
|
||||
import io.github.dsheirer.source.tuner.MixerTunerType;
|
||||
import io.github.dsheirer.source.tuner.TunerClass;
|
||||
import io.github.dsheirer.source.tuner.TunerType;
|
||||
@@ -31,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.usb4java.Device;
|
||||
import org.usb4java.DeviceDescriptor;
|
||||
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@@ -42,10 +42,10 @@ public class FCD2TunerController extends FCDTunerController
|
||||
public static final int MAXIMUM_TUNABLE_FREQUENCY = 2050000000;
|
||||
public static final int SAMPLE_RATE = 192000;
|
||||
|
||||
public FCD2TunerController(MixerTunerDataLine mixerTDL, Device device, DeviceDescriptor descriptor)
|
||||
public FCD2TunerController(TargetDataLine mixerTDL, Device device, DeviceDescriptor descriptor)
|
||||
{
|
||||
super(mixerTDL, device, descriptor, MixerTunerType.FUNCUBE_DONGLE_PRO_PLUS.getDisplayString(),
|
||||
MINIMUM_TUNABLE_FREQUENCY, MAXIMUM_TUNABLE_FREQUENCY, MixerTunerType.FUNCUBE_DONGLE_PRO_PLUS.getAudioFormat());
|
||||
super(MixerTunerType.FUNCUBE_DONGLE_PRO_PLUS, mixerTDL, device, descriptor,
|
||||
MINIMUM_TUNABLE_FREQUENCY, MAXIMUM_TUNABLE_FREQUENCY);
|
||||
}
|
||||
|
||||
public void init() throws SourceException
|
||||
|
||||
Reference in New Issue
Block a user