HackRF input plugin: pass thread pointer in the callback instead of using a static variable

pull/27/head
f4exb 2017-01-08 10:44:38 +01:00
rodzic 5d51fde9f7
commit 212a8ad2f9
3 zmienionych plików z 6 dodań i 10 usunięć

Wyświetl plik

@ -10,7 +10,7 @@ endif(LIBUSB_FOUND AND LIBBLADERF_FOUND)
#find_package(LibHACKRF)
#if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
# add_subdirectory(hackrfoutput)
3endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
#endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
if (BUILD_DEBIAN)
add_subdirectory(bladerfoutput)

Wyświetl plik

@ -14,14 +14,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "../hackrfinput/hackrfinputthread.h"
#include "hackrfinputthread.h"
#include <stdio.h>
#include <errno.h>
#include "../../../sdrbase/dsp/samplesinkfifo.h"
HackRFInputThread *HackRFInputThread::m_this = 0;
#include "dsp/samplesinkfifo.h"
HackRFInputThread::HackRFInputThread(hackrf_device* dev, SampleSinkFifo* sampleFifo, QObject* parent) :
QThread(parent),
@ -33,13 +31,11 @@ HackRFInputThread::HackRFInputThread(hackrf_device* dev, SampleSinkFifo* sampleF
m_log2Decim(0),
m_fcPos(0)
{
m_this = this;
}
HackRFInputThread::~HackRFInputThread()
{
stopWork();
m_this = 0;
}
void HackRFInputThread::startWork()
@ -82,7 +78,7 @@ void HackRFInputThread::run()
//m_running = true;
m_startWaiter.wakeAll();
rc = (hackrf_error) hackrf_start_rx(m_dev, rx_callback, NULL);
rc = (hackrf_error) hackrf_start_rx(m_dev, rx_callback, this);
if (rc != HACKRF_SUCCESS)
{
@ -207,7 +203,8 @@ void HackRFInputThread::callback(const qint8* buf, qint32 len)
int HackRFInputThread::rx_callback(hackrf_transfer* transfer)
{
HackRFInputThread *thread = (HackRFInputThread *) transfer->rx_ctx;
qint32 bytes_to_write = transfer->valid_length;
m_this->callback((qint8 *) transfer->buffer, bytes_to_write);
thread->callback((qint8 *) transfer->buffer, bytes_to_write);
return 0;
}

Wyświetl plik

@ -53,7 +53,6 @@ private:
int m_samplerate;
unsigned int m_log2Decim;
int m_fcPos;
static HackRFInputThread *m_this;
Decimators<qint8, SDR_SAMP_SZ, 8> m_decimators;