add multithreading CONFIG parameter and use thread synchronization
This commit is contained in:
parent
0d5ce4b62b
commit
30c8f462c3
3 changed files with 31 additions and 45 deletions
|
@ -6,12 +6,18 @@ contains(CONFIG, "noupcasename") {
|
||||||
TARGET = jamulus
|
TARGET = jamulus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# support multi-threading with OMP if requested
|
||||||
|
contains(CONFIG, "multithreading") {
|
||||||
|
message(Multithreading in the server is enabled.)
|
||||||
|
DEFINES += USE_MULTITHREADING
|
||||||
|
QT += concurrent
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG += qt \
|
CONFIG += qt \
|
||||||
thread \
|
thread \
|
||||||
release
|
release
|
||||||
|
|
||||||
QT += network \
|
QT += network \
|
||||||
concurrent \
|
|
||||||
xml
|
xml
|
||||||
|
|
||||||
contains(CONFIG, "headless") {
|
contains(CONFIG, "headless") {
|
||||||
|
|
|
@ -979,6 +979,10 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE
|
||||||
|
|
||||||
|
|
||||||
// Process data ------------------------------------------------------------
|
// Process data ------------------------------------------------------------
|
||||||
|
#ifdef USE_MULTITHREADING
|
||||||
|
QFutureSynchronizer<void> FutureSynchronizer;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check if at least one client is connected. If not, stop server until
|
// Check if at least one client is connected. If not, stop server until
|
||||||
// one client is connected.
|
// one client is connected.
|
||||||
if ( iNumClients > 0 )
|
if ( iNumClients > 0 )
|
||||||
|
@ -1055,35 +1059,26 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TEST
|
// generate a separate mix for each channel, OPUS encode the
|
||||||
QFuture<void> future = QtConcurrent::run ( this, &CServer::MixEncodeTransmitData,
|
// audio data and transmit the network packet (note that if
|
||||||
|
// multithreading is enabled, the work is distributed over
|
||||||
|
// all available processor cores)
|
||||||
|
#ifdef USE_MULTITHREADING
|
||||||
|
// by using the future synchronizer we make sure that all
|
||||||
|
// threads are done when we leave the timer callback function
|
||||||
|
FutureSynchronizer.addFuture ( QtConcurrent::run ( this, &CServer::MixEncodeTransmitData,
|
||||||
i,
|
i,
|
||||||
iCurChanID,
|
iCurChanID,
|
||||||
pCurOpusEncoder,
|
pCurOpusEncoder,
|
||||||
iClientFrameSizeSamples,
|
iClientFrameSizeSamples,
|
||||||
iNumClients );
|
iNumClients ) );
|
||||||
|
#else
|
||||||
|
MixEncodeTransmitData ( i,
|
||||||
// generate a separate mix for each channel, OPUS encode the
|
iCurChanID,
|
||||||
// audio data and transmit the network packet
|
|
||||||
/*
|
|
||||||
MixEncodeTransmitData ( vecvecsData,
|
|
||||||
vecvecdGains[i],
|
|
||||||
vecvecdPannings[i],
|
|
||||||
vecNumAudioChannels,
|
|
||||||
vecvecsIntermediateProcBuf[i],
|
|
||||||
vecvecsSendData[i],
|
|
||||||
vecvecbyCodedData[i],
|
|
||||||
vecChannels[iCurChanID],
|
|
||||||
DoubleFrameSizeConvBufOut[iCurChanID],
|
|
||||||
vecUseDoubleSysFraSizeConvBuf[i],
|
|
||||||
vecNumFrameSizeConvBlocks[i],
|
|
||||||
pCurOpusEncoder,
|
pCurOpusEncoder,
|
||||||
iCeltNumCodedBytes,
|
|
||||||
iClientFrameSizeSamples,
|
iClientFrameSizeSamples,
|
||||||
iCurNumAudChan,
|
|
||||||
iNumClients );
|
iNumClients );
|
||||||
*/
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
23
src/server.h
23
src/server.h
|
@ -29,8 +29,11 @@
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QtConcurrent>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#ifdef USE_MULTITHREADING
|
||||||
|
# include <QtConcurrent>
|
||||||
|
# include <QFutureSynchronizer>
|
||||||
|
#endif
|
||||||
#ifdef USE_OPUS_SHARED_LIB
|
#ifdef USE_OPUS_SHARED_LIB
|
||||||
# include "opus/opus_custom.h"
|
# include "opus/opus_custom.h"
|
||||||
#else
|
#else
|
||||||
|
@ -302,24 +305,6 @@ protected:
|
||||||
|
|
||||||
void WriteHTMLChannelList();
|
void WriteHTMLChannelList();
|
||||||
|
|
||||||
/*
|
|
||||||
void MixEncodeTransmitData ( const CVector<CVector<int16_t> >& vecvecsData,
|
|
||||||
const CVector<double>& vecdGains,
|
|
||||||
const CVector<double>& vecdPannings,
|
|
||||||
const CVector<int>& vecNumAudioChannels,
|
|
||||||
CVector<double>& vecdIntermProcBuf,
|
|
||||||
CVector<int16_t>& vecsSendData,
|
|
||||||
CVector<uint8_t>& vecbyCodedData,
|
|
||||||
CChannel& Channel,
|
|
||||||
CConvBuf<int16_t>& DoubleFrameSizeConvBufOut,
|
|
||||||
const int iUseDoubleSysFraSizeConvBuf,
|
|
||||||
const int iNumFrameSizeConvBlocks,
|
|
||||||
OpusCustomEncoder* pCurOpusEncoder,
|
|
||||||
const int iCeltNumCodedBytes,
|
|
||||||
const int iClientFrameSizeSamples,
|
|
||||||
const int iCurNumAudChan,
|
|
||||||
const int iNumClients );
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
void MixEncodeTransmitData ( const int iIdx,
|
void MixEncodeTransmitData ( const int iIdx,
|
||||||
|
|
Loading…
Reference in a new issue