1
0
mirror of https://github.com/JvanKatwijk/dab-cmdline synced 2025-10-05 23:52:50 +02:00

keyboard listener added to example-5

This commit is contained in:
JvanKatwijk
2017-11-10 16:26:57 +01:00
parent 567fb5cd6d
commit 934305407d
42 changed files with 4364 additions and 5 deletions

View File

@@ -14,8 +14,8 @@ The library interface is given in dab-api.h
To show the use of the library, several example programs are included:
- The example programs example-1, example-2, example-3 and example-4
are regular C (C++) programs.
- The example programs example-1, example-2, example-3, example-4
and example-5 are regular C (C++) programs.
- simpleDab is a Qt based GUI program, linking to the library.
It shows the use of the library when handled from with a Qt GUI.
@@ -30,14 +30,17 @@ To show the use of the library, several example programs are included:
The C (C++) example programs
------------------------------------------------------------------------
As said, there are 4 versions of an example dab command line program,
As said, there are 5 versions of an example dab command line program,
they are written in C, communicate with the library functions through callbacks.
The programs are all more or less the same, with some differences in
the functionality provided.
For each of the programs, a CMakeLists.txt file exists with which a
Makefile can be generated using Cmake.
The standard way to create an executable is
cd example-X (replace X by the appropriate digit)
mkdir build
cd build
cmake .. -DXXX=ON
@@ -90,6 +93,11 @@ The example programs are different though:
or the AAC frames (in case of DAB+) are just emitted through stdout.
(Note that the AAC frames have 960 rather than 1024 samples)
- example 5 is a small experimental extension to example 2,
It contains a simple "keyboard listener", that will react
on entering a stroke on the return key. It will cause the
"next" (audio) service to be selected.
=======================================================================
A note on the callback functions

View File

@@ -188,7 +188,7 @@ int16_t dabService (std::string, void *);
// mapping from a name to a Service identifier is done
int32_t dab_getSId (std::string, void *);
//
// and the other wway around, mapping the service identifier to a name
// and the other way around, mapping the service identifier to a name
std::string dab_getserviceName (int32_t, void *);
}

362
example-5/CMakeLists.txt Normal file
View File

@@ -0,0 +1,362 @@
cmake_minimum_required( VERSION 2.8.11 )
set (objectName dab_cmdline-5)
set (CMAKE_CXX_FLAGS "${CMAKE_XCC_FLAGS} -Wall -std=c++11 -flto")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "/usr/local/bin" CACHE PATH "default install path" FORCE )
endif()
#set (CMAKE_INSTALL_PREFIX /usr/local/bin)
if(MINGW)
add_definitions ( -municode)
endif()
########################################################################
# select the release build type by default to get optimization flags
########################################################################
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
### make sure our local CMake Modules path comes first
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
######################################################################
#
########################################################################
if(DEFINED AIRSPY)
set(AIRSPY true)
set(objectName dab-airspy-5)
endif ()
if(DEFINED SDRPLAY)
set(SDRPLAY true)
set(objectName dab-sdrplay-5)
endif ()
if(DEFINED RTLSDR)
set(RTLSDR true)
set(objectName dab-rtlsdr-5)
endif ()
if(DEFINED WAVFILES)
set(WAVFILES true)
set(objectName dab-files-5)
endif ()
if(DEFINED RTL_TCP)
set(RTL_TCP true)
set(objectName dab-rtl_tcp-5)
endif ()
if (DEFINED_SERVER)
add_definitions(-DHAVE_SERVER)
endif ()
#########################################################################
find_package (PkgConfig)
find_package(FFTW3f)
if (NOT FFTW3F_FOUND)
message(FATAL_ERROR "please install FFTW3")
endif ()
find_package(Faad)
if (NOT FAAD_FOUND )
message(FATAL_ERROR "please install libfaad")
endif ()
find_package(zlib)
if (NOT ZLIB_FOUND)
message(FATAL_ERROR "please install libz")
endif ()
list(APPEND extraLibs ${ZLIB_LIBRARY})
find_library (PTHREADS pthread)
if (NOT(PTHREADS))
message (FATAL_ERROR "please install libpthread")
else (NOT(PTHREADS))
set (extraLibs ${extraLibs} ${PTHREADS})
endif (NOT(PTHREADS))
find_package(LibSampleRate)
if (NOT LIBSAMPLERATE_FOUND)
message(FATAL_ERROR "please install libsamplerate")
endif ()
list(APPEND extraLibs ${LIBSAMPLERATE_LIBRARY})
find_package(Portaudio)
if (NOT PORTAUDIO_FOUND)
message(FATAL_ERROR "please install portaudio V19")
endif ()
list(APPEND extraLibs ${PORTAUDIO_LIBRARIES})
#########################################################################
find_package (PkgConfig)
##########################################################################
# The devices
#
if (RTL_TCP)
include_directories (
../devices/rtl_tcp
)
set ($(objectName)_HDRS
${${objectName}_HDRS}
../devices/rtl_tcp/rtl_tcp-client.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
../devices/rtl_tcp/rtl_tcp-client.cpp
)
add_definitions (-DHAVE_RTL_TCP)
endif (RTL_TCP)
if (SDRPLAY)
find_path (SDRPLAYLIB_INCLUDE_DIR
NAMES mirsdrapi-rsp.h
PATHS
/usr/local/include/
)
include_directories (${SDRPLAYLIB_INCLUDE_DIR})
include_directories (
../devices/sdrplay-handler
)
set ($(objectName)_HDRS
${${objectName}_HDRS}
../devices/sdrplay-handler/sdrplay-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
../devices/sdrplay-handler/sdrplay-handler.cpp
)
add_definitions (-DHAVE_SDRPLAY)
endif (SDRPLAY)
if (AIRSPY)
find_package(LibAIRSPY)
if (NOT LIBAIRSPY_FOUND)
message(FATAL_ERROR "please install airspy library")
endif ()
### include_directories (${AIRSPYLIB_INCLUDE_DIR})
include_directories (
../devices/airspy-handler
)
set ($(objectName)_HDRS
${${objectName}_HDRS}
../devices/airspy-handler/airspy-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
../devices/airspy-handler/airspy-handler.cpp
)
add_definitions (-DHAVE_AIRSPY)
endif (AIRSPY)
if (RTLSDR)
find_package(LibRTLSDR)
if (NOT LIBRTLSDR_FOUND)
message(FATAL_ERROR "please install librtlsdr")
endif ()
###include_directories (${RTLSDR_INCLUDE_DIR})
include_directories (
../devices/rtlsdr-handler/
)
set (${objectName}_HDRS
${${objectName}_HDRS}
../devices/rtlsdr-handler/rtlsdr-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
../devices/rtlsdr-handler/rtlsdr-handler.cpp
)
add_definitions (-DHAVE_RTLSDR)
endif()
if (WAVFILES)
include_directories (
../devices/wavfiles/
)
set (${objectName}_HDRS
${${objectName}_HDRS}
../devices/wavfiles/wavfiles.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
../devices/wavfiles/wavfiles.cpp
)
find_package(LibSndFile)
if (NOT LIBSNDFILE_FOUND)
message(FATAL_ERROR "please install libsndfile")
endif ()
list(APPEND extraLibs ${LIBSNDFILE_LIBRARY})
add_definitions (-DHAVE_WAVFILES)
endif()
#######################################################################
#
# Here we really start
include_directories (
${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
.
./
./server-thread
../
../library
../library/includes
../library/includes/ofdm
../library/includes/backend
../library/includes/backend/viterbi_768
../library/includes/backend/audio
../library/includes/backend/data
../library/includes/backend/data/journaline
../library/includes/various
/usr/include/
)
set (${objectName}_HDRS
${${objectName}_HDRS}
./ringbuffer.h
./band-handler.h
./audio-base.h
./audiosink.h
./filesink.h
./newconverter.h
./server-thread/tcp-server.h
../devices/device-handler.h
../library/includes/dab-class.h
../library/includes/dab-constants.h
../library/includes/ofdm/ofdm-processor.h
../library/includes/ofdm/phasereference.h
../library/includes/ofdm/phasetable.h
../library/includes/ofdm/freq-interleaver.h
../library/includes/backend/viterbi_768/viterbi-768.h
../library/includes/backend/protection.h
../library/includes/backend/uep-protection.h
../library/includes/backend/eep-protection.h
../library/includes/backend/firecode-checker.h
../library/includes/backend/dab-processor.h
../library/includes/backend/dab-virtual.h
../library/includes/backend/charsets.h
../library/includes/backend/galois.h
../library/includes/backend/msc-handler.h
../library/includes/backend/reed-solomon.h
../library/includes/backend/audio/dab-audio.h
../library/includes/backend/audio/faad-decoder.h
../library/includes/backend/audio/mp4processor.h
../library/includes/backend/audio/mp2processor.h
../library/includes/backend/data/mot-databuilder.h
../library/includes/backend/data/virtual-datahandler.h
../library/includes/backend/data/tdc-datahandler.h
../library/includes/backend/data/pad-handler.h
../library/includes/backend/data/mot-data.h
../library/includes/backend/data/dab-data.h
../library/includes/backend/data/data-processor.h
../library/includes/various/fft.h
../library/includes/various/dab-params.h
../library/includes/various/tii_table.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
./main.cpp
./audio-base.cpp
./audiosink.cpp
./filesink.cpp
./newconverter.cpp
./band-handler.cpp
./server-thread/tcp-server.cpp
../devices/device-handler.cpp
../library/src/dab-class.cpp
../library/src/ofdm/ofdm-processor.cpp
../library/src/ofdm/ofdm-decoder.cpp
../library/src/ofdm/phasereference.cpp
../library/src/ofdm/phasetable.cpp
../library/src/ofdm/freq-interleaver.cpp
../library/src/backend/viterbi_768/viterbi-768.cpp
../library/src/backend/viterbi_768/spiral-no-sse.c
../library/src/backend/fic-handler.cpp
../library/src/backend/msc-handler.cpp
../library/src/backend/protection.cpp
../library/src/backend/eep-protection.cpp
../library/src/backend/uep-protection.cpp
../library/src/backend/fib-processor.cpp
../library/src/backend/firecode-checker.cpp
../library/src/backend/dab-virtual.cpp
../library/src/backend/dab-processor.cpp
../library/src/backend/protTables.cpp
../library/src/backend/charsets.cpp
../library/src/backend/galois.cpp
../library/src/backend/reed-solomon.cpp
../library/src/backend/audio/dab-audio.cpp
../library/src/backend/audio/mp4processor.cpp
../library/src/backend/audio/mp2processor.cpp
../library/src/backend/data/mot-databuilder.cpp
../library/src/backend/data/virtual-datahandler.cpp
../library/src/backend/data/tdc-datahandler.cpp
../library/src/backend/data/pad-handler.cpp
../library/src/backend/data/mot-data.cpp
../library/src/backend/data/dab-data.cpp
../library/src/backend/data/data-processor.cpp
../library/src/various/fft.cpp
../library/src/various/dab-params.cpp
../library/src/various/tii_table.cpp
)
#
include_directories (
${FFTW_INCLUDE_DIRS}
${PORTAUDIO_INCLUDE_DIRS}
${FAAD_INCLUDE_DIRS}
${SNDFILES_INCLUDE_DIRS}
)
#####################################################################
add_executable (${objectName}
${${objectName}_SRCS}
)
target_link_libraries (${objectName}
${FFTW3F_LIBRARIES}
${extraLibs}
${FAAD_LIBRARIES}
${CMAKE_DL_LIBS}
)
INSTALL (TARGETS ${objectName} DESTINATION .)
########################################################################
# Create uninstall target
########################################################################
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

41
example-5/README Normal file
View File

@@ -0,0 +1,41 @@
Example 5
Example 5 is a simple command line version of the DAB software. The
input device is fixed, depending on a setting in the CMakeLists.txt
file. The output is either to the soundcard (default) or to a file
(-O option).
It is an experimental extension of example. In example 5 a
small keyboard listener is added such that touching the "return" key will select
the "next" program (it will skip data services). All other keys are ignored.
Other than example 1, it binds directly to the functionality implementing
the DAB decoding.
All callbacks are defined, most of them with an empty body.
See the file main.cpp for the command line options
FEEL FREE TO IMPROVE THE PROGRAM
Points to note:
bytesOut is a new callback function, a function that is called
from the tdc handler (and later may be from others as well)
The data parameter is a packet with a 4 byte header
byte 0 is 0xFF
byte 1 is 0x00
byte 2 is 0xFF
byte 3 is 0x00
byte 4 is the high byte of the 16 bit size
byte 5 is the low byte of the 16 bit size
byte 6 is 0x00
byte 7 is 0 for packet type 0, 0xFF for packet type 1
Note that the lenngth is the length of the data part, so not taking the
header into account
The bytesOut function puts the data into a simple TCP server that can be
read from port 8888 (depending on the configuration).

150
example-5/audio-base.cpp Normal file
View File

@@ -0,0 +1,150 @@
#
/*
* Copyright (C) 2011, 2012, 2013
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the main program for the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "audio-base.h"
#include <stdio.h>
/*
* The class is the abstract sink for the data generated
* It will handle the "dumping" though
*/
audioBase::audioBase (void):
converter_16 (16000, 48000, 2 * 1600),
converter_24 (24000, 48000, 2 * 2400),
converter_32 (32000, 48000, 4 * 3200) {
}
audioBase::~audioBase (void) {
}
void audioBase::restart (void) {
}
void audioBase::stop (void) {
}
//
// This one is a hack for handling different baudrates coming from
// the aac decoder. call is from the GUI, triggered by the
// aac decoder or the mp2 decoder
void audioBase::audioOut (int16_t *buffer,
int32_t amount, int32_t rate) {
switch (rate) {
case 16000:
audioOut_16000 (buffer, amount / 2);
return;
case 24000:
audioOut_24000 (buffer, amount / 2);
return;
case 32000:
audioOut_32000 (buffer, amount / 2);
return;
default:
case 48000:
audioOut_48000 (buffer, amount / 2);
return;
}
}
//
// scale up from 16 -> 48
// amount gives number of pairs
void audioBase::audioOut_16000 (int16_t *V, int32_t amount) {
DSPCOMPLEX outputBuffer [converter_16. getOutputsize ()];
float buffer [2 * converter_16. getOutputsize ()];
int16_t i;
int32_t result;
for (i = 0; i < amount; i ++)
if (converter_16. convert (DSPCOMPLEX (V [2 * i] / 32767.0,
V [2 * i + 1] / 32767.0),
outputBuffer, &result)) {
for (i = 0; i < result; i ++) {
buffer [2 * i ] = real (outputBuffer [i]);
buffer [2 * i + 1] = imag (outputBuffer [i]);
}
audioOutput (buffer, result);
}
}
// scale up from 24000 -> 48000
// amount gives number of pairs
void audioBase::audioOut_24000 (int16_t *V, int32_t amount) {
DSPCOMPLEX outputBuffer [converter_24. getOutputsize ()];
float buffer [2 * converter_24. getOutputsize ()];
int16_t i;
int32_t result;
for (i = 0; i < amount; i ++)
if (converter_24. convert (DSPCOMPLEX (V [2 * i] / 32767.0,
V [2 * i + 1] / 32767.0),
outputBuffer, &result)) {
for (i = 0; i < result; i ++) {
buffer [2 * i ] = real (outputBuffer [i]);
buffer [2 * i + 1] = imag (outputBuffer [i]);
}
audioOutput (buffer, result);
}
}
//
// scale up from 32000 -> 48000
// amount is number of pairs
void audioBase::audioOut_32000 (int16_t *V, int32_t amount) {
DSPCOMPLEX outputBuffer [converter_32. getOutputsize ()];
float buffer [2 * converter_32. getOutputsize ()];
int32_t i;
int32_t result;
for (i = 0; i < amount; i ++) {
if (converter_32. convert (DSPCOMPLEX (V [2 * i] / 32767.0,
V [2 * i + 1] / 32767.0),
outputBuffer, &result)) {
for (i = 0; i < result; i ++) {
buffer [2 * i ] = real (outputBuffer [i]);
buffer [2 * i + 1] = imag (outputBuffer [i]);
}
audioOutput (buffer, result);
}
}
}
void audioBase::audioOut_48000 (int16_t *V, int32_t amount) {
float *buffer = (float *)alloca (2 * amount * sizeof (float));
int32_t i;
for (i = 0; i < amount; i ++) {
buffer [2 * i] = V [2 * i] / 32767.0;
buffer [2 * i + 1] = V [2 * i + 1] / 32767.0;
}
audioOutput (buffer, amount);
}
//
// The audioOut function is the one that really should be
// reimplemented in the offsprings of this class
void audioBase::audioOutput (float *v, int32_t amount) {
(void)v;
(void)amount;
}

56
example-5/audio-base.h Normal file
View File

@@ -0,0 +1,56 @@
#
/*
* Copyright (C) 2009, 2010, 2011
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the main program for the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __AUDIO_BASE__
#define __AUDIO_BASE__
#include <stdio.h>
#include <samplerate.h>
#include "newconverter.h"
#include "ringbuffer.h"
typedef float DSPFLOAT;
typedef std::complex<DSPFLOAT> DSPCOMPLEX;
using namespace std;
class audioBase {
public:
audioBase (void);
virtual ~audioBase (void);
virtual void stop (void);
virtual void restart (void);
void audioOut (int16_t *, int32_t, int32_t);
private:
void audioOut_16000 (int16_t *, int32_t);
void audioOut_24000 (int16_t *, int32_t);
void audioOut_32000 (int16_t *, int32_t);
void audioOut_48000 (int16_t *, int32_t);
newConverter converter_16;
newConverter converter_24;
newConverter converter_32;
protected:
virtual void audioOutput (float *, int32_t);
};
#endif

253
example-5/audiosink.cpp Normal file
View File

@@ -0,0 +1,253 @@
#
/*
* Copyright (C) 2011, 2012, 2013
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the main program of the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "audiosink.h"
#include <stdio.h>
/*
*/
audioSink::audioSink (int16_t latency,
std::string soundChannel,
bool *err):
audioBase () {
int32_t i;
this -> latency = latency;
this -> CardRate = 48000;
_O_Buffer = new RingBuffer<float>(2 * 32768);
portAudio = false;
writerRunning = false;
if (Pa_Initialize () != paNoError) {
fprintf (stderr, "Initializing Pa for output failed\n");
return;
}
portAudio = true;
fprintf (stderr, "Hostapis: %d\n", Pa_GetHostApiCount ());
for (i = 0; i < Pa_GetHostApiCount (); i ++)
fprintf (stderr, "Api %d is %s\n", i, Pa_GetHostApiInfo (i) -> name);
numofDevices = Pa_GetDeviceCount ();
outTable = new int16_t [numofDevices + 1];
for (i = 0; i < numofDevices; i ++)
outTable [i] = -1;
ostream = NULL;
*err = !selectDevice (soundChannel);
}
audioSink::~audioSink (void) {
if ((ostream != NULL) && !Pa_IsStreamStopped (ostream)) {
paCallbackReturn = paAbort;
(void) Pa_AbortStream (ostream);
while (!Pa_IsStreamStopped (ostream))
Pa_Sleep (1);
writerRunning = false;
}
if (ostream != NULL)
Pa_CloseStream (ostream);
if (portAudio)
Pa_Terminate ();
delete _O_Buffer;
delete[] outTable;
}
bool audioSink::selectDevice (const std::string soundChannel) {
PaError err;
int16_t odev = 0, i;
fprintf (stderr, "selecting device %s\n", soundChannel. c_str ());
for (i = 0; i < numofDevices; i ++) {
const std::string so =
outputChannelwithRate (i, CardRate);
if (so == std::string (""))
continue;
fprintf (stderr, "device %s seems available as %d\n",
so. c_str (), i);
if (so. find (soundChannel,0) != std::string::npos)
odev = i;
}
if (!isValidDevice (odev)) {
fprintf (stderr, "invalid device (%d) selected\n", odev);
return false;
}
if ((ostream != NULL) && !Pa_IsStreamStopped (ostream)) {
paCallbackReturn = paAbort;
(void) Pa_AbortStream (ostream);
while (!Pa_IsStreamStopped (ostream))
Pa_Sleep (1);
writerRunning = false;
}
if (ostream != NULL)
Pa_CloseStream (ostream);
outputParameters. device = odev;
outputParameters. channelCount = 2;
outputParameters. sampleFormat = paFloat32;
outputParameters. suggestedLatency =
Pa_GetDeviceInfo (odev) ->
defaultHighOutputLatency * latency;
bufSize = (int)((float)outputParameters. suggestedLatency);
bufSize = latency * 128;
outputParameters. hostApiSpecificStreamInfo = NULL;
//
fprintf (stderr, "Suggested size for outputbuffer = %d\n", bufSize);
err = Pa_OpenStream (&ostream,
NULL,
&outputParameters,
CardRate,
bufSize,
0,
this -> paCallback_o,
this
);
if (err != paNoError) {
fprintf (stderr, "Open ostream error\n");
return false;
}
paCallbackReturn = paContinue;
err = Pa_StartStream (ostream);
if (err != paNoError) {
fprintf (stderr, "Open startstream error\n");
return false;
}
writerRunning = true;
return true;
}
void audioSink::restart (void) {
PaError err;
if (!Pa_IsStreamStopped (ostream))
return;
_O_Buffer -> FlushRingBuffer ();
paCallbackReturn = paContinue;
err = Pa_StartStream (ostream);
if (err == paNoError)
writerRunning = true;
}
void audioSink::stop (void) {
if (Pa_IsStreamStopped (ostream))
return;
paCallbackReturn = paAbort;
(void)Pa_StopStream (ostream);
while (!Pa_IsStreamStopped (ostream))
Pa_Sleep (1);
writerRunning = false;
}
//
// helper
bool audioSink::OutputrateIsSupported (int16_t device, int32_t Rate) {
PaStreamParameters *outputParameters =
(PaStreamParameters *)alloca (sizeof (PaStreamParameters));
outputParameters -> device = device;
outputParameters -> channelCount = 2; /* I and Q */
outputParameters -> sampleFormat = paFloat32;
outputParameters -> suggestedLatency = 0;
outputParameters -> hostApiSpecificStreamInfo = NULL;
return Pa_IsFormatSupported (NULL, outputParameters, Rate) ==
paFormatIsSupported;
}
/*
* ... and the callback
*/
int audioSink::paCallback_o (
const void* inputBuffer,
void* outputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo *timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData) {
RingBuffer<float> *outB;
float *outp = (float *)outputBuffer;
audioSink *ud = reinterpret_cast <audioSink *>(userData);
uint32_t actualSize;
uint32_t i;
(void)statusFlags;
(void)inputBuffer;
(void)timeInfo;
if (ud -> paCallbackReturn == paContinue) {
outB = (reinterpret_cast <audioSink *> (userData)) -> _O_Buffer;
actualSize = outB -> getDataFromBuffer (outp, 2 * framesPerBuffer);
for (i = actualSize; i < 2 * framesPerBuffer; i ++)
outp [i] = 0;
}
return ud -> paCallbackReturn;
}
void audioSink::audioOutput (float *b, int32_t amount) {
_O_Buffer -> putDataIntoBuffer (b, 2 * amount);
}
const char *audioSink::outputChannelwithRate (int16_t ch, int32_t rate) {
const PaDeviceInfo *deviceInfo;
if ((ch < 0) || (ch >= numofDevices))
return "";
deviceInfo = Pa_GetDeviceInfo (ch);
if (deviceInfo == NULL)
return "";
if (deviceInfo -> maxOutputChannels <= 0)
return "";
if (OutputrateIsSupported (ch, rate))
return (deviceInfo -> name);
return "";
}
int16_t audioSink::invalidDevice (void) {
return numofDevices + 128;
}
bool audioSink::isValidDevice (int16_t dev) {
return 0 <= dev && dev < numofDevices;
}
bool audioSink::selectDefaultDevice (void) {
return selectDevice ("default");
}
int32_t audioSink::cardRate (void) {
return 48000;
}
int16_t audioSink::numberofDevices (void) {
return numofDevices;
}

73
example-5/audiosink.h Normal file
View File

@@ -0,0 +1,73 @@
#
/*
* Copyright (C) 2009, 2010, 2011
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the main program for the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __AUDIO_SINK__
#define __AUDIO_SINK__
#include <portaudio.h>
#include <stdio.h>
#include "audio-base.h"
#include "ringbuffer.h"
#include <string>
class audioSink : public audioBase {
public:
audioSink (int16_t, std::string, bool *);
~audioSink (void);
void stop (void);
void restart (void);
bool selectDevice (const std::string);
bool selectDefaultDevice (void);
private:
int16_t numberofDevices (void);
const char *outputChannelwithRate (int16_t, int32_t);
int16_t invalidDevice (void);
bool isValidDevice (int16_t);
int32_t cardRate (void);
bool OutputrateIsSupported (int16_t, int32_t);
void audioOutput (float *, int32_t);
int32_t CardRate;
int16_t latency;
int32_t size;
bool portAudio;
bool writerRunning;
int16_t numofDevices;
int paCallbackReturn;
int16_t bufSize;
PaStream *ostream;
RingBuffer<float> *_O_Buffer;
PaStreamParameters outputParameters;
int16_t *outTable;
protected:
static int paCallback_o (const void *input,
void *output,
unsigned long framesperBuffer,
const PaStreamCallbackTimeInfo *timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData);
};
#endif

121
example-5/band-handler.cpp Normal file
View File

@@ -0,0 +1,121 @@
#
/*
* Copyright (C) 2013, 2014, 2015, 2016, 2017
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "band-handler.h"
struct dabFrequencies {
const char *key;
int fKHz;
};
static
struct dabFrequencies bandIII_frequencies [] = {
{"5A", 174928},
{"5B", 176640},
{"5C", 178352},
{"5D", 180064},
{"6A", 181936},
{"6B", 183648},
{"6C", 185360},
{"6D", 187072},
{"7A", 188928},
{"7B", 190640},
{"7C", 192352},
{"7D", 194064},
{"8A", 195936},
{"8B", 197648},
{"8C", 199360},
{"8D", 201072},
{"9A", 202928},
{"9B", 204640},
{"9C", 206352},
{"9D", 208064},
{"10A", 209936},
{"10B", 211648},
{"10C", 213360},
{"10D", 215072},
{"11A", 216928},
{"11B", 218640},
{"11C", 220352},
{"11D", 222064},
{"12A", 223936},
{"12B", 225648},
{"12C", 227360},
{"12D", 229072},
{"13A", 230748},
{"13B", 232496},
{"13C", 234208},
{"13D", 235776},
{"13E", 237488},
{"13F", 239200},
{NULL, 0}
};
static
struct dabFrequencies Lband_frequencies [] = {
{"LA", 1452960},
{"LB", 1454672},
{"LC", 1456384},
{"LD", 1458096},
{"LE", 1459808},
{"LF", 1461520},
{"LG", 1463232},
{"LH", 1464944},
{"LI", 1466656},
{"LJ", 1468368},
{"LK", 1470080},
{"LL", 1471792},
{"LM", 1473504},
{"LN", 1475216},
{"LO", 1476928},
{"LP", 1478640},
{NULL, 0}
};
bandHandler::bandHandler (void) {}
bandHandler::~bandHandler (void) {}
// find the frequency for a given channel in a given band
int32_t bandHandler::Frequency (uint8_t dabBand, std::string Channel) {
int32_t tunedFrequency = 0;
struct dabFrequencies *finger;
int i;
if (dabBand == BAND_III)
finger = bandIII_frequencies;
else
finger = Lband_frequencies;
for (i = 0; finger [i]. key != NULL; i ++) {
if (finger [i]. key == Channel) {
tunedFrequency = finger [i]. fKHz * 1000;
break;
}
}
if (tunedFrequency == 0)
tunedFrequency = finger [0]. fKHz * 1000;
return tunedFrequency;
}

41
example-5/band-handler.h Normal file
View File

@@ -0,0 +1,41 @@
#
/*
* Copyright (C) 2013, 2014, 2015, 2016, 2017
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the Qt-DAB program
* Qt-DAB 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 2 of the License, or
* (at your option) any later version.
*
* Qt-DAB 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 Qt-DAB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __BANDHANDLER__
#define __BANDHANDLER__
#include <stdint.h>
#include <string>
//
// a simple convenience class
//
#define BAND_III 0100
#define L_BAND 0101
class bandHandler {
public:
bandHandler (void);
~bandHandler (void);
int32_t Frequency (uint8_t band, std::string Channel);
};
#endif

View File

@@ -0,0 +1,13 @@
QMAKE_DEFAULT_INCDIRS = \
/usr/include/c++/6.4.1 \
/usr/include/c++/6.4.1/x86_64-redhat-linux \
/usr/include/c++/6.4.1/backward \
/usr/lib/gcc/x86_64-redhat-linux/6.4.1/include \
/usr/local/include \
/usr/include
QMAKE_DEFAULT_LIBDIRS = \
/usr/lib/gcc/x86_64-redhat-linux/6.4.1 \
/usr/lib64 \
/lib64 \
/usr/lib \
/lib

BIN
example-5/client/Client Normal file

Binary file not shown.

596
example-5/client/Makefile Normal file
View File

@@ -0,0 +1,596 @@
#############################################################################
# Makefile for building: Client
# Generated by qmake (3.0) (Qt 5.7.1)
# Project: client.pro
# Template: app
# Command: /usr/bin/qmake-qt5 -o Makefile client.pro
#############################################################################
MAKEFILE = Makefile
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB
CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
INCPATH = -I. -I. -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtCore -I. -I. -I/usr/lib64/qt5/mkspecs/linux-g++
QMAKE = /usr/bin/qmake-qt5
DEL_FILE = rm -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
COPY = cp -f
COPY_FILE = cp -f
COPY_DIR = cp -f -R
INSTALL_FILE = install -m 644 -p
INSTALL_PROGRAM = install -m 755 -p
INSTALL_DIR = cp -f -R
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
TAR = tar -cf
COMPRESS = gzip -9f
DISTNAME = Client1.0.0
DISTDIR = /usr/shared/sdr-j-development/systems/dab-cmdline/example-2/client/.tmp/Client1.0.0
LINK = g++
LFLAGS = -Wl,-O1
LIBS = $(SUBLIBS) -lQt5Widgets -lQt5Gui -lQt5Network -lQt5Core -lGL -lpthread
AR = ar cqs
RANLIB =
SED = sed
STRIP = strip
####### Output directory
OBJECTS_DIR = ./
####### Files
SOURCES = client.cpp \
main.cpp moc_client.cpp
OBJECTS = client.o \
main.o \
moc_client.o
DIST = /usr/lib64/qt5/mkspecs/features/spec_pre.prf \
/usr/lib64/qt5/mkspecs/common/unix.conf \
/usr/lib64/qt5/mkspecs/common/linux.conf \
/usr/lib64/qt5/mkspecs/common/sanitize.conf \
/usr/lib64/qt5/mkspecs/common/gcc-base.conf \
/usr/lib64/qt5/mkspecs/common/gcc-base-unix.conf \
/usr/lib64/qt5/mkspecs/common/g++-base.conf \
/usr/lib64/qt5/mkspecs/common/g++-unix.conf \
/usr/lib64/qt5/mkspecs/qconfig.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dcore.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dcore_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dextras.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dextras_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dinput.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dinput_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dlogic.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dlogic_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquick.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquick_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickextras.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickextras_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickinput.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickinput_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickrender.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickrender_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3drender.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3drender_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_bluetooth.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_bluetooth_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_clucene_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_concurrent.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_concurrent_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_core.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_core_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_dbus.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_dbus_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_designer.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_designer_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_designercomponents_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_eglfs_device_lib_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_enginio.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_enginio_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_gui.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_gui_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_help.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_help_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_location.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_location_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimedia.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimedia_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimediawidgets_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_network.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_network_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_nfc.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_nfc_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_opengl.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_opengl_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_packetprotocol_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_platformsupport_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_positioning.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_positioning_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_printsupport.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qml.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qml_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmldebug_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmldevtools_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmltest.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmltest_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quick.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quick_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickparticles_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickwidgets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickwidgets_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_script.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_script_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_scripttools.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_scripttools_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_sensors.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_sensors_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_serialport.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_serialport_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_sql.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_sql_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_svg.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_svg_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_testlib.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_testlib_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_uiplugin.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_uitools.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_uitools_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandclient.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandclient_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_webkit.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_websockets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_websockets_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_widgets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_widgets_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xml.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xml_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xmlpatterns_private.pri \
/usr/lib64/qt5/mkspecs/features/qt_functions.prf \
/usr/lib64/qt5/mkspecs/features/qt_config.prf \
/usr/lib64/qt5/mkspecs/linux-g++/qmake.conf \
/usr/lib64/qt5/mkspecs/features/spec_post.prf \
.qmake.stash \
/usr/lib64/qt5/mkspecs/features/exclusive_builds.prf \
/usr/lib64/qt5/mkspecs/features/toolchain.prf \
/usr/lib64/qt5/mkspecs/features/default_pre.prf \
/usr/lib64/qt5/mkspecs/features/resolve_config.prf \
/usr/lib64/qt5/mkspecs/features/default_post.prf \
/usr/lib64/qt5/mkspecs/features/warn_on.prf \
/usr/lib64/qt5/mkspecs/features/qt.prf \
/usr/lib64/qt5/mkspecs/features/resources.prf \
/usr/lib64/qt5/mkspecs/features/moc.prf \
/usr/lib64/qt5/mkspecs/features/unix/opengl.prf \
/usr/lib64/qt5/mkspecs/features/uic.prf \
/usr/lib64/qt5/mkspecs/features/unix/thread.prf \
/usr/lib64/qt5/mkspecs/features/file_copies.prf \
/usr/lib64/qt5/mkspecs/features/testcase_targets.prf \
/usr/lib64/qt5/mkspecs/features/exceptions.prf \
/usr/lib64/qt5/mkspecs/features/yacc.prf \
/usr/lib64/qt5/mkspecs/features/lex.prf \
client.pro client.h \
constants.h client.cpp \
main.cpp
QMAKE_TARGET = Client
DESTDIR =
TARGET = Client
first: all
####### Build rules
$(TARGET): ui_widget.h $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
Makefile: client.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5/mkspecs/features/spec_pre.prf \
/usr/lib64/qt5/mkspecs/common/unix.conf \
/usr/lib64/qt5/mkspecs/common/linux.conf \
/usr/lib64/qt5/mkspecs/common/sanitize.conf \
/usr/lib64/qt5/mkspecs/common/gcc-base.conf \
/usr/lib64/qt5/mkspecs/common/gcc-base-unix.conf \
/usr/lib64/qt5/mkspecs/common/g++-base.conf \
/usr/lib64/qt5/mkspecs/common/g++-unix.conf \
/usr/lib64/qt5/mkspecs/qconfig.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dcore.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dcore_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dextras.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dextras_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dinput.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dinput_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dlogic.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dlogic_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquick.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquick_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickextras.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickextras_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickinput.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickinput_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickrender.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickrender_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3drender.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_3drender_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_bluetooth.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_bluetooth_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_clucene_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_concurrent.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_concurrent_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_core.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_core_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_dbus.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_dbus_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_designer.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_designer_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_designercomponents_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_eglfs_device_lib_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_enginio.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_enginio_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_gui.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_gui_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_help.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_help_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_location.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_location_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimedia.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimedia_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimediawidgets_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_network.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_network_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_nfc.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_nfc_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_opengl.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_opengl_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_packetprotocol_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_platformsupport_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_positioning.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_positioning_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_printsupport.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_printsupport_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qml.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qml_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmldebug_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmldevtools_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmltest.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmltest_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quick.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quick_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickparticles_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickwidgets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickwidgets_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_script.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_script_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_scripttools.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_scripttools_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_sensors.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_sensors_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_serialport.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_serialport_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_sql.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_sql_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_svg.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_svg_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_testlib.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_testlib_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_uiplugin.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_uitools.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_uitools_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandclient.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandclient_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_webkit.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_websockets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_websockets_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_widgets.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_widgets_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xml.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xml_private.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri \
/usr/lib64/qt5/mkspecs/modules/qt_lib_xmlpatterns_private.pri \
/usr/lib64/qt5/mkspecs/features/qt_functions.prf \
/usr/lib64/qt5/mkspecs/features/qt_config.prf \
/usr/lib64/qt5/mkspecs/linux-g++/qmake.conf \
/usr/lib64/qt5/mkspecs/features/spec_post.prf \
.qmake.stash \
/usr/lib64/qt5/mkspecs/features/exclusive_builds.prf \
/usr/lib64/qt5/mkspecs/features/toolchain.prf \
/usr/lib64/qt5/mkspecs/features/default_pre.prf \
/usr/lib64/qt5/mkspecs/features/resolve_config.prf \
/usr/lib64/qt5/mkspecs/features/default_post.prf \
/usr/lib64/qt5/mkspecs/features/warn_on.prf \
/usr/lib64/qt5/mkspecs/features/qt.prf \
/usr/lib64/qt5/mkspecs/features/resources.prf \
/usr/lib64/qt5/mkspecs/features/moc.prf \
/usr/lib64/qt5/mkspecs/features/unix/opengl.prf \
/usr/lib64/qt5/mkspecs/features/uic.prf \
/usr/lib64/qt5/mkspecs/features/unix/thread.prf \
/usr/lib64/qt5/mkspecs/features/file_copies.prf \
/usr/lib64/qt5/mkspecs/features/testcase_targets.prf \
/usr/lib64/qt5/mkspecs/features/exceptions.prf \
/usr/lib64/qt5/mkspecs/features/yacc.prf \
/usr/lib64/qt5/mkspecs/features/lex.prf \
client.pro \
/usr/lib64/libQt5Widgets.prl \
/usr/lib64/libQt5Gui.prl \
/usr/lib64/libQt5Network.prl \
/usr/lib64/libQt5Core.prl
$(QMAKE) -o Makefile client.pro
/usr/lib64/qt5/mkspecs/features/spec_pre.prf:
/usr/lib64/qt5/mkspecs/common/unix.conf:
/usr/lib64/qt5/mkspecs/common/linux.conf:
/usr/lib64/qt5/mkspecs/common/sanitize.conf:
/usr/lib64/qt5/mkspecs/common/gcc-base.conf:
/usr/lib64/qt5/mkspecs/common/gcc-base-unix.conf:
/usr/lib64/qt5/mkspecs/common/g++-base.conf:
/usr/lib64/qt5/mkspecs/common/g++-unix.conf:
/usr/lib64/qt5/mkspecs/qconfig.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dcore.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dcore_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dextras.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dextras_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dinput.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dinput_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dlogic.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dlogic_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquick.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquick_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickextras.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickextras_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickinput.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickinput_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickrender.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3dquickrender_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3drender.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_3drender_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_bluetooth.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_bluetooth_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_bootstrap_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_clucene_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_concurrent.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_concurrent_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_core.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_core_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_dbus.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_dbus_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_designer.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_designer_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_designercomponents_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_eglfs_device_lib_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_eglfs_kms_support_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_enginio.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_enginio_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_gui.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_gui_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_help.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_help_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_location.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_location_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimedia.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimedia_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_multimediawidgets_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_network.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_network_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_nfc.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_nfc_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_opengl.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_opengl_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_packetprotocol_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_platformsupport_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_positioning.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_positioning_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_printsupport.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_printsupport_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_qml.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_qml_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmldebug_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmldevtools_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmltest.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_qmltest_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_quick.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_quick_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickparticles_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickwidgets.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_quickwidgets_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_script.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_script_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_scripttools.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_scripttools_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_sensors.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_sensors_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_serialport.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_serialport_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_sql.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_sql_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_svg.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_svg_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_testlib.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_testlib_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_uiplugin.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_uitools.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_uitools_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandclient.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandclient_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_webkit.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_websockets.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_websockets_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_widgets.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_widgets_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_xcb_qpa_lib_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_xml.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_xml_private.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri:
/usr/lib64/qt5/mkspecs/modules/qt_lib_xmlpatterns_private.pri:
/usr/lib64/qt5/mkspecs/features/qt_functions.prf:
/usr/lib64/qt5/mkspecs/features/qt_config.prf:
/usr/lib64/qt5/mkspecs/linux-g++/qmake.conf:
/usr/lib64/qt5/mkspecs/features/spec_post.prf:
.qmake.stash:
/usr/lib64/qt5/mkspecs/features/exclusive_builds.prf:
/usr/lib64/qt5/mkspecs/features/toolchain.prf:
/usr/lib64/qt5/mkspecs/features/default_pre.prf:
/usr/lib64/qt5/mkspecs/features/resolve_config.prf:
/usr/lib64/qt5/mkspecs/features/default_post.prf:
/usr/lib64/qt5/mkspecs/features/warn_on.prf:
/usr/lib64/qt5/mkspecs/features/qt.prf:
/usr/lib64/qt5/mkspecs/features/resources.prf:
/usr/lib64/qt5/mkspecs/features/moc.prf:
/usr/lib64/qt5/mkspecs/features/unix/opengl.prf:
/usr/lib64/qt5/mkspecs/features/uic.prf:
/usr/lib64/qt5/mkspecs/features/unix/thread.prf:
/usr/lib64/qt5/mkspecs/features/file_copies.prf:
/usr/lib64/qt5/mkspecs/features/testcase_targets.prf:
/usr/lib64/qt5/mkspecs/features/exceptions.prf:
/usr/lib64/qt5/mkspecs/features/yacc.prf:
/usr/lib64/qt5/mkspecs/features/lex.prf:
client.pro:
/usr/lib64/libQt5Widgets.prl:
/usr/lib64/libQt5Gui.prl:
/usr/lib64/libQt5Network.prl:
/usr/lib64/libQt5Core.prl:
qmake: FORCE
@$(QMAKE) -o Makefile client.pro
qmake_all: FORCE
all: Makefile $(TARGET)
dist: distdir FORCE
(cd `dirname $(DISTDIR)` && $(TAR) $(DISTNAME).tar $(DISTNAME) && $(COMPRESS) $(DISTNAME).tar) && $(MOVE) `dirname $(DISTDIR)`/$(DISTNAME).tar.gz . && $(DEL_FILE) -r $(DISTDIR)
distdir: FORCE
@test -d $(DISTDIR) || mkdir -p $(DISTDIR)
$(COPY_FILE) --parents $(DIST) $(DISTDIR)/
$(COPY_FILE) --parents /usr/lib64/qt5/mkspecs/features/data/dummy.cpp $(DISTDIR)/
$(COPY_FILE) --parents client.h constants.h $(DISTDIR)/
$(COPY_FILE) --parents client.cpp main.cpp $(DISTDIR)/
$(COPY_FILE) --parents widget.ui $(DISTDIR)/
clean: compiler_clean
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core
distclean: clean
-$(DEL_FILE) $(TARGET)
-$(DEL_FILE) .qmake.stash
-$(DEL_FILE) Makefile
####### Sub-libraries
mocclean: compiler_moc_header_clean compiler_moc_source_clean
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
check: first
benchmark: first
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_moc_predefs_make_all: moc_predefs.h
compiler_moc_predefs_clean:
-$(DEL_FILE) moc_predefs.h
moc_predefs.h: /usr/lib64/qt5/mkspecs/features/data/dummy.cpp
g++ -pipe -O2 -Wall -W -dM -E -o moc_predefs.h /usr/lib64/qt5/mkspecs/features/data/dummy.cpp
compiler_moc_header_make_all: moc_client.cpp
compiler_moc_header_clean:
-$(DEL_FILE) moc_client.cpp
moc_client.cpp: constants.h \
ui_widget.h \
header-test.h \
client.h \
moc_predefs.h \
/usr/lib64/qt5/bin/moc
/usr/lib64/qt5/bin/moc $(DEFINES) --include ./moc_predefs.h -I/usr/lib64/qt5/mkspecs/linux-g++ -I/usr/shared/sdr-j-development/systems/dab-cmdline/example-2/client -I/usr/shared/sdr-j-development/systems/dab-cmdline/example-2/client -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtNetwork -I/usr/include/qt5/QtCore -I/usr/include/c++/6.4.1 -I/usr/include/c++/6.4.1/x86_64-redhat-linux -I/usr/include/c++/6.4.1/backward -I/usr/lib/gcc/x86_64-redhat-linux/6.4.1/include -I/usr/local/include -I/usr/include client.h -o moc_client.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all: ui_widget.h
compiler_uic_clean:
-$(DEL_FILE) ui_widget.h
ui_widget.h: widget.ui \
/usr/lib64/qt5/bin/uic
/usr/lib64/qt5/bin/uic widget.ui -o ui_widget.h
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: compiler_moc_predefs_clean compiler_moc_header_clean compiler_uic_clean
####### Compile
client.o: client.cpp client.h \
constants.h \
ui_widget.h \
header-test.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o client.o client.cpp
main.o: main.cpp client.h \
constants.h \
ui_widget.h \
header-test.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
moc_client.o: moc_client.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_client.o moc_client.cpp
####### Install
install: FORCE
uninstall: FORCE
FORCE:

3
example-5/client/README Normal file
View File

@@ -0,0 +1,3 @@
Very simple client, for use with the tcpServer that emits the tdc data.

274
example-5/client/client.cpp Normal file
View File

@@ -0,0 +1,274 @@
#
/*
* Copyright (C) 2015
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the SDR-J.
* Many of the ideas as implemented in SDR-J are derived from
* other work, made available through the GNU general Public License.
* All copyrights of the original authors are recognized.
*
* SDR-J 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 2 of the License, or
* (at your option) any later version.
*
* SDR-J 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 SDR-J; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Communication via network to a DAB receiver to
* show the tdc data
*/
#include <QSettings>
#include <QLabel>
#include <QMessageBox>
#include <QtNetwork>
#include <QTcpSocket>
#include <QHostAddress>
#include "client.h"
//
#define swap(a) (((a) << 8) | ((a) >> 8))
//---------------------------------------------------------------------------
uint16_t usCalculCRC (uint8_t *buf, int lg) {
uint16_t crc;
uint count;
crc = 0xFFFF;
for (count= 0; count < lg; count++) {
crc = (uint16_t) (swap (crc) ^ (uint16_t)buf [count]);
crc ^= ((uint8_t)crc) >> 4;
crc = (uint16_t)
(crc ^ (swap((uint8_t)(crc)) << 4) ^ ((uint8_t)(crc) << 5));
}
return ((uint16_t)(crc ^ 0xFFFF));
}
static inline
bool check_crc_bytes (uint8_t *msg, int16_t len) {
int i, j;
uint16_t accumulator = 0xFFFF;
uint16_t crc;
uint16_t genpoly = 0x1021;
for (i = 0; i < len; i ++) {
int16_t data = msg [i] << 8;
for (j = 8; j > 0; j--) {
if ((data ^ accumulator) & 0x8000)
accumulator = ((accumulator << 1) ^ genpoly) & 0xFFFF;
else
accumulator = (accumulator << 1) & 0xFFFF;
data = (data << 1) & 0xFFFF;
}
}
//
// ok, now check with the crc that is contained
// in the au
crc = ~((msg [len] << 8) | msg [len + 1]) & 0xFFFF;
return (crc ^ accumulator) == 0;
}
Client::Client (QWidget *parent):QDialog (parent) {
int16_t i;
setupUi (this);
connected = false;
connect (connectButton, SIGNAL (clicked (void)),
this, SLOT (wantConnect (void)));
connect (terminateButton, SIGNAL (clicked (void)),
this, SLOT (terminate (void)));
state -> setText ("waiting to start");
connectionTimer = new QTimer ();
connectionTimer -> setInterval (1000);
connect (connectionTimer, SIGNAL (timeout (void)),
this, SLOT (timerTick (void)));
}
//
Client::~Client (void) {
connected = false;
}
//
void Client::wantConnect (void) {
QString ipAddress;
int16_t i;
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
if (connected)
return;
// use the first non-localhost IPv4 address
for (i = 0; i < ipAddressesList.size(); ++i) {
if (ipAddressesList.at (i) != QHostAddress::LocalHost &&
ipAddressesList. at (i). toIPv4Address ()) {
ipAddress = ipAddressesList. at(i). toString();
break;
}
}
// if we did not find one, use IPv4 localhost
if (ipAddress. isEmpty())
ipAddress = QHostAddress (QHostAddress::LocalHost).toString ();
hostLineEdit -> setText (ipAddress);
hostLineEdit -> setInputMask ("000.000.000.000");
// Setting default IP address
state -> setText ("Give IP address, return");
connect (hostLineEdit, SIGNAL (returnPressed (void)),
this, SLOT (setConnection (void)));
}
// if / when a return is pressed in the line edit,
// a signal appears and we are able to collect the
// inserted text. The format is the IP-V4 format.
// Using this text, we try to connect,
void Client::setConnection (void) {
QString s = hostLineEdit -> text ();
QHostAddress theAddress = QHostAddress (s);
int32_t basePort;
basePort = 8888;
disconnect (hostLineEdit, SIGNAL (returnPressed (void)),
this, SLOT (setConnection (void)));
//
// The streamer will provide us with the raw data
streamer. connectToHost (theAddress, basePort);
if (!streamer. waitForConnected (2000)) {
QMessageBox::warning (this, tr ("client"),
tr ("setting up stream failed\n"));
return;
}
connected = true;
state -> setText ("Connected");
connect (&streamer, SIGNAL (readyRead (void)),
this, SLOT (readData (void)));
connectionTimer -> start (1000);
}
// These functions are typical for network use
void Client::readData (void) {
QByteArray d;
int16_t i;
d. resize (4 * 512);
while (streamer. bytesAvailable () > 4 * 512) {
streamer. read (d. data (), d. size ());
for (i = 0; i < d. size (); i ++)
handle ((uint8_t)(d [i]));
}
}
#define SEARCH_HEADER 0
#define HEADER_FOUND 1
int searchState = SEARCH_HEADER;
void Client::handle (uint8_t d) {
int16_t i;
if (searchState == SEARCH_HEADER) {
headertester. shift (d);
if (headertester. hasHeader ()) {
toRead = headertester. length ();
dataLength = toRead;
dataBuffer = new uint8_t [toRead];
dataIndex = 0;
frameType = headertester. frametype ();
searchState = HEADER_FOUND;
headertester. reset ();
}
return;
}
toRead --;
dataBuffer [dataIndex ++] = d;
if (toRead == 0) {
searchState = SEARCH_HEADER;
if (frameType == 0)
handleFrameType_0 (dataBuffer, dataLength);
else
handleFrameType_1 (dataBuffer, dataLength);
delete[] dataBuffer;
}
}
void Client::terminate (void) {
if (connected) {
streamer. close ();
}
accept ();
}
void Client::timerTick (void) {
if (streamer. state () == QAbstractSocket::UnconnectedState) {
state -> setText ("not connected");
connected = false;
connectionTimer -> stop ();
}
}
void Client::handleFrameType_0 (uint8_t *dataBuffer, int16_t Length) {
fprintf (stderr, "number of services %d\n", dataBuffer [0]);
}
void Client::handleFrameType_1 (uint8_t *dataBuffer, int16_t Length) {
fprintf (stderr, "type 1 %x %x %x %x\n",
dataBuffer [0],
dataBuffer [1], dataBuffer [2], dataBuffer [3]);
if (dataBuffer [3] == 0) { // encryption 0
int16_t index = 4;
while (index < Length) {
int16_t i;
uint8_t sCi = dataBuffer [index];
uint16_t segLen = (dataBuffer [index + 1] << 8) |
dataBuffer [index + 2];
uint16_t crc = (dataBuffer [index + 3] << 8) |
dataBuffer [index + 4];
uint8_t testVector [18];
testVector [0] = sCi;
testVector [1] = dataBuffer [index + 1];
testVector [2] = dataBuffer [index + 2];
for (i = 0; i < 13; i ++)
testVector [i + 3] = dataBuffer [index + i + 5];
testVector [16] = dataBuffer [index + 3];
testVector [17] = dataBuffer [index + 4];
if (usCalculCRC (testVector, 16) == crc)
fprintf (stderr,
"sCi = %o, segLen = %d (index = %d, Length = %d)\n",
sCi, segLen, index, Length);
else {
fprintf (stderr, "failing crc\n");
}
index += segLen + 5;
}
}
else
fprintf (stderr, "encryption not zero\n");
}
bool Client::serviceComponentFrameheaderCRC (uint8_t *data,
int16_t offset,
int16_t maxL) {
uint8_t testVector [18];
int16_t i;
int16_t length = (data [offset + 1] << 8) | data [offset + 2];
int16_t size = length < 13 ? length : 13;
uint16_t crc;
if (length < 0)
return false; // assumed garbage
crc = (data [offset + 3] << 8) | data [offset + 4]; // the crc
testVector [0] = data [offset + 0];
testVector [1] = data [offset + 1];
testVector [2] = data [offset + 2];
for (i = 0; i < size; i ++)
testVector [3 + i] = data [offset + 5 + i];
return usCalculCRC (testVector, 3 + size) == crc;
}

76
example-5/client/client.h Normal file
View File

@@ -0,0 +1,76 @@
#
/*
* Copyright (C) 2015
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the SDR-J.
* Many of the ideas as implemented in SDR-J are derived from
* other work, made available through the GNU general Public License.
* All copyrights of the original authors are recognized.
*
* SDR-J 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 2 of the License, or
* (at your option) any later version.
*
* SDR-J 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 SDR-J; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Communication via network to a DAB receiver to
* show the tdc data
*/
#ifndef __TDC_CLIENT__
#define __TDC_CLIENT__
#include "constants.h"
#include <QDialog>
#include <QSettings>
#include <QLabel>
#include <QMessageBox>
#include <QTcpSocket>
#include <QHostAddress>
#include <QTimer>
#include "ui_widget.h"
#include "header-test.h"
//
class Client:public QDialog, public Ui_widget {
Q_OBJECT
public:
Client (QWidget *parent = NULL);
~Client (void);
bool connected;
private slots:
void wantConnect (void);
void setConnection (void);
void readData (void);
void handle (uint8_t);
void terminate (void);
void timerTick (void);
private:
void handleFrameType_0 (uint8_t *, int16_t);
void handleFrameType_1 (uint8_t *, int16_t);
bool serviceComponentFrameheaderCRC (uint8_t *data,
int16_t offset,
int16_t maxL);
QTcpSocket streamer;
QTimer *connectionTimer;
headerTest headertester;
int16_t toRead;
int16_t dataLength;
uint8_t *dataBuffer;
uint8_t frameType;
int16_t dataIndex;
};
#endif

View File

@@ -0,0 +1,18 @@
#
TEMPLATE = app
CONFIG += console
QT += core gui network widgets
INCLUDEPATH += .
HEADERS = ./client.h \
./constants.h
SOURCES = ./client.cpp main.cpp
TARGET = Client
FORMS += ./widget.ui
unix{
DESTDIR = .
}

View File

@@ -0,0 +1,81 @@
#
/*
* Copyright (C) 2011, 2012, 2013
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the SDR-J
* Many of the ideas as implemented in SDR-J are derived from
* other work, made available through the GNU general Public License.
* All copyrights of the original authors are recognized.
*
* SDR-J 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 2 of the License, or
* (at your option) any later version.
*
* SDR-J 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 SDR-J; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#
#ifndef __SOUND_CONSTANTS
#define __SOUND_CONSTANTS
#include <math.h>
#include <complex>
#include <stdint.h>
#include <unistd.h>
#include <limits>
#include "stdlib.h"
using namespace std;
#include <malloc.h>
#ifdef __MINGW32__
#include "windows.h"
#else
#include "alloca.h"
#endif
/*
*/
typedef float DSPFLOAT;
typedef std::complex<DSPFLOAT> DSPCOMPLEX;
#define MINIMUM(x, y) ((x) < (y) ? x : y)
#define MAXIMUM(x, y) ((x) > (y) ? x : y)
// common, simple but useful, functions
static inline
bool isIndeterminate (DSPFLOAT x) {
return x != x;
}
static inline
bool isInfinite (double x) {
return x == numeric_limits<DSPFLOAT>::infinity ();
}
//
static inline
DSPCOMPLEX cmul (DSPCOMPLEX x, float y) {
return DSPCOMPLEX (real (x) * y, imag (x) * y);
}
static inline
DSPCOMPLEX cdiv (DSPCOMPLEX x, float y) {
return DSPCOMPLEX (real (x) / y, imag (x) / y);
}
static inline
float get_db (DSPFLOAT x) {
return 20 * log10 ((x + 1) / (float)(256 * 65536));
}
#endif

View File

@@ -0,0 +1,102 @@
#
/*
* Copyright (C) 2017
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the SDR-J
* Many of the ideas as implemented in SDR-J are derived from
* other work, made available through the GNU general Public License.
* All copyrights of the original authors are recognized.
*
* SDR-J 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 2 of the License, or
* (at your option) any later version.
*
* SDR-J 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 SDR-J; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* Simple checker for te package header
*/
#ifndef __HEADER_TEST__
#define __HEADER_TEST__
#include <stdint.h>
#include <stdio.h>
class headerTest {
private:
uint8_t b [8];
int16_t counter;
public:
headerTest (void) {
counter = 0;
}
~headerTest (void) {
}
void shift (uint8_t d) {
if ((counter == 0) && (d == 0xFF)) {
b [counter ++] = 0xFF;
return;
}
if ((counter == 1) && (d == 0x00)) {
b [counter ++] = 0x00;
return;
}
if ((counter == 2) && (d == 0xFF)) {
b [counter ++] = 0xFF;
return;
}
if ((counter == 3) && (d == 0x00)) {
b [counter ++] = 0x00;
return;
}
if (counter == 4) {
b [counter ++] = d;
return;
}
if (counter == 5) {
b [counter ++] = d;
return;
}
if ((counter == 6) && (d == 0x00)) {
b [counter ++] = d;
return;
}
if ((counter == 7) && ((d == 0x00) || (d = 0xFF))) {
b [counter ++] = d;
fprintf (stderr, "header detected, %o %o %o (%d)\n",
b [4], b [5], b [7],
(b [4] << 8) | (b [5] & 0xFF));
return;
}
counter = 0;
}
void reset (void) {
counter = 0;
}
bool hasHeader (void) {
return counter == 8;
}
uint8_t frametype (void) {
return b [7];
}
int16_t length () {
return (b [4] << 8) | b [5];
}
};
#endif

51
example-5/client/main.cpp Normal file
View File

@@ -0,0 +1,51 @@
#
/*
* Copyright (C) 2008, 2009, 2010, 2011, 2012
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair programming
*
* This file is part of the SDR-J.
* Many of the ideas as implemented in SDR-J are derived from
* other work, made available through the GNU general Public License.
* All copyrights of the original authors are recognized.
*
* SDR-J 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 2 of the License, or
* (at your option) any later version.
*
* SDR-J 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 SDR-J; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Main program
*/
#include <QApplication>
#include <QDir>
#include "client.h"
#ifdef __MINGW32__
#include "windows.h"
#endif
int main (int argc, char **argv) {
Client *myClient;
QApplication a (argc, argv);
myClient = new Client ();
myClient -> show ();
a. exec ();
/*
* done:
*/
fflush (stdout);
fflush (stderr);
qDebug ("It is done\n");
}

View File

@@ -0,0 +1,320 @@
#
/*
* $Id: pa_ringbuffer.c 1738 2011-08-18 11:47:28Z rossb $
* Portable Audio I/O Library
* Ring Buffer utility.
*
* Author: Phil Burk, http://www.softsynth.com
* modified for SMP safety on Mac OS X by Bjorn Roche
* modified for SMP safety on Linux by Leland Lucius
* also, allowed for const where possible
* modified for multiple-byte-sized data elements by Sven Fischer
*
* Note that this is safe only for a single-thread reader and a
* single-thread writer.
*
* This program uses the PortAudio Portable Audio Library.
* For more information see: http://www.portaudio.com
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
*
* Copyright (C) 2008, 2009, 2010
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* The ringbuffer here is a rewrite of the ringbuffer used in the PA code
* All rights remain with their owners
* This file is part of the SDR-J.
* Many of the ideas as implemented in SDR-J are derived from
* other work, made available through the GNU general Public License.
* All copyrights of the original authors are recognized.
*
* SDR-J 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 2 of the License, or
* (at your option) any later version.
*
* SDR-J 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 SDR-J; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __RINGBUFFER
#define __RINGBUFFER
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
/*
* a simple ringbuffer, lockfree, however only for a
* single reader and a single writer.
* Mostly used for getting samples from or to the soundcard
*/
#if defined(__APPLE__)
# include <libkern/OSAtomic.h>
/* Here are the memory barrier functions. Mac OS X only provides
full memory barriers, so the three types of barriers are the same,
however, these barriers are superior to compiler-based ones. */
# define PaUtil_FullMemoryBarrier() OSMemoryBarrier()
# define PaUtil_ReadMemoryBarrier() OSMemoryBarrier()
# define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
#elif defined(__GNUC__)
/* GCC >= 4.1 has built-in intrinsics. We'll use those */
# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
# define PaUtil_FullMemoryBarrier() __sync_synchronize()
# define PaUtil_ReadMemoryBarrier() __sync_synchronize()
# define PaUtil_WriteMemoryBarrier() __sync_synchronize()
/* as a fallback, GCC understands volatile asm and "memory" to mean it
* should not reorder memory read/writes */
# elif defined( __PPC__ )
# define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory")
# define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory")
# define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory")
# elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || defined( __i686__ ) || defined( __x86_64__ )
# define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory")
# define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory")
# define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory")
# else
# ifdef ALLOW_SMP_DANGERS
# warning Memory barriers not defined on this system or system unknown
# warning For SMP safety, you should fix this.
# define PaUtil_FullMemoryBarrier()
# define PaUtil_ReadMemoryBarrier()
# define PaUtil_WriteMemoryBarrier()
# else
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
# endif
# endif
#else
# ifdef ALLOW_SMP_DANGERS
# warning Memory barriers not defined on this system or system unknown
# warning For SMP safety, you should fix this.
# define PaUtil_FullMemoryBarrier()
# define PaUtil_ReadMemoryBarrier()
# define PaUtil_WriteMemoryBarrier()
# else
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
# endif
#endif
template <class elementtype>
class RingBuffer {
private:
uint32_t bufferSize;
volatile uint32_t writeIndex;
volatile uint32_t readIndex;
uint32_t bigMask;
uint32_t smallMask;
char *buffer;
public:
RingBuffer (uint32_t elementCount) {
if (((elementCount - 1) & elementCount) != 0)
elementCount = 4 * 16384; /* default */
bufferSize = elementCount;
buffer = new char [2 * bufferSize * sizeof (elementtype)];
writeIndex = 0;
readIndex = 0;
smallMask = (elementCount)- 1;
bigMask = (elementCount * 2) - 1;
}
~RingBuffer () {
delete[] buffer;
}
/*
* functions for checking available data for reading and space
* for writing
*/
uint32_t GetRingBufferReadAvailable (void) {
return (writeIndex - readIndex) & bigMask;
}
//int32_t ReadSpace (void){
// return GetRingBufferReadAvailable ();
//}
uint32_t GetRingBufferWriteAvailable (void) {
return bufferSize - GetRingBufferReadAvailable ();
}
int32_t WriteSpace (void) {
return GetRingBufferWriteAvailable ();
}
void FlushRingBuffer () {
writeIndex = 0;
readIndex = 0;
}
/* ensure that previous writes are seen before we update the write index
(write after write)
*/
int32_t AdvanceRingBufferWriteIndex (int32_t elementCount) {
PaUtil_WriteMemoryBarrier();
return writeIndex = (writeIndex + elementCount) & bigMask;
}
/* ensure that previous reads (copies out of the ring buffer) are
* always completed before updating (writing) the read index.
* (write-after-read) => full barrier
*/
int32_t AdvanceRingBufferReadIndex (int32_t elementCount) {
PaUtil_FullMemoryBarrier();
return readIndex = (readIndex + elementCount) & bigMask;
}
/***************************************************************************
** Get address of region(s) to which we can write data.
** If the region is contiguous, size2 will be zero.
** If non-contiguous, size2 will be the size of second region.
** Returns room available to be written or elementCount, whichever is smaller.
*/
int32_t GetRingBufferWriteRegions (uint32_t elementCount,
void **dataPtr1, int32_t *sizePtr1,
void **dataPtr2, int32_t *sizePtr2 ) {
uint32_t index;
uint32_t available = GetRingBufferWriteAvailable ();
if (elementCount > available)
elementCount = available;
/* Check to see if write is not contiguous. */
index = writeIndex & smallMask;
if ((index + elementCount) > bufferSize ) {
/* Write data in two blocks that wrap the buffer. */
int32_t firstHalf = bufferSize - index;
*dataPtr1 = &buffer[index * sizeof(elementtype)];
*sizePtr1 = firstHalf;
*dataPtr2 = &buffer [0];
*sizePtr2 = elementCount - firstHalf;
}
else { // fits
*dataPtr1 = &buffer [index * sizeof(elementtype)];
*sizePtr1 = elementCount;
*dataPtr2 = NULL;
*sizePtr2 = 0;
}
if (available > 0)
PaUtil_FullMemoryBarrier(); /* (write-after-read) => full barrier */
return elementCount;
}
/***************************************************************************
** Get address of region(s) from which we can read data.
** If the region is contiguous, size2 will be zero.
** If non-contiguous, size2 will be the size of second region.
** Returns room available to be read or elementCount, whichever is smaller.
*/
int32_t GetRingBufferReadRegions (uint32_t elementCount,
void **dataPtr1, int32_t *sizePtr1,
void **dataPtr2, int32_t *sizePtr2) {
uint32_t index;
uint32_t available = GetRingBufferReadAvailable (); /* doesn't use memory barrier */
if (elementCount > available)
elementCount = available;
/* Check to see if read is not contiguous. */
index = readIndex & smallMask;
if ((index + elementCount) > bufferSize) {
/* Write data in two blocks that wrap the buffer. */
int32_t firstHalf = bufferSize - index;
*dataPtr1 = &buffer [index * sizeof(elementtype)];
*sizePtr1 = firstHalf;
*dataPtr2 = &buffer [0];
*sizePtr2 = elementCount - firstHalf;
}
else {
*dataPtr1 = &buffer [index * sizeof(elementtype)];
*sizePtr1 = elementCount;
*dataPtr2 = NULL;
*sizePtr2 = 0;
}
if (available)
PaUtil_ReadMemoryBarrier(); /* (read-after-read) => read barrier */
return elementCount;
}
int32_t putDataIntoBuffer (const void *data, int32_t elementCount) {
int32_t size1, size2, numWritten;
void *data1;
void *data2;
numWritten = GetRingBufferWriteRegions (elementCount,
&data1, &size1,
&data2, &size2 );
if (size2 > 0) {
memcpy (data1, data, size1 * sizeof(elementtype));
data = ((char *)data) + size1 * sizeof(elementtype);
memcpy (data2, data, size2 * sizeof(elementtype));
}
else
memcpy (data1, data, size1 * sizeof(elementtype));
AdvanceRingBufferWriteIndex (numWritten );
return numWritten;
}
int32_t getDataFromBuffer (void *data, int32_t elementCount ) {
int32_t size1, size2, numRead;
void *data1;
void *data2;
numRead = GetRingBufferReadRegions (elementCount,
&data1, &size1,
&data2, &size2 );
if (size2 > 0) {
memcpy (data, data1, size1 * sizeof(elementtype));
data = ((char *)data) + size1 * sizeof(elementtype);
memcpy (data, data2, size2 * sizeof(elementtype));
}
else
memcpy (data, data1, size1 * sizeof(elementtype));
AdvanceRingBufferReadIndex (numRead );
return numRead;
}
int32_t skipDataInBuffer (uint32_t n_values) {
// ensure that we have the correct read and write indices
PaUtil_FullMemoryBarrier ();
if (n_values > GetRingBufferReadAvailable ())
n_values = GetRingBufferReadAvailable ();
AdvanceRingBufferReadIndex (n_values);
return n_values;
}
};
#endif

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>widget</class>
<widget class="QDialog" name="widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>230</width>
<height>195</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QPushButton" name="connectButton">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>131</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>connect</string>
</property>
</widget>
<widget class="QLineEdit" name="hostLineEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>131</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="state">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>131</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="terminateButton">
<property name="geometry">
<rect>
<x>150</x>
<y>10</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>quit</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,41 @@
# http://tim.klingt.org/code/projects/supernova/repository/revisions/d336dd6f400e381bcfd720e96139656de0c53b6a/entry/cmake_modules/FindFFTW3f.cmake
# Modified to use pkg config and use standard var names
# Find single-precision (float) version of FFTW3
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(PC_FFTW3F "fftw3f >= 3.0")
FIND_PATH(
FFTW3F_INCLUDE_DIRS
NAMES fftw3.h
HINTS $ENV{FFTW3_DIR}/include
${PC_FFTW3F_INCLUDE_DIR}
PATHS /usr/local/include
/usr/include
)
FIND_LIBRARY(
FFTW3F_LIBRARIES
NAMES fftw3f libfftw3f
HINTS $ENV{FFTW3_DIR}/lib
${PC_FFTW3F_LIBDIR}
PATHS /usr/local/lib
/usr/lib
/usr/lib64
)
FIND_LIBRARY(
FFTW3F_THREADS_LIBRARIES
NAMES fftw3f_threads libfftw3f_threads
HINTS $ENV{FFTW3_DIR}/lib
${PC_FFTW3F_LIBDIR}
PATHS /usr/local/lib
/usr/lib
/usr/lib64
)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFTW3F DEFAULT_MSG FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIRS)
MARK_AS_ADVANCED(FFTW3F_LIBRARIES FFTW3F_INCLUDE_DIRS FFTW3F_THREADS_LIBRARIES)

View File

@@ -0,0 +1,34 @@
# Try to find FAAD library and include path.
# Once done this will define
#
# FAAD_INCLUDE_DIRS - where to find faad.h, etc.
# FAAD_LIBRARIES - List of libraries when using libfaad.
# FAAD_FOUND - True if libfaad found.
find_path(FAAD_INCLUDE_DIR faad.h DOC "The directory where faad.h resides")
find_library(FAAD_LIBRARY NAMES faad DOC "The libfaad library")
if(FAAD_INCLUDE_DIR AND FAAD_LIBRARY)
set(FAAD_FOUND 1)
set(FAAD_LIBRARIES ${FAAD_LIBRARY})
set(FAAD_INCLUDE_DIRS ${FAAD_INCLUDE_DIR})
else(FAAD_INCLUDE_DIR AND FAAD_LIBRARY)
set(FAAD_FOUND 0)
set(FAAD_LIBRARIES)
set(FAAD_INCLUDE_DIRS)
endif(FAAD_INCLUDE_DIR AND FAAD_LIBRARY)
mark_as_advanced(FAAD_INCLUDE_DIR)
mark_as_advanced(FAAD_LIBRARY)
mark_as_advanced(FAAD_FOUND)
if(NOT FAAD_FOUND)
set(FAAD_DIR_MESSAGE "libfaad was not found. Make sure FAAD_LIBRARY and FAAD_INCLUDE_DIR are set.")
if(NOT FAAD_FIND_QUIETLY)
message(STATUS "${FAAD_DIR_MESSAGE}")
else(NOT FAAD_FIND_QUIETLY)
if(FAAD_FIND_REQUIRED)
message(FATAL_ERROR "${FAAD_DIR_MESSAGE}")
endif(FAAD_FIND_REQUIRED)
endif(NOT FAAD_FIND_QUIETLY)
endif(NOT FAAD_FOUND)

View File

@@ -0,0 +1,28 @@
if(NOT LIBAIRSPY_FOUND)
pkg_check_modules (LIBAIRSPY_PKG libairspy)
find_path(LIBAIRSPY_INCLUDE_DIR NAMES libairspy/airspy.h
PATHS
${LIBAIRSPY_PKG_INCLUDE_DIRS}
/usr/include
/usr/local/include
)
find_library(LIBAIRSPY_LIBRARIES NAMES airspy
PATHS
${LIBAIRSPY_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)
if(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
set(LIBAIRSPY_FOUND TRUE CACHE INTERNAL "libairspy found")
message(STATUS "Found libairspy: ${LIBAIRSPY_INCLUDE_DIR}, ${LIBAIRSPY_LIBRARIES}")
else(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
set(LIBAIRSPY_FOUND FALSE CACHE INTERNAL "libairspy found")
message(STATUS "libairspy not found.")
endif(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
mark_as_advanced(LIBAIRSPY_INCLUDE_DIR LIBAIRSPY_LIBRARIES)
endif(NOT LIBAIRSPY_FOUND)

View File

@@ -0,0 +1,28 @@
if(NOT LIBRTLSDR_FOUND)
pkg_check_modules (LIBRTLSDR_PKG librtlsdr)
find_path(LIBRTLSDR_INCLUDE_DIR NAMES rtl-sdr.h
PATHS
${LIBRTLSDR_PKG_INCLUDE_DIRS}
/usr/include
/usr/local/include
)
find_library(LIBRTLSDR_LIBRARIES NAMES rtlsdr
PATHS
${LIBRTLSDR_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)
if(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
set(LIBRTLSDR_FOUND TRUE CACHE INTERNAL "librtlsdr found")
message(STATUS "Found librtlsdr: ${LIBRTLSDR_INCLUDE_DIR}, ${LIBRTLSDR_LIBRARIES}")
else(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
set(LIBRTLSDR_FOUND FALSE CACHE INTERNAL "librtlsdr found")
message(STATUS "librtlsdr not found.")
endif(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
mark_as_advanced(LIBRTLSDR_INCLUDE_DIR LIBRTLSDR_LIBRARIES)
endif(NOT LIBRTLSDR_FOUND)

View File

@@ -0,0 +1,20 @@
# Find libsamplerate
FIND_PATH(LIBSAMPLERATE_INCLUDE_DIR samplerate.h)
SET(LIBSAMPLERATE_NAMES ${LIBSAMPLERATE_NAMES} samplerate libsamplerate)
FIND_LIBRARY(LIBSAMPLERATE_LIBRARY NAMES ${LIBSAMPLERATE_NAMES} PATH)
IF (LIBSAMPLERATE_INCLUDE_DIR AND LIBSAMPLERATE_LIBRARY)
SET(LIBSAMPLERATE_FOUND TRUE)
ENDIF (LIBSAMPLERATE_INCLUDE_DIR AND LIBSAMPLERATE_LIBRARY)
IF (LIBSAMPLERATE_FOUND)
IF (NOT LibSampleRate_FIND_QUIETLY)
MESSAGE (STATUS "Found LibSampleRate: ${LIBSNDFILE_LIBRARY}")
ENDIF (NOT LibSampleRate_FIND_QUIETLY)
ELSE (LIBSAMPLERATE_FOUND)
IF (LibSampleRate_FIND_REQUIRED)
MESSAGE (FATAL_ERROR "Could not find samplerate")
ENDIF (LibSampleRate_FIND_REQUIRED)
ENDIF (LIBSAMPLERATE_FOUND)

View File

@@ -0,0 +1,20 @@
# Find libsndfile
FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h)
SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile)
FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH)
IF (LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
SET(LIBSNDFILE_FOUND TRUE)
ENDIF (LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY)
IF (LIBSNDFILE_FOUND)
IF (NOT LibSndFile_FIND_QUIETLY)
MESSAGE (STATUS "Found LibSndFile: ${LIBSNDFILE_LIBRARY}")
ENDIF (NOT LibSndFile_FIND_QUIETLY)
ELSE (LIBSNDFILE_FOUND)
IF (LibSndFile_FIND_REQUIRED)
MESSAGE (FATAL_ERROR "Could not find sndfile")
ENDIF (LibSndFile_FIND_REQUIRED)
ENDIF (LIBSNDFILE_FOUND)

View File

@@ -0,0 +1,52 @@
# - Try to find Portaudio
# Once done this will define
#
# PORTAUDIO_FOUND - system has Portaudio
# PORTAUDIO_INCLUDE_DIRS - the Portaudio include directory
# PORTAUDIO_LIBRARIES - Link these to use Portaudio
include(FindPkgConfig)
pkg_check_modules(PC_PORTAUDIO portaudio-2.0)
find_path(PORTAUDIO_INCLUDE_DIRS
NAMES
portaudio.h
PATHS
/usr/local/include
/usr/include
HINTS
${PC_PORTAUDIO_INCLUDEDIR}
)
find_library(PORTAUDIO_LIBRARIES
NAMES
portaudio
PATHS
/usr/local/lib
/usr/lib
/usr/lib64
HINTS
${PC_PORTAUDIO_LIBDIR}
)
mark_as_advanced(PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
# Found PORTAUDIO, but it may be version 18 which is not acceptable.
if(EXISTS ${PORTAUDIO_INCLUDE_DIRS}/portaudio.h)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES_SAVED ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES ${PORTAUDIO_INCLUDE_DIRS})
CHECK_CXX_SOURCE_COMPILES(
"#include <portaudio.h>\nPaDeviceIndex pa_find_device_by_name(const char *name); int main () {return 0;}"
PORTAUDIO2_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVED})
unset(CMAKE_REQUIRED_INCLUDES_SAVED)
if(PORTAUDIO2_FOUND)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PORTAUDIO DEFAULT_MSG PORTAUDIO_INCLUDE_DIRS PORTAUDIO_LIBRARIES)
else(PORTAUDIO2_FOUND)
message(STATUS
" portaudio.h not compatible (requires API 2.0)")
set(PORTAUDIO_FOUND FALSE)
endif(PORTAUDIO2_FOUND)
endif()

View File

@@ -0,0 +1,64 @@
# - try to find Qwt libraries and include files
# QWT_INCLUDE_DIR where to find qwt_global.h, etc.
# QWT_LIBRARIES libraries to link against
# QWT_FOUND If false, do not try to use Qwt
# qwt_global.h holds a string with the QWT version;
# test to make sure it's at least 5.2
find_path(QWT_INCLUDE_DIRS
NAMES qwt_global.h
HINTS
${CMAKE_INSTALL_PREFIX}/include/qwt
PATHS
/usr/local/include/qwt-qt4
/usr/local/include/qwt
/usr/include/qwt6
/usr/include/qwt-qt4
/usr/include/qwt-qt4
/usr/include/qwt
/usr/include/qwt5
/usr/include/qwt6-qt5
/opt/local/include/qwt
/sw/include/qwt
/usr/local/lib/qwt.framework/Headers
)
find_library (QWT_LIBRARIES
NAMES qwt6 qwt6-qt5 qwt-qt5 qwt6-qt4 qwt qwt-qt4
HINTS
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib64
PATHS
/usr/local/lib
/usr/lib
/opt/local/lib
/sw/lib
/usr/local/lib/qwt.framework
)
set(QWT_FOUND FALSE)
if(QWT_INCLUDE_DIRS)
file(STRINGS "${QWT_INCLUDE_DIRS}/qwt_global.h"
QWT_STRING_VERSION REGEX "QWT_VERSION_STR")
set(QWT_WRONG_VERSION True)
set(QWT_VERSION "No Version")
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" QWT_VERSION ${QWT_STRING_VERSION})
string(COMPARE LESS ${QWT_VERSION} "5.2.0" QWT_WRONG_VERSION)
string(COMPARE GREATER ${QWT_VERSION} "6.2.0" QWT_WRONG_VERSION)
message(STATUS "QWT Version: ${QWT_VERSION}")
if(NOT QWT_WRONG_VERSION)
set(QWT_FOUND TRUE)
else(NOT QWT_WRONG_VERSION)
message(STATUS "QWT Version must be >= 5.2 and <= 6.2.0, Found ${QWT_VERSION}")
endif(NOT QWT_WRONG_VERSION)
endif(QWT_INCLUDE_DIRS)
if(QWT_FOUND)
# handle the QUIETLY and REQUIRED arguments and set QWT_FOUND to TRUE if
# all listed variables are TRUE
include ( FindPackageHandleStandardArgs )
find_package_handle_standard_args( Qwt DEFAULT_MSG QWT_LIBRARIES QWT_INCLUDE_DIRS )
MARK_AS_ADVANCED(QWT_LIBRARIES QWT_INCLUDE_DIRS)
endif(QWT_FOUND)

View File

@@ -0,0 +1,20 @@
# Find zlib
FIND_PATH(ZLIB_INCLUDE_DIR zlib.h)
SET(ZLIB_NAMES ${ZLIB_NAMES} libz z)
FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} PATH)
IF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
SET(ZLIB_FOUND TRUE)
ENDIF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
IF (ZLIB_FOUND)
IF (NOT zlib_FIND_QUIETLY)
MESSAGE (STATUS "Found zlib: ${ZLIBFILE_LIBRARY}")
ENDIF (NOT zlib_FIND_QUIETLY)
ELSE (ZLIB_FOUND)
IF (zlib_FIND_REQUIRED)
MESSAGE (FATAL_ERROR "Could not find zlib")
ENDIF (zlib_FIND_REQUIRED)
ENDIF (ZLIB_FOUND)

View File

@@ -0,0 +1,21 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)

63
example-5/filesink.cpp Normal file
View File

@@ -0,0 +1,63 @@
#
/*
* Copyright (C) 2009, 2010, 2011
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the main program for the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include "filesink.h"
fileSink::fileSink (std::string fileName, bool *success) {
if (fileName == "-") { // stdout
outputFile = stdout;
*success = true;
}
else {
outputFile = fopen (fileName. c_str (), "w+b");
*success = outputFile != NULL;
}
audioOK = *success;
}
fileSink::~fileSink (void) {
if (audioOK)
fclose (outputFile);
}
void fileSink::stop (void) {
}
void fileSink::restart (void) {
}
void fileSink::audioOutput (float *buffer, int32_t amount) {
if (audioOK) {
int16_t localBuffer [2 * amount];
int16_t i;
for (i = 0; i < amount; i ++) {
localBuffer [2 * i ] = buffer [2 * i] * 32767;
localBuffer [2 * i + 1] = buffer [2 * i + 1] * 32767;
}
fwrite (localBuffer, 2 * sizeof (int16_t), amount, outputFile);
}
}

45
example-5/filesink.h Normal file
View File

@@ -0,0 +1,45 @@
#
/*
* Copyright (C) 2009, 2010, 2011
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the main program for the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __FILE_SINK__
#define __FILE_SINK__
#include <stdio.h>
#include "audio-base.h"
#include "ringbuffer.h"
#include <string>
class fileSink : public audioBase {
public:
fileSink (std::string, bool *);
~fileSink (void);
void stop (void);
void restart (void);
private:
void audioOutput (float *, int32_t);
FILE *outputFile;
bool audioOK;
};
#endif

550
example-5/main.cpp Normal file
View File

@@ -0,0 +1,550 @@
/*
* Copyright (C) 2015, 2016, 2017
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the DAB-library
*
* DAB-library 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 2 of the License, or
* (at your option) any later version.
*
* DAB-library 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 DAB-library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* E X A M P L E P R O G R A M
* for the DAB-library
*/
#include <unistd.h>
#include <signal.h>
#include <getopt.h>
#include <cstdio>
#include <iostream>
#include "audiosink.h"
#include "filesink.h"
#include "dab-class.h"
#include "band-handler.h"
#ifdef HAVE_SDRPLAY
#include "sdrplay-handler.h"
#elif HAVE_AIRSPY
#include "airspy-handler.h"
#elif HAVE_RTLSDR
#include "rtlsdr-handler.h"
#elif HAVE_WAVFILES
#include "wavfiles.h"
#elif HAVE_RTL_TCP
#include "rtl_tcp-client.h"
#endif
#include <atomic>
#include <thread>
#ifdef DATA_STREAMER
#include "tcp-server.h"
#endif
using std::cerr;
using std::endl;
void printOptions (void); // forward declaration
void listener (void);
// we deal with some callbacks, so we have some data that needs
// to be accessed from global contexts
static
std::atomic<bool> run;
static
dabClass *theRadio = NULL;
static
std::atomic<bool>timeSynced;
static
std::atomic<bool>timesyncSet;
static
std::atomic<bool>ensembleRecognized;
static
audioBase *soundOut = NULL;
#ifdef DATA_STREAMER
tcpServer tdcServer (8888);
#endif
std::string programName = "Classic FM";
int32_t serviceIdentifier = -1;
static void sighandler (int signum) {
fprintf (stderr, "Signal caught, terminating!\n");
run. store (false);
}
static
void syncsignalHandler (bool b, void *userData) {
timeSynced. store (b);
timesyncSet. store (true);
(void)userData;
}
//
// This function is called whenever the dab engine has taken
// some time to gather information from the FIC bloks
// the Boolean b tells whether or not an ensemble has been
// recognized, the names of the programs are in the
// ensemble
static
void ensemblenameHandler (std::string name, int Id, void *userData) {
fprintf (stderr, "ensemble %s is (%X) recognized\n",
name. c_str (), (uint32_t)Id);
ensembleRecognized. store (true);
}
std::vector<std::string> programNames;
std::vector<int> programSIds;
static
void programnameHandler (std::string s, int SId, void *userdata) {
for (std::vector<std::string>::iterator it = programNames.begin();
it != programNames. end(); ++it)
if (*it == s)
return;
programNames. push_back (s);
programSIds . push_back (SId);
fprintf (stderr, "program %s is part of the ensemble\n", s. c_str ());
}
static
void programdataHandler (audiodata *d, void *ctx) {
(void)ctx;
fprintf (stderr, "\tstartaddress\t= %d\n", d -> startAddr);
fprintf (stderr, "\tlength\t\t= %d\n", d -> length);
fprintf (stderr, "\tsubChId\t\t= %d\n", d -> subchId);
fprintf (stderr, "\tprotection\t= %d\n", d -> protLevel);
fprintf (stderr, "\tbitrate\t\t= %d\n", d -> bitRate);
}
//
// The function is called from within the library with
// a string, the so-called dynamic label
static
void dataOut_Handler (std::string dynamicLabel, void *ctx) {
(void)ctx;
// fprintf (stderr, "%s\n", dynamicLabel. c_str ());
}
//
// Note: the function is called from the tdcHandler with a
// frame, either frame 0 or frame 1.
// The frames are packed bytes, here an additional header
// is added, a header of 8 bytes:
// the first 4 bytes for a pattern 0xFF 0x00 0xFF 0x00 0xFF
// the length of the contents, i.e. framelength without header
// is stored in bytes 5 (high byte) and byte 6.
// byte 7 contains 0x00, byte 8 contains 0x00 for frametype 0
// and 0xFF for frametype 1
// Note that the callback function is executed in the thread
// that executes the tdcHandler code.
static
void bytesOut_Handler (uint8_t *data, int16_t amount,
uint8_t type, void *ctx) {
#ifdef DATA_STREAMER
uint8_t localBuf [amount + 8];
int16_t i;
localBuf [0] = 0xFF;
localBuf [1] = 0x00;
localBuf [2] = 0xFF;
localBuf [3] = 0x00;
localBuf [4] = (amount >> 8) & 0xFF;
localBuf [5] = amount & 0xFF;
localBuf [6] = 0x00;
localBuf [7] = type == 0 ? 0 : 0xFF;
for (i = 0; i < amount; i ++)
localBuf [8 + i] = data;
tdcServer. sendData (localBuf, amount + 8);
#else
(void)data;
(void)amount;
#endif
(void)ctx;
}
//
// This function is overloaded. In the normal form it
// handles a buffer full of PCM samples. We pass them on to the
// audiohandler, based on portaudio. Feel free to modify this
// and send the samples elsewhere
//
// However, in the "special mode", the aac frames are send out
// Obviously, the parameters "rate" and "isStereo" are meaningless
// then.
static
void pcmHandler (int16_t *buffer, int size, int rate,
bool isStereo, void *ctx) {
static bool isStarted = false;
(void)isStereo;
if (!isStarted) {
soundOut -> restart ();
isStarted = true;
}
soundOut -> audioOut (buffer, size, rate);
}
static
void systemData (bool flag, int16_t snr, int32_t freqOff, void *ctx) {
// fprintf (stderr, "synced = %s, snr = %d, offset = %d\n",
// flag? "on":"off", snr, freqOff);
}
static
void fibQuality (int16_t q, void *ctx) {
// fprintf (stderr, "fic quality = %d\n", q);
}
static
void mscQuality (int16_t fe, int16_t rsE, int16_t aacE, void *ctx) {
// fprintf (stderr, "msc quality = %d %d %d\n", fe, rsE, aacE);
}
int main (int argc, char **argv) {
// Default values
uint8_t theMode = 1;
std::string theChannel = "11C";
uint8_t theBand = BAND_III;
int16_t ppmCorrection = 0;
int theGain = 35; // scale = 0 .. 100
std::string soundChannel = "default";
int16_t latency = 10;
int16_t waitingTime = 10;
bool autogain = false;
int opt;
struct sigaction sigact;
bandHandler dabBand;
deviceHandler *theDevice;
#ifdef HAVE_WAVFILES
std::string fileName;
#elif HAVE_RTL_TCP
std::string hostname = "127.0.0.1"; // default
int32_t basePort = 1234; // default
#endif
bool err;
fprintf (stderr, "dab_cmdline V 1.0alfa example 5,\n \
Copyright 2017 J van Katwijk, Lazy Chair Computing\n");
timeSynced. store (false);
timesyncSet. store (false);
run. store (false);
if (argc == 1) {
printOptions ();
exit (1);
}
// For file input we do not need options like Q, G and C,
// We do need an option to specify the filename
#ifndef HAVE_WAVFILES
while ((opt = getopt (argc, argv, "W:M:B:C:P:G:A:L:S:QO:")) != -1) {
#elif HAVE_RTL_TCP
while ((opt = getopt (argc, argv, "W:M:B:C:P:G:A:L:S:H:I:QO:")) != -1) {
#else
while ((opt = getopt (argc, argv, "W:M:B:P:A:L:S:F:O:")) != -1) {
#endif
fprintf (stderr, "opt = %c\n", opt);
switch (opt) {
case 'W':
waitingTime = atoi (optarg);
break;
case 'M':
theMode = atoi (optarg);
if (!(theMode == 1) || (theMode == 2) || (theMode == 4))
theMode = 1;
break;
case 'B':
theBand = std::string (optarg) == std::string ("L_BAND") ?
L_BAND : BAND_III;
break;
case 'P':
programName = optarg;
break;
case 'p':
ppmCorrection = atoi (optarg);
break;
#ifdef HAVE_WAVFILES
case 'F':
fileName = std::string (optarg);
break;
#else
case 'C':
theChannel = std::string (optarg);
break;
case 'G':
theGain = atoi (optarg);
break;
case 'Q':
autogain = true;
break;
#ifdef HAVE_RTL_TCP
case 'H':
hostname = std::string (optarg);
break;
case 'I':
basePort = atoi (optarg);
break;
#endif
#endif
case 'O':
soundOut = new fileSink (std::string (optarg), &err);
if (!err) {
fprintf (stderr, "sorry, could not open file\n");
exit (32);
}
break;
case 'A':
soundChannel = optarg;
break;
case 'L':
latency = atoi (optarg);
break;
case 'S': {
std::stringstream ss;
ss << std::hex << optarg;
ss >> serviceIdentifier;
break;
}
default:
printOptions ();
exit (1);
}
}
//
sigact.sa_handler = sighandler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
int32_t frequency = dabBand. Frequency (theBand, theChannel);
try {
#ifdef HAVE_SDRPLAY
theDevice = new sdrplayHandler (frequency,
ppmCorrection,
theGain,
autogain,
0,
0);
#elif HAVE_AIRSPY
theDevice = new airspyHandler (frequency,
ppmCorrection,
theGain);
#elif HAVE_RTLSDR
theDevice = new rtlsdrHandler (frequency,
ppmCorrection,
theGain,
autogain);
#elif HAVE_WAVFILES
theDevice = new wavFiles (fileName);
#elif HAVE_RTL_TCP
theDevice = new rtl_tcp_client (hostname,
basePort,
frequency,
theGain,
autogain,
ppmCorrection);
#endif
}
catch (int e) {
fprintf (stderr, "allocating device failed (%d), fatal\n", e);
exit (32);
}
//
if (soundOut == NULL) { // not bound to a file?
soundOut = new audioSink (latency, soundChannel, &err);
if (err) {
fprintf (stderr, "no valid sound channel, fatal\n");
exit (33);
}
}
//
// and with a sound device we can create a "backend"
theRadio = new dabClass (theDevice,
theMode,
NULL, // no spectrum shown
NULL, // no constellations
syncsignalHandler,
systemData,
ensemblenameHandler,
programnameHandler,
fibQuality,
pcmHandler,
dataOut_Handler,
bytesOut_Handler,
programdataHandler,
mscQuality,
NULL
);
if (theRadio == NULL) {
fprintf (stderr, "sorry, no radio available, fatal\n");
exit (4);
}
theDevice -> setGain (theGain);
if (autogain)
theDevice -> set_autogain (autogain);
theDevice -> setVFOFrequency (frequency);
theDevice -> restartReader ();
//
// The device should be working right now
timesyncSet. store (false);
ensembleRecognized. store (false);
theRadio -> startProcessing ();
int timeOut = 0;
// while (!timesyncSet. load () && (++timeOut < 5))
while (++timeOut < waitingTime)
sleep (1);
if (!timeSynced. load ()) {
cerr << "There does not seem to be a DAB signal here" << endl;
theDevice -> stopReader ();
sleep (1);
theRadio -> stop ();
delete theRadio;
delete theDevice;
exit (22);
}
else
cerr << "there might be a DAB signal here" << endl;
if (!ensembleRecognized. load ())
while (!ensembleRecognized. load () && (++timeOut < waitingTime)) {
fprintf (stderr, "%d\r", waitingTime - timeOut);
sleep (1);
}
fprintf (stderr, "\n");
if (!ensembleRecognized. load ()) {
fprintf (stderr, "no ensemble data found, fatal\n");
theDevice -> stopReader ();
sleep (1);
theRadio -> reset ();
delete theRadio;
delete theDevice;
exit (22);
}
run. store (true);
std::thread keyboard_listener = std::thread (&listener);
if (serviceIdentifier != -1)
programName = theRadio -> dab_getserviceName (serviceIdentifier);
fprintf (stderr, "we try to start program %s\n",
programName. c_str ());
if (theRadio -> dab_service (programName) < 0) {
fprintf (stderr, "sorry we cannot handle service %s\n",
programName. c_str ());
run. store (false);
}
while (run. load ())
sleep (1);
theDevice -> stopReader ();
theRadio -> reset ();
delete theRadio;
delete theDevice;
delete soundOut;
}
void printOptions (void) {
fprintf (stderr,
" dab-cmdline options are\n\
-W number amount of time to look for an ensemble\n\
-M Mode Mode is 1, 2 or 4. Default is Mode 1\n\
-B Band Band is either L_BAND or BAND_III (default)\n\
-P name program to be selected in the ensemble\n\
-C channel channel to be used\n\
-G Gain gain for device (range 1 .. 100)\n\
-Q if set, set autogain for device true\n\
-F filename in case the input is from file\n\
-A name select the audio channel (portaudio)\n\
-L number latency for audiobuffer\n\
-S hexnumber use hexnumber to identify program\n\n\
-O filename put the output into a file rather than through portaudio\n");
}
bool matches (std::string s1, std::string s2) {
const char *ss1 = s1. c_str ();
const char *ss2 = s2. c_str ();
while ((*ss1 != 0) && (*ss2 != 0)) {
if (*ss2 != *ss1)
return false;
ss1 ++;
ss2 ++;
}
return *ss2 == 0;
}
void selectNext (void) {
int16_t i;
int16_t foundIndex = -1;
for (i = 0; i < programNames. size (); i ++) {
if (matches (programNames [i], programName)) {
if (i == programNames. size () - 1)
foundIndex = 0;
else
foundIndex = i + 1;
break;
}
}
if (foundIndex == -1) {
fprintf (stderr, "system error\n");
sighandler (9);
}
// skip the data services. Slightly dangerous here, may be
// add a guard for "only data services" ensembles
while (!theRadio -> is_audioService (programNames [foundIndex]))
foundIndex = (foundIndex + 1) % programNames. size ();
programName = programNames [foundIndex];
fprintf (stderr, "we now try to start program %s\n",
programName. c_str ());
if (theRadio -> dab_service (programName) < 0) {
fprintf (stderr, "sorry we cannot handle service %s\n",
programName. c_str ());
sighandler (9);
}
}
void listener (void) {
fprintf (stderr, "listener is running\n");
while (run. load ()) {
char t = getchar ();
switch (t) {
case '\n': selectNext ();
break;
default:
fprintf (stderr, "unidentified %d (%c)\n", t, t);
}
}
}

View File

@@ -0,0 +1,85 @@
#
/*
* Copyright (C) 2011, 2012, 2013
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the main program of the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "newconverter.h"
newConverter::newConverter (int32_t inRate, int32_t outRate,
int32_t inSize) {
int err;
this -> inRate = inRate;
this -> outRate = outRate;
inputLimit = inSize;
ratio = double(outRate) / inRate;
// fprintf (stderr, "ratio = %f\n", ratio);
outputLimit = inSize * ratio;
converter = src_new (SRC_SINC_BEST_QUALITY, 2, &err);
// converter = src_new (SRC_LINEAR, 2, &err);
// converter = src_new (SRC_SINC_MEDIUM_QUALITY, 2, &err);
src_data = new SRC_DATA;
inBuffer = new float [2 * inputLimit + 20];
outBuffer = new float [2 * outputLimit + 20];
src_data-> data_in = inBuffer;
src_data-> data_out = outBuffer;
src_data-> src_ratio = ratio;
src_data-> end_of_input = 0;
inp = 0;
}
newConverter::~newConverter (void) {
src_delete (converter);
delete [] inBuffer;
delete [] outBuffer;
delete src_data;
}
bool newConverter::convert (DSPCOMPLEX v,
DSPCOMPLEX *out, int32_t *amount) {
int32_t i;
int32_t framesOut;
int res;
inBuffer [2 * inp] = real (v);
inBuffer [2 * inp + 1] = imag (v);
inp ++;
if (inp < inputLimit)
return false;
src_data -> input_frames = inp;
src_data -> output_frames = outputLimit + 10;
res = src_process (converter, src_data);
if (res != 0) {
fprintf (stderr, "error %s\n", src_strerror (res));
return false;
}
inp = 0;
framesOut = src_data -> output_frames_gen;
for (i = 0; i < framesOut; i ++)
out [i] = DSPCOMPLEX (outBuffer [2 * i], outBuffer [2 * i + 1]);
*amount = framesOut;
return true;
}
int32_t newConverter::getOutputsize (void) {
return outputLimit;
}

64
example-5/newconverter.h Normal file
View File

@@ -0,0 +1,64 @@
#
/*
* Copyright (C) 2011, 2012, 2013
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the main program of the DAB library
*
* DAB library 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 2 of the License, or
* (at your option) any later version.
*
* DAB library 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 DAB library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __NEW_CONVERTER__
#define __NEW_CONVERTER__
#include <math.h>
#include <complex>
#include <stdint.h>
#include <unistd.h>
#include <limits>
#include <samplerate.h>
typedef float DSPFLOAT;
typedef std::complex<DSPFLOAT> DSPCOMPLEX;
using namespace std;
class newConverter {
private:
int32_t inRate;
int32_t outRate;
double ratio;
int32_t outputLimit;
int32_t inputLimit;
SRC_STATE *converter;
SRC_DATA *src_data;
float *inBuffer;
float *outBuffer;
int32_t inp;
public:
newConverter (int32_t inRate, int32_t outRate,
int32_t inSize);
~newConverter (void);
bool convert (DSPCOMPLEX v,
DSPCOMPLEX *out, int32_t *amount);
int32_t getOutputsize (void);
};
#endif

321
example-5/ringbuffer.h Normal file
View File

@@ -0,0 +1,321 @@
#
/*
* $Id: pa_ringbuffer.c 1738 2011-08-18 11:47:28Z rossb $
* Portable Audio I/O Library
* Ring Buffer utility.
*
* Author: Phil Burk, http://www.softsynth.com
* modified for SMP safety on Mac OS X by Bjorn Roche
* modified for SMP safety on Linux by Leland Lucius
* also, allowed for const where possible
* modified for multiple-byte-sized data elements by Sven Fischer
*
* Note that this is safe only for a single-thread reader and a
* single-thread writer.
*
* This program uses the PortAudio Portable Audio Library.
* For more information see: http://www.portaudio.com
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
*
* Copyright (C) 2008, 2009, 2010
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* The ringbuffer here is a rewrite of the ringbuffer used in the PA code
* All rights remain with their owners
* This file is part of the SDR-J.
* Many of the ideas as implemented in SDR-J are derived from
* other work, made available through the GNU general Public License.
* All copyrights of the original authors are recognized.
*
* SDR-J 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 2 of the License, or
* (at your option) any later version.
*
* SDR-J 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 ESDR; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __RINGBUFFER
#define __RINGBUFFER
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
/*
* a simple ringbuffer, lockfree, however only for a
* single reader and a single writer.
* Mostly used for getting samples from or to the soundcard
*/
#if defined(__APPLE__)
# include <libkern/OSAtomic.h>
/* Here are the memory barrier functions. Mac OS X only provides
full memory barriers, so the three types of barriers are the same,
however, these barriers are superior to compiler-based ones. */
# define PaUtil_FullMemoryBarrier() OSMemoryBarrier()
# define PaUtil_ReadMemoryBarrier() OSMemoryBarrier()
# define PaUtil_WriteMemoryBarrier() OSMemoryBarrier()
#elif defined(__GNUC__)
/* GCC >= 4.1 has built-in intrinsics. We'll use those */
# if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
# define PaUtil_FullMemoryBarrier() __sync_synchronize()
# define PaUtil_ReadMemoryBarrier() __sync_synchronize()
# define PaUtil_WriteMemoryBarrier() __sync_synchronize()
/* as a fallback, GCC understands volatile asm and "memory" to mean it
* should not reorder memory read/writes */
# elif defined( __PPC__ )
# define PaUtil_FullMemoryBarrier() asm volatile("sync":::"memory")
# define PaUtil_ReadMemoryBarrier() asm volatile("sync":::"memory")
# define PaUtil_WriteMemoryBarrier() asm volatile("sync":::"memory")
# elif defined( __i386__ ) || defined( __i486__ ) || defined( __i586__ ) || defined( __i686__ ) || defined( __x86_64__ )
# define PaUtil_FullMemoryBarrier() asm volatile("mfence":::"memory")
# define PaUtil_ReadMemoryBarrier() asm volatile("lfence":::"memory")
# define PaUtil_WriteMemoryBarrier() asm volatile("sfence":::"memory")
# else
# ifdef ALLOW_SMP_DANGERS
# warning Memory barriers not defined on this system or system unknown
# warning For SMP safety, you should fix this.
# define PaUtil_FullMemoryBarrier()
# define PaUtil_ReadMemoryBarrier()
# define PaUtil_WriteMemoryBarrier()
# else
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
# endif
# endif
#else
# ifdef ALLOW_SMP_DANGERS
# warning Memory barriers not defined on this system or system unknown
# warning For SMP safety, you should fix this.
# define PaUtil_FullMemoryBarrier()
# define PaUtil_ReadMemoryBarrier()
# define PaUtil_WriteMemoryBarrier()
# else
# error Memory barriers are not defined on this system. You can still compile by defining ALLOW_SMP_DANGERS, but SMP safety will not be guaranteed.
# endif
#endif
template <class elementtype>
class RingBuffer {
private:
uint32_t bufferSize;
volatile uint32_t writeIndex;
volatile uint32_t readIndex;
uint32_t bigMask;
uint32_t smallMask;
char *buffer;
public:
RingBuffer (uint32_t elementCount) {
if (((elementCount - 1) & elementCount) != 0)
elementCount = 2 * 16384; /* default */
bufferSize = elementCount;
buffer = new char [2 * bufferSize * sizeof (elementtype)];
writeIndex = 0;
readIndex = 0;
smallMask = (elementCount)- 1;
bigMask = (elementCount * 2) - 1;
}
~RingBuffer () {
delete[] buffer;
}
/*
* functions for checking available data for reading and space
* for writing
*/
int32_t GetRingBufferReadAvailable (void) {
return (writeIndex - readIndex) & bigMask;
}
int32_t ReadSpace (void){
return GetRingBufferReadAvailable ();
}
int32_t GetRingBufferWriteAvailable (void) {
return bufferSize - GetRingBufferReadAvailable ();
}
int32_t WriteSpace (void) {
return GetRingBufferWriteAvailable ();
}
void FlushRingBuffer () {
writeIndex = 0;
readIndex = 0;
}
/* ensure that previous writes are seen before we update the write index
(write after write)
*/
int32_t AdvanceRingBufferWriteIndex (int32_t elementCount) {
PaUtil_WriteMemoryBarrier();
return writeIndex = (writeIndex + elementCount) & bigMask;
}
/* ensure that previous reads (copies out of the ring buffer) are
* always completed before updating (writing) the read index.
* (write-after-read) => full barrier
*/
int32_t AdvanceRingBufferReadIndex (int32_t elementCount) {
PaUtil_FullMemoryBarrier();
return readIndex = (readIndex + elementCount) & bigMask;
}
/***************************************************************************
** Get address of region(s) to which we can write data.
** If the region is contiguous, size2 will be zero.
** If non-contiguous, size2 will be the size of second region.
** Returns room available to be written or elementCount, whichever is smaller.
*/
int32_t GetRingBufferWriteRegions (uint32_t elementCount,
void **dataPtr1, int32_t *sizePtr1,
void **dataPtr2, int32_t *sizePtr2 ) {
uint32_t index;
uint32_t available = GetRingBufferWriteAvailable ();
if (elementCount > available)
elementCount = available;
/* Check to see if write is not contiguous. */
index = writeIndex & smallMask;
if ((index + elementCount) > bufferSize ) {
/* Write data in two blocks that wrap the buffer. */
int32_t firstHalf = bufferSize - index;
*dataPtr1 = &buffer[index * sizeof(elementtype)];
*sizePtr1 = firstHalf;
*dataPtr2 = &buffer [0];
*sizePtr2 = elementCount - firstHalf;
}
else { // fits
*dataPtr1 = &buffer [index * sizeof(elementtype)];
*sizePtr1 = elementCount;
*dataPtr2 = NULL;
*sizePtr2 = 0;
}
if (available > 0)
PaUtil_FullMemoryBarrier(); /* (write-after-read) => full barrier */
return elementCount;
}
/***************************************************************************
** Get address of region(s) from which we can read data.
** If the region is contiguous, size2 will be zero.
** If non-contiguous, size2 will be the size of second region.
** Returns room available to be read or elementCount, whichever is smaller.
*/
int32_t GetRingBufferReadRegions (uint32_t elementCount,
void **dataPtr1, int32_t *sizePtr1,
void **dataPtr2, int32_t *sizePtr2) {
uint32_t index;
uint32_t available = GetRingBufferReadAvailable (); /* doesn't use memory barrier */
if (elementCount > available)
elementCount = available;
/* Check to see if read is not contiguous. */
index = readIndex & smallMask;
if ((index + elementCount) > bufferSize) {
/* Write data in two blocks that wrap the buffer. */
int32_t firstHalf = bufferSize - index;
*dataPtr1 = &buffer [index * sizeof(elementtype)];
*sizePtr1 = firstHalf;
*dataPtr2 = &buffer [0];
*sizePtr2 = elementCount - firstHalf;
}
else {
*dataPtr1 = &buffer [index * sizeof(elementtype)];
*sizePtr1 = elementCount;
*dataPtr2 = NULL;
*sizePtr2 = 0;
}
if (available)
PaUtil_ReadMemoryBarrier(); /* (read-after-read) => read barrier */
return elementCount;
}
int32_t putDataIntoBuffer (const void *data, int32_t elementCount) {
int32_t size1, size2, numWritten;
void *data1;
void *data2;
numWritten = GetRingBufferWriteRegions (elementCount,
&data1, &size1,
&data2, &size2 );
if (size2 > 0) {
memcpy (data1, data, size1 * sizeof(elementtype));
data = ((char *)data) + size1 * sizeof(elementtype);
memcpy (data2, data, size2 * sizeof(elementtype));
}
else
memcpy (data1, data, size1 * sizeof(elementtype));
AdvanceRingBufferWriteIndex (numWritten );
return numWritten;
}
int32_t getDataFromBuffer (void *data, int32_t elementCount ) {
int32_t size1, size2, numRead;
void *data1;
void *data2;
numRead = GetRingBufferReadRegions (elementCount,
&data1, &size1,
&data2, &size2 );
if (size2 > 0) {
memcpy (data, data1, size1 * sizeof(elementtype));
data = ((char *)data) + size1 * sizeof(elementtype);
memcpy (data, data2, size2 * sizeof(elementtype));
}
else
memcpy (data, data1, size1 * sizeof(elementtype));
AdvanceRingBufferReadIndex (numRead );
return numRead;
}
int32_t skipDataInBuffer (uint32_t n_values) {
// ensure that we have the correct read and write indices
PaUtil_FullMemoryBarrier ();
if (n_values > GetRingBufferReadAvailable ())
n_values = GetRingBufferReadAvailable ();
AdvanceRingBufferReadIndex (n_values);
return n_values;
}
};
#endif

View File

@@ -0,0 +1,124 @@
#
/*
* Copyright (C) 2016, 2017
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Computing
*
* This file is part of the DAB-library
* DAB-library 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 2 of the License, or
* (at your option) any later version.
*
* DAB-library 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 DAB-library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Simple streaming server, for e.g. epg data and tpg data
*/
#include <stdint.h>
#include <ringbuffer.h>
#include <arpa/inet.h>
#include "tcp-server.h"
tcpServer::tcpServer (int port) {
buffer = new RingBuffer<uint8_t> (32 * 32768);
connected. store (false);
threadHandle = std::thread (&tcpServer::run, this, port);
}
tcpServer::~tcpServer (void) {
if (running. load ()) {
running. store (false);
usleep (1000);
threadHandle. join ();
}
delete buffer;
}
void tcpServer::sendData (uint8_t *data, int32_t amount) {
if (connected)
buffer -> putDataIntoBuffer (data, amount);
}
#define BUF_SIZE 1024
void tcpServer::run (int port) {
// Variables for writing a server.
/*
* 1. Getting the address data structure.
* 2. Opening a new socket.
* 3. Bind to the socket.
* 4. Listen to the socket.
* 5. Accept Connection.
* 6. Receive Data.
* 7. Close Connection.
*/
int socket_desc , client_sock , c , read_size;
struct sockaddr_in server , client;
//Create socket
socket_desc = socket(AF_INET , SOCK_STREAM , 0);
if (socket_desc == -1) {
fprintf (stderr, "Could not create socket");
return;
}
fprintf (stderr, "Socket created");
running. store (true);
// Prepare the sockaddr_in structure
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons (port);
// Bind
if (bind (socket_desc,
(struct sockaddr *)&server , sizeof(server)) < 0) {
// print the error message
perror ("bind failed. Error");
return;
}
fprintf (stderr, "I am now accepting connections ...\n");
// Listen
listen (socket_desc , 3);
while (running) {
// Accept a new connection and return back the socket desciptor
c = sizeof(struct sockaddr_in);
// accept connection from an incoming client
client_sock = accept (socket_desc,
(struct sockaddr *)&client,
(socklen_t*)&c);
if (client_sock < 0) {
perror("accept failed");
return;
}
fprintf (stderr, "Connection accepted");
connected = true;
try {
uint8_t localBuffer [BUF_SIZE];
int16_t amount;
int status;
while (running. load ()) {
while (running. load () &&
(buffer -> GetRingBufferReadAvailable () < BUF_SIZE))
usleep (1000);
amount = buffer -> getDataFromBuffer (localBuffer, BUF_SIZE);
status = send (client_sock, localBuffer, amount ,0);
if (status == -1) {
throw (22);
}
}
}
catch (int e) {}
connected = false;
}
// Close the socket before we finish
close (socket_desc);
running. store (false);
}

View File

@@ -0,0 +1,51 @@
#
/*
* Copyright (C) 2016, 2017
* Jan van Katwijk (J.vanKatwijk@gmail.com)
* Lazy Chair Programming
*
* This file is part of the DAB-library
* DAB-library 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 2 of the License, or
* (at your option) any later version.
*
* DAB-library 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 DAB-library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Simple streaming server, for e.g. epg data and tpg data
*/
#ifndef __TCP_SERVER__
#define __TCP_SERVER__
#include <stdint.h>
#include <ringbuffer.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string>
#include <thread>
#include <unistd.h>
#include <atomic>
class tcpServer {
public:
tcpServer (int);
~tcpServer (void);
void sendData (uint8_t *, int32_t);
void run (int port);
private:
std::thread threadHandle;
RingBuffer<uint8_t> *buffer;
std::atomic<bool> running;
std::atomic<bool> connected;
};
#endif

View File

@@ -69,6 +69,8 @@ public:
std::string dab_getserviceName (int32_t);
int16_t dab_service (std::string);
int32_t dab_getSId (std::string);
bool is_audioService (std::string);
bool is_dataService (std::string);
private:
ficHandler the_ficHandler;
mscHandler the_mscHandler;

View File

@@ -101,12 +101,31 @@ void dabClass::stop (void) {
the_ficHandler. clearEnsemble ();
}
//
//
// The return value > 0, then success,
// otherwise error
bool dabClass::is_audioService (std::string name) {
switch (the_ficHandler. kindofService (name)) {
case AUDIO_SERVICE:
return true;
default:
return false;
}
}
bool dabClass::is_dataService (std::string name) {
switch (the_ficHandler. kindofService (name)) {
case PACKET_SERVICE:
return true;
default:
return false;
}
}
int16_t dabClass::dab_service (std::string name) {
audiodata d1;
packetdata d2;
switch (the_ficHandler. kindofService (name)) {
case AUDIO_SERVICE:
the_ficHandler. dataforAudioService (name, &d1);