mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-18 14:21:49 -05:00
SDRdaemon: dhannel sink: fixed passing data address and port to the thread
This commit is contained in:
parent
0924945579
commit
e067778b78
@ -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
|
||||
|
@ -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_ */
|
||||
|
@ -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,17 +97,22 @@ 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
|
||||
{
|
||||
if (m_socket)
|
||||
{
|
||||
for (int i = 0; i < SDRDaemonNbOrginalBlocks; i++)
|
||||
{
|
||||
// send block via UDP
|
||||
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, m_port);
|
||||
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, dataPort);
|
||||
usleep(txDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cm256Params.BlockBytes = sizeof(SDRDaemonProtectedBlock);
|
||||
@ -141,13 +147,16 @@ bool SDRDaemonChannelSinkThread::handleDataBlock(SDRDaemonDataBlock& dataBlock)
|
||||
}
|
||||
|
||||
// Transmit all blocks
|
||||
if (m_socket)
|
||||
{
|
||||
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, m_port);
|
||||
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, dataPort);
|
||||
usleep(txDelay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dataBlock.m_controlBlock.m_processed = true;
|
||||
return true;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user