multi-arfcn, sigproc: set aligned memory allocation on 32-bit machines

Wel need 16-byte alingment for SSE aligned loads. GCC will guarantee
that on 64-bit architectures, but only 8-byte alignment on 32 machines.
In any case, use memalign to explicity request 16-byte alignment.

This primarily affects filter taps, which are assumed to be always
be read from index 0 of the allocated vector.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: consolidate radio parameters in a single header

Create a new compiled parameters file that combines configurable
radio preprocessor definitions. These include the number of
channels, channel bandwidth, samples-per-symbol and filter
settings.

We also need different Tx / Rx timeslot correction offsets for
each configuration, which are the effect of different sample rates
and group delay values. These offsets are measured empirically.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
transceiver: fix build warning due to NULL use

GCC complains when a NULL value is returned through
an 'int' interface. Use '0' instead so that gcc will
shutup.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: remove limitation on transceiver sample rate

There was a previous assumption that the transceiver would
operate at the GSM symbol rate and the channelizer would run
at a higher rate (generally 400 ksps). With two samples-per-
symbol in the transceiver, the channelizer needs to run at the
lower of the two rates. To handle both cases, we need to be
explicit when specifying filter and buffer construction in the
base class so that the lengths are setup correctly.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: match variable names to existing coding style

Convert to camel case and m/w prefixing where appropriate in the
main transceiver files. This matches what appears to existing
conventions throughtout the existing code base.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: fix macros that missed previous file renaming

Previous name changes were the following,

Downsampler -> Resampler
ChannelizerTx -> Synthesis

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
transceiver: fix calculation of training sequence correlation for 2 sps

The correlation starting point for normal burst training sequence
calculation should be a scaled value of the same symbol regardless
of the samples-per-symbol used. Use of 2 samples-per-symbol double
the index values, but yields the following outputs, which results
in a late time-of-arrival value at the output of the correlation.
Modifiy the parameter calculation according to match expected
input.

1 sps parameters

maxTOA = 3
spanTOA = 5;
startIx = 61;
endIx = 87;
windowLen = 26;
corrLen = 7;

2 sps parameters (errant case)

maxTOA = 6;
spanTOA = 10;
startIx = 112;
endIx = 184;
windowLen = 72;
corrLen =13;

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, core: channel configuration message is not an error

Output channel combination setup at NOTICE logging level.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, sigproc: initialize fft with a struct object

Don't use static variables because there may be instances
with different values. Channelizer and synthesis filter-
banks use the same values, so it currently makes no
difference, but that may change in the future.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: fix resampler release bug

We allocate 'P' partitions not 'Q'. This was causing
segfaults at transceiver shutdown.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
transceiver: define virtual destructor for base device

Lack of an explicitly defined virtual destructor was
causing the empty default interface destructor to be
called, which created a memory leak at shutdown.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: only deallocate radio resouces if started

Certain notable variables - sample buffers - are not
allocated until start(), which causes a segfault if the
transceiver is shutdown without the radio starting. Check
that the radio is 'started' before releasing in the
destructor.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: remove unused attach call()

At one point an attach() call was used to connect
multiple transceivers to the radio interface. The
current approach is to pass the radio interface to
the transceiver instances through the constructor.
Remove the unused and deprecated call.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: remove unused reset() call in drive loop

This call is a remnant of the Transceiver / DriveLoop split. The
empty call is never used.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: allocate threads on heap and fix thread release

The underlying pthread of the Thread object isn't created until
Thread::start(). If the Thread object is contructed, but not
started, then the destructor will fail with a variety of
unpredictable errors such as the following or double free() in
certain cases.

Program received signal SIGSEGV, Segmentation fault.
__GI___libc_free (mem=0x3811abed3e946178) at malloc.c:2972
2972      if (chunk_is_mmapped(p))

If the Thread object is stack allocated, but start() isn't called,
destructor is guaranteed to run and will fail. The previous
approach was to dynamically allocate threads, but not free them,
thus avoiding memory errors, but creating memory leaks.

To get around this limitation, dynamically allocate Thread objects
and initialize with NULL. Then allocate immediately prior to start
such that pthread allocation is tied to the Thread object
constructor. Deallocation can check that the Thread pointer is
valid through NULL or other tracking methods.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>
multi-arfcn, trx: handle thread exiting on shutdown

Previous approach was to allow stack unwinding to take care
shutdown and thread ending, which was unpredictable and
occasionally segfault. Attempt to shutdown more gracefully.

There are thread cancellation points in the transceiver code
using pthread_testcancel(), but the thread abstraction library
does not allow direct access to the pthread variables. This
prevents thread shutdown through pthread_cancel(). To get
around this, use boolean status values in the receive socket
service loops and main drive loop.

The socket read calls will block indefinitly, so shutdown
may cause the socket implementation to throw a SocketError
exception. Use of timeout values with reads does not seem to
work correctly or reliably, so catch the exception and ignore
if it occurs on shutdown.

The following error may appear as the socket is shutdown while
the Transceiver is blocking on read().

  DatagramSocket::read() failed: Bad file descriptor

So be it; the API doesn't allow us to do any more.

Signed-off-by: Thomas Tsou <ttsou@vt.edu>