mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 17:47:32 -05:00
Resolves issue with residual buffer decimation processing after dispose
is invoked on call teardown.
This commit is contained in:
@@ -264,6 +264,7 @@ public class TunerChannelSource extends ComplexSource
|
|||||||
public class DecimationProcessor implements Runnable
|
public class DecimationProcessor implements Runnable
|
||||||
{
|
{
|
||||||
private AtomicBoolean mDispose = new AtomicBoolean( false );
|
private AtomicBoolean mDispose = new AtomicBoolean( false );
|
||||||
|
private List<ComplexBuffer> mSampleBuffers = new ArrayList<ComplexBuffer>();
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
@@ -278,64 +279,64 @@ public class TunerChannelSource extends ComplexSource
|
|||||||
* run the program out of memory */
|
* run the program out of memory */
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
/* Check to see if we've been shutdown */
|
if( mBuffer != null )
|
||||||
if( mDispose.get() )
|
|
||||||
{
|
{
|
||||||
cleanup();
|
mBuffer.drainTo( mSampleBuffers, 4 );
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
List<ComplexBuffer> sampleBuffers =
|
|
||||||
new ArrayList<ComplexBuffer>();
|
|
||||||
|
|
||||||
if( mBuffer != null )
|
for( Buffer buffer: mSampleBuffers )
|
||||||
{
|
{
|
||||||
mBuffer.drainTo( sampleBuffers, 4 );
|
/* Check to see if we've been shutdown */
|
||||||
|
if( mDispose.get() )
|
||||||
for( Buffer buffer: sampleBuffers )
|
|
||||||
{
|
{
|
||||||
/* Check to see if we've been shutdown */
|
cleanup();
|
||||||
if( mDispose.get() )
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float[] samples = buffer.getSamples();
|
||||||
|
|
||||||
|
/* We make a copy of the buffer so that we don't affect
|
||||||
|
* anyone else that is using the same buffer, like other
|
||||||
|
* channels or the spectral display */
|
||||||
|
float[] translated = new float[ samples.length ];
|
||||||
|
|
||||||
|
/* Perform frequency translation */
|
||||||
|
for( int x = 0; x < samples.length; x += 2 )
|
||||||
{
|
{
|
||||||
cleanup();
|
mMixer.rotate();
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float[] samples = buffer.getSamples();
|
|
||||||
|
|
||||||
/* We make a copy of the buffer so that we don't affect
|
translated[ x ] = Complex.multiplyInphase(
|
||||||
* anyone else that is using the same buffer, like other
|
samples[ x ], samples[ x + 1 ], mMixer.inphase(), mMixer.quadrature() );
|
||||||
* channels or the spectral display */
|
|
||||||
float[] translated = new float[ samples.length ];
|
|
||||||
|
|
||||||
/* Perform frequency translation */
|
translated[ x + 1 ] = Complex.multiplyQuadrature(
|
||||||
for( int x = 0; x < samples.length; x += 2 )
|
|
||||||
{
|
|
||||||
mMixer.rotate();
|
|
||||||
|
|
||||||
translated[ x ] = Complex.multiplyInphase(
|
|
||||||
samples[ x ], samples[ x + 1 ], mMixer.inphase(), mMixer.quadrature() );
|
samples[ x ], samples[ x + 1 ], mMixer.inphase(), mMixer.quadrature() );
|
||||||
|
}
|
||||||
|
|
||||||
translated[ x + 1 ] = Complex.multiplyQuadrature(
|
if( mDecimationFilter != null )
|
||||||
samples[ x ], samples[ x + 1 ], mMixer.inphase(), mMixer.quadrature() );
|
{
|
||||||
}
|
mDecimationFilter.receive( new ComplexBuffer( translated ) );
|
||||||
|
|
||||||
if( mDecimationFilter != null )
|
|
||||||
{
|
|
||||||
mDecimationFilter.receive( new ComplexBuffer( translated ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleBuffers.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mSampleBuffers.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
mLog.error( "encountered an error during decimation process", e );
|
/* Only log the stack trace if we've haven't been shutdown and
|
||||||
|
* this is a true error */
|
||||||
|
if( !mDispose.get() )
|
||||||
|
{
|
||||||
|
mLog.error( "Error encountered during decimation process", e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check to see if we've been shutdown */
|
||||||
|
if( mDispose.get() )
|
||||||
|
{
|
||||||
|
mSampleBuffers.clear();
|
||||||
|
cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user