mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
#1353 Resolves issue where polyphase channelizer would mis-tune channels after a period of time resulting in idle decoding channels. (#1354)
Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 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.sample.complex;
|
||||
|
||||
import io.github.dsheirer.buffer.INativeBuffer;
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.sample.Broadcaster;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Module that receives and rebroadcasts complex samples.
|
||||
*/
|
||||
public class ComplexSampleListenerModule extends Module implements IComplexSamplesListener, Listener<ComplexSamples>
|
||||
{
|
||||
private static final Logger mLog = LoggerFactory.getLogger(ComplexSampleListenerModule.class);
|
||||
private Broadcaster<INativeBuffer> mBroadcaster = new Broadcaster<>();
|
||||
|
||||
/**
|
||||
* Implements the interface
|
||||
* @return this.
|
||||
*/
|
||||
@Override
|
||||
public Listener<ComplexSamples> getComplexSamplesListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Primary receive method for sample buffers to rebroadcast.
|
||||
* @param complexSamples to rebroadcast
|
||||
*/
|
||||
@Override
|
||||
public void receive(ComplexSamples complexSamples)
|
||||
{
|
||||
mBroadcaster.broadcast(new ComplexSamplesNativeBufferAdapter(complexSamples));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds listener to receive rebroadcast of complex samples buffer.
|
||||
* @param listener to add
|
||||
*/
|
||||
public void addListener(Listener<INativeBuffer> listener)
|
||||
{
|
||||
mBroadcaster.addListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the listener from receiving rebroadcast of complex samples.
|
||||
* @param listener to remove
|
||||
*/
|
||||
public void removeListener(Listener<INativeBuffer> listener)
|
||||
{
|
||||
mBroadcaster.removeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
//Not implemented
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
//Not implemented
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
//Not implemented
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* *****************************************************************************
|
||||
* Copyright (C) 2014-2022 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.sample.complex;
|
||||
|
||||
import io.github.dsheirer.buffer.INativeBuffer;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Adapts a single complex samples buffer to be compatible as an INativeBuffer instance.
|
||||
*/
|
||||
public class ComplexSamplesNativeBufferAdapter implements INativeBuffer
|
||||
{
|
||||
private ComplexSamples mComplexSamples;
|
||||
private long mTimestamp = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
* Constructs an instance
|
||||
* @param complexSamples to adapt/convert to an INativeBuffer
|
||||
*/
|
||||
public ComplexSamplesNativeBufferAdapter(ComplexSamples complexSamples)
|
||||
{
|
||||
mComplexSamples = complexSamples;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ComplexSamples> iterator()
|
||||
{
|
||||
return new ComplexSamplesIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<InterleavedComplexSamples> iteratorInterleaved()
|
||||
{
|
||||
return new InterleavedComplexSamplesIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sampleCount()
|
||||
{
|
||||
return mComplexSamples.i().length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp()
|
||||
{
|
||||
return mTimestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple iterator implementation.
|
||||
*/
|
||||
public class ComplexSamplesIterator implements Iterator<ComplexSamples>
|
||||
{
|
||||
public boolean mHasNext = true;
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return mHasNext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComplexSamples next()
|
||||
{
|
||||
mHasNext = false;
|
||||
return mComplexSamples;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple iterator implementation.
|
||||
*/
|
||||
public class InterleavedComplexSamplesIterator implements Iterator<InterleavedComplexSamples>
|
||||
{
|
||||
public boolean mHasNext = true;
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return mHasNext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterleavedComplexSamples next()
|
||||
{
|
||||
mHasNext = false;
|
||||
return mComplexSamples.toInterleaved();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user