30 m_dataAddress(QHostAddress::LocalHost),
31 m_remoteAddress(QHostAddress::LocalHost),
34 m_dataConnected(false),
36 m_nbUDPFrames(m_minNbUDPFrames),
37 m_nbAllocatedUDPFrames(m_minNbUDPFrames),
39 m_readFrameIndex(m_minNbUDPFrames/2),
41 m_rwDelta(m_minNbUDPFrames/2),
43 m_autoRWBalance(true),
44 m_feedbackMessageQueue(0)
46 m_udpBuf =
new udpBlk_t[m_minNbUDPFrames];
47 std::fill(m_udpDump, m_udpDump + m_udpBlockSize + 8192, 0);
48 connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()),
this, SLOT(handleMessages()));
58 qDebug(
"UDPSourceUDPHandler::start");
70 qDebug(
"UDPSourceUDPHandler::start: bind data socket to %s:%d",
m_dataAddress.toString().toStdString().c_str(),
m_dataPort);
76 qWarning(
"UDPSourceUDPHandler::start: cannot bind data socket to %s:%d",
m_dataAddress.toString().toStdString().c_str(),
m_dataPort);
84 qDebug(
"UDPSourceUDPHandler::stop");
103 qint64 pendingDataSize =
m_dataSocket->pendingDatagramSize();
108 qWarning(
"UDPSourceUDPHandler::dataReadyRead: UDP read error");
112 int udpDumpSize = m_udpDumpIndex + bytesRead;
127 m_udpDumpIndex = udpDumpSize;
139 m_writeFrameIndex = 0;
205 if ((d < -0.45) || (d > 0.45))
212 float c = (d / 15.0) + (dd / 20.0);
213 c = c < -0.05 ? -0.05 : c > 0.05 ? 0.05 : c;
235 qDebug(
"UDPSourceUDPHandler::configureUDPLink: %s:%d", address.toStdString().c_str(), port);
240 qWarning(
"UDPSourceUDPHandler::configureUDPLink: invalid address %s. Set to localhost.", address.toStdString().c_str());
261 qDebug(
"UDPSourceUDPHandler::resizeBuffer: nb_frames: %d", 2*halfNbFrames);
266 m_udpBuf =
new udpBlk_t[2*halfNbFrames];
void applyUDPLink(const QString &address, quint16 port)
Message * pop()
Pop message from queue.
void push(Message *message, bool emitSignal=true)
Push message onto queue.
const QString & getAddress() const
static MsgUDPAddressAndPort * create(QString address, quint16 port)
void advanceReadPointer(int nbBytes)
int m_nbAllocatedUDPFrames
void readSample(qint16 &t)
audio mono
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
void configureUDPLink(const QString &address, quint16 port)
static const int m_minNbUDPFrames
static bool match(const Message *message)
char m_udpDump[m_udpBlockSize+8192]
static MsgSampleRateCorrection * create(float correctionFactor, float rawDeltaRatio)
QHostAddress m_remoteAddress
virtual ~UDPSourceUDPHandler()
MessageQueue m_inputMessageQueue
QUdpSocket * m_dataSocket
QHostAddress m_dataAddress
void resizeBuffer(float sampleRate)
static const int m_udpBlockSize
MessageQueue * m_feedbackMessageQueue
bool handleMessage(const Message &message)
T max(const T &x, const T &y)