1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-30 16:56:35 -04:00

SDRdaemon: dhannel sink: fixed passing data address and port to the thread

This commit is contained in:
f4exb 2018-08-22 23:16:08 +02:00
parent 0924945579
commit e067778b78
6 changed files with 35 additions and 16 deletions

View File

@ -49,7 +49,9 @@ SDRDaemonChannelSink::SDRDaemonChannelSink(DeviceSourceAPI *deviceAPI) :
m_sampleRate(48000),
m_sampleBytes(SDR_RX_SAMP_SZ == 24 ? 4 : 2),
m_nbBlocksFEC(0),
m_txDelay(100)
m_txDelay(100),
m_dataAddress("127.0.0.1"),
m_dataPort(9090)
{
setObjectName(m_channelId);
@ -170,6 +172,8 @@ void SDRDaemonChannelSink::feed(const SampleVector::const_iterator& begin, const
m_dataBlock->m_controlBlock.m_complete = true;
m_dataBlock->m_controlBlock.m_nbBlocksFEC = m_nbBlocksFEC;
m_dataBlock->m_controlBlock.m_txDelay = m_txDelay;
m_dataBlock->m_controlBlock.m_dataAddress = m_dataAddress;
m_dataBlock->m_controlBlock.m_dataPort = m_dataPort;
m_dataQueue.push(m_dataBlock);
m_dataBlock = new SDRDaemonDataBlock(); // create a new one immediately

View File

@ -64,6 +64,8 @@ public:
void setNbBlocksFEC(int nbBlocksFEC);
void setTxDelay(int txDelay);
void setDataAddress(const QString& address) { m_dataAddress = address; }
void setDataPort(uint16_t port) { m_dataPort = port; }
static const QString m_channelIdURI;
static const QString m_channelId;
@ -92,6 +94,8 @@ private:
uint8_t m_sampleBytes;
int m_nbBlocksFEC;
int m_txDelay;
QString m_dataAddress;
uint16_t m_dataPort;
};
#endif /* SDRDAEMON_CHANNEL_SDRDAEMONCHANNELSINK_H_ */

View File

@ -36,7 +36,7 @@ SDRDaemonChannelSinkThread::SDRDaemonChannelSinkThread(SDRDaemonDataQueue *dataQ
m_dataQueue(dataQueue),
m_cm256(cm256),
m_address(QHostAddress::LocalHost),
m_port(9090)
m_socket(0)
{
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
connect(m_dataQueue, SIGNAL(dataBlockEnqueued()), this, SLOT(handleData()), Qt::QueuedConnection);
@ -68,6 +68,7 @@ void SDRDaemonChannelSinkThread::stopWork()
{
qDebug("SDRDaemonChannelSinkThread::stopWork");
delete m_socket;
m_socket = 0;
m_running = false;
wait();
}
@ -96,15 +97,20 @@ bool SDRDaemonChannelSinkThread::handleDataBlock(SDRDaemonDataBlock& dataBlock)
uint16_t frameIndex = dataBlock.m_controlBlock.m_frameIndex;
int nbBlocksFEC = dataBlock.m_controlBlock.m_nbBlocksFEC;
int txDelay = dataBlock.m_controlBlock.m_txDelay;
m_address.setAddress(dataBlock.m_controlBlock.m_dataAddress);
uint16_t dataPort = dataBlock.m_controlBlock.m_dataPort;
SDRDaemonSuperBlock *txBlockx = dataBlock.m_superBlocks;
if ((nbBlocksFEC == 0) || !m_cm256) // Do not FEC encode
{
for (int i = 0; i < SDRDaemonNbOrginalBlocks; i++)
if (m_socket)
{
// send block via UDP
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, m_port);
usleep(txDelay);
for (int i = 0; i < SDRDaemonNbOrginalBlocks; i++)
{
// send block via UDP
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, dataPort);
usleep(txDelay);
}
}
}
else
@ -141,11 +147,14 @@ bool SDRDaemonChannelSinkThread::handleDataBlock(SDRDaemonDataBlock& dataBlock)
}
// Transmit all blocks
for (int i = 0; i < cm256Params.OriginalCount + cm256Params.RecoveryCount; i++)
if (m_socket)
{
// send block via UDP
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, m_port);
usleep(txDelay);
for (int i = 0; i < cm256Params.OriginalCount + cm256Params.RecoveryCount; i++)
{
// send block via UDP
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, dataPort);
usleep(txDelay);
}
}
}

View File

@ -61,9 +61,6 @@ public:
void startStop(bool start);
void setAddress(QString& address) { m_address.setAddress(address); }
void setPort(unsigned int port) { m_port = port; }
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
@ -73,7 +70,6 @@ private:
CM256 *m_cm256; //!< CM256 library object
QHostAddress m_address;
unsigned int m_port;
QUdpSocket *m_socket;
MessageQueue m_inputMessageQueue;

View File

@ -70,12 +70,12 @@ struct SDRDaemonHeader
uint8_t m_blockIndex;
uint8_t m_filler;
void init()
void init()
{
m_frameIndex = 0;
m_blockIndex = 0;
m_filler = 0;
}
}
};
static const int SDRDaemonUdpSize = UDPSINKFEC_UDPSIZE;
@ -111,6 +111,8 @@ struct SDRDaemonTxControlBlock
uint16_t m_frameIndex;
int m_nbBlocksFEC;
int m_txDelay;
QString m_dataAddress;
uint16_t m_dataPort;
SDRDaemonTxControlBlock() {
m_complete = false;
@ -118,6 +120,8 @@ struct SDRDaemonTxControlBlock
m_frameIndex = 0;
m_nbBlocksFEC = 0;
m_txDelay = 100;
m_dataAddress = "127.0.0.1";
m_dataPort = 9090;
}
};

View File

@ -132,6 +132,8 @@ SDRDaemonMain::SDRDaemonMain(qtwebapp::LoggerWithFile *logger, const SDRDaemonPa
m_channelSink = new SDRDaemonChannelSink(m_deviceSourceAPI);
m_channelSink->setNbBlocksFEC(parser.getNbBlocksFEC());
m_channelSink->setTxDelay(parser.getTxDelay());
m_channelSink->setDataAddress(parser.getDataAddress());
m_channelSink->setDataPort(parser.getDataPort());
}
else
{