Files
sdrtrunk/src/main/java/io/github/dsheirer/sample/complex/ComplexSampleAssembler.java
Denny 9316599dec Updates pull request from Roman Tsypuk to convert the build system from
ant to gradle.  Removes linux and windows application launch scripts and
produces an executable jar with all resources included.
2017-12-17 07:28:06 -05:00

73 lines
1.9 KiB
Java

/*******************************************************************************
* 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.sample.complex;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.sample.Provider;
import java.util.ArrayList;
import java.util.List;
public class ComplexSampleAssembler implements Listener<Complex>,
Provider<List<Complex>>
{
private ArrayList<Complex> mBuffer;
private int mBufferSize;
private Listener<List<Complex>> mListener;
public ComplexSampleAssembler( int bufferSize )
{
mBufferSize = bufferSize;
mBuffer = new ArrayList<>();
}
public void dispose()
{
mBuffer.clear();
mListener = null;
}
@Override
public void receive( Complex sample )
{
mBuffer.add( sample );
if( mBuffer.size() >= mBufferSize )
{
if( mListener != null )
{
mListener.receive( mBuffer );
}
mBuffer = new ArrayList<>();
}
}
@Override
public void setListener( Listener<List<Complex>> listener )
{
mListener = listener;
}
@Override
public void removeListener( Listener<List<Complex>> listener )
{
mListener = null;
}
}