mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
HackRF output plugin: corrected sample size
This commit is contained in:
parent
212a8ad2f9
commit
64246c5c6a
@ -7,10 +7,10 @@ if(LIBUSB_FOUND AND LIBBLADERF_FOUND)
|
||||
add_subdirectory(bladerfoutput)
|
||||
endif(LIBUSB_FOUND AND LIBBLADERF_FOUND)
|
||||
|
||||
#find_package(LibHACKRF)
|
||||
#if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
||||
# add_subdirectory(hackrfoutput)
|
||||
#endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
||||
find_package(LibHACKRF)
|
||||
if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
||||
add_subdirectory(hackrfoutput)
|
||||
endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
|
||||
|
||||
if (BUILD_DEBIAN)
|
||||
add_subdirectory(bladerfoutput)
|
||||
|
@ -25,12 +25,10 @@ HackRFOutputThread::HackRFOutputThread(hackrf_device* dev, SampleSourceFifo* sam
|
||||
QThread(parent),
|
||||
m_running(false),
|
||||
m_dev(dev),
|
||||
m_convertBuffer(HACKRF_BLOCKSIZE),
|
||||
m_sampleFifo(sampleFifo),
|
||||
m_samplerate(10),
|
||||
m_log2Interp(0)
|
||||
{
|
||||
qDebug("HackRFOutputThread::HackRFOutputThread: m_dev: %lx m_sampleFifo: %lx", (uint64_t) m_dev, (uint64_t) m_sampleFifo);
|
||||
}
|
||||
|
||||
HackRFOutputThread::~HackRFOutputThread()
|
||||
@ -81,11 +79,6 @@ void HackRFOutputThread::run()
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("HackRFOutputThread::run: this: %lx start HackRF Tx: m_dev: %lx m_sampleFifo: %lx",
|
||||
(uint64_t) this,
|
||||
(uint64_t) m_dev,
|
||||
(uint64_t) m_sampleFifo);
|
||||
|
||||
while ((m_running) && (hackrf_is_streaming(m_dev) == HACKRF_TRUE))
|
||||
{
|
||||
sleep(1);
|
||||
@ -107,37 +100,37 @@ void HackRFOutputThread::run()
|
||||
}
|
||||
|
||||
// Interpolate according to specified log2 (ex: log2=4 => interp=16)
|
||||
void HackRFOutputThread::callback(qint16* buf, qint32 len)
|
||||
void HackRFOutputThread::callback(qint8* buf, qint32 len)
|
||||
{
|
||||
SampleVector::iterator beginRead;
|
||||
m_sampleFifo->readAdvance(beginRead, len/(1<<m_log2Interp));
|
||||
beginRead -= len;
|
||||
m_sampleFifo->readAdvance(beginRead, len/(2*(1<<m_log2Interp)));
|
||||
beginRead -= len/2;
|
||||
|
||||
if (m_log2Interp == 0)
|
||||
{
|
||||
m_interpolators.interpolate1(&beginRead, buf, len*2);
|
||||
m_interpolators.interpolate1(&beginRead, buf, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (m_log2Interp)
|
||||
{
|
||||
case 1:
|
||||
m_interpolators.interpolate2_cen(&beginRead, buf, len*2);
|
||||
m_interpolators.interpolate2_cen(&beginRead, buf, len);
|
||||
break;
|
||||
case 2:
|
||||
m_interpolators.interpolate4_cen(&beginRead, buf, len*2);
|
||||
m_interpolators.interpolate4_cen(&beginRead, buf, len);
|
||||
break;
|
||||
case 3:
|
||||
m_interpolators.interpolate8_cen(&beginRead, buf, len*2);
|
||||
m_interpolators.interpolate8_cen(&beginRead, buf, len);
|
||||
break;
|
||||
case 4:
|
||||
m_interpolators.interpolate16_cen(&beginRead, buf, len*2);
|
||||
m_interpolators.interpolate16_cen(&beginRead, buf, len);
|
||||
break;
|
||||
case 5:
|
||||
m_interpolators.interpolate32_cen(&beginRead, buf, len*2);
|
||||
m_interpolators.interpolate32_cen(&beginRead, buf, len);
|
||||
break;
|
||||
case 6:
|
||||
m_interpolators.interpolate64_cen(&beginRead, buf, len*2);
|
||||
m_interpolators.interpolate64_cen(&beginRead, buf, len);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -148,7 +141,7 @@ void HackRFOutputThread::callback(qint16* buf, qint32 len)
|
||||
int HackRFOutputThread::tx_callback(hackrf_transfer* transfer)
|
||||
{
|
||||
HackRFOutputThread *thread = (HackRFOutputThread *) transfer->tx_ctx;
|
||||
qint32 bytes_to_write = transfer->valid_length;
|
||||
thread->callback((qint16 *) transfer->buffer, bytes_to_write);
|
||||
qint32 bytes_to_write = transfer->valid_length;
|
||||
thread->callback((qint8 *) transfer->buffer, bytes_to_write);
|
||||
return 0;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "dsp/samplesourcefifo.h"
|
||||
#include "dsp/interpolators.h"
|
||||
|
||||
#define HACKRF_BLOCKSIZE (1<<17)
|
||||
#define HACKRF_BLOCKSIZE (1<<18)
|
||||
|
||||
class HackRFOutputThread : public QThread {
|
||||
Q_OBJECT
|
||||
@ -45,17 +45,16 @@ private:
|
||||
bool m_running;
|
||||
|
||||
hackrf_device* m_dev;
|
||||
qint16 m_buf[2*HACKRF_BLOCKSIZE];
|
||||
SampleVector m_convertBuffer;
|
||||
qint8 m_buf[2*HACKRF_BLOCKSIZE];
|
||||
SampleSourceFifo* m_sampleFifo;
|
||||
|
||||
int m_samplerate;
|
||||
unsigned int m_log2Interp;
|
||||
|
||||
Interpolators<qint16, SDR_SAMP_SZ, 12> m_interpolators;
|
||||
Interpolators<qint8, SDR_SAMP_SZ, 8> m_interpolators;
|
||||
|
||||
void run();
|
||||
void callback(qint16* buf, qint32 len);
|
||||
void callback(qint8* buf, qint32 len);
|
||||
static int tx_callback(hackrf_transfer* transfer);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user