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
|
||||
}
|
||||
|
||||
# support multi-threading with OMP if requested
|
||||
contains(CONFIG, "multithreading") {
|
||||
message(Multithreading in the server is enabled.)
|
||||
DEFINES += USE_MULTITHREADING
|
||||
QT += concurrent
|
||||
}
|
||||
|
||||
CONFIG += qt \
|
||||
thread \
|
||||
release
|
||||
|
||||
QT += network \
|
||||
concurrent \
|
||||
xml
|
||||
|
||||
contains(CONFIG, "headless") {
|
||||
|
|
|
@ -979,6 +979,10 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE
|
|||
|
||||
|
||||
// Process data ------------------------------------------------------------
|
||||
#ifdef USE_MULTITHREADING
|
||||
QFutureSynchronizer<void> FutureSynchronizer;
|
||||
#endif
|
||||
|
||||
// Check if at least one client is connected. If not, stop server until
|
||||
// one client is connected.
|
||||
if ( iNumClients > 0 )
|
||||
|
@ -1055,35 +1059,26 @@ static CTimingMeas JitterMeas ( 1000, "test2.dat" ); JitterMeas.Measure(); // TE
|
|||
}
|
||||
}
|
||||
|
||||
// TEST
|
||||
QFuture<void> future = QtConcurrent::run ( this, &CServer::MixEncodeTransmitData,
|
||||
// generate a separate mix for each channel, OPUS encode the
|
||||
// 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,
|
||||
iCurChanID,
|
||||
pCurOpusEncoder,
|
||||
iClientFrameSizeSamples,
|
||||
iNumClients );
|
||||
|
||||
|
||||
// generate a separate mix for each channel, OPUS encode the
|
||||
// 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],
|
||||
iNumClients ) );
|
||||
#else
|
||||
MixEncodeTransmitData ( i,
|
||||
iCurChanID,
|
||||
pCurOpusEncoder,
|
||||
iCeltNumCodedBytes,
|
||||
iClientFrameSizeSamples,
|
||||
iCurNumAudChan,
|
||||
iNumClients );
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
23
src/server.h
23
src/server.h
|
@ -29,8 +29,11 @@
|
|||
#include <QDateTime>
|
||||
#include <QHostAddress>
|
||||
#include <QFileInfo>
|
||||
#include <QtConcurrent>
|
||||
#include <algorithm>
|
||||
#ifdef USE_MULTITHREADING
|
||||
# include <QtConcurrent>
|
||||
# include <QFutureSynchronizer>
|
||||
#endif
|
||||
#ifdef USE_OPUS_SHARED_LIB
|
||||
# include "opus/opus_custom.h"
|
||||
#else
|
||||
|
@ -302,24 +305,6 @@ protected:
|
|||
|
||||
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
|
||||
void MixEncodeTransmitData ( const int iIdx,
|
||||
|
|
Loading…
Reference in a new issue