the maximum number of channel can be set via command line now, added some test functions in the buffer

This commit is contained in:
Volker Fischer 2011-05-13 18:23:00 +00:00
parent 7d24441887
commit 793b21f9d9
11 changed files with 552 additions and 465 deletions

View file

@ -345,7 +345,7 @@ void CAudioMixerBoard::SetServerName ( const QString& strNewServerName )
void CAudioMixerBoard::SetGUIDesign ( const EGUIDesign eNewDesign ) void CAudioMixerBoard::SetGUIDesign ( const EGUIDesign eNewDesign )
{ {
// apply GUI design to child GUI controls // apply GUI design to child GUI controls
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
vecpChanFader[i]->SetGUIDesign ( eNewDesign ); vecpChanFader[i]->SetGUIDesign ( eNewDesign );
} }
@ -354,7 +354,7 @@ void CAudioMixerBoard::SetGUIDesign ( const EGUIDesign eNewDesign )
void CAudioMixerBoard::HideAll() void CAudioMixerBoard::HideAll()
{ {
// make all controls invisible // make all controls invisible
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
vecpChanFader[i]->Hide(); vecpChanFader[i]->Hide();
} }
@ -370,7 +370,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelShortInfo>& vecCh
// search for channels with are already present and preserver their gain // search for channels with are already present and preserver their gain
// setting, for all other channels, reset gain // setting, for all other channels, reset gain
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
bool bFaderIsUsed = false; bool bFaderIsUsed = false;
@ -422,7 +422,7 @@ void CAudioMixerBoard::OnChSoloStateChanged ( const int iChannelIdx,
( static_cast<Qt::CheckState> ( iValue ) == Qt::Checked ); ( static_cast<Qt::CheckState> ( iValue ) == Qt::Checked );
// apply "other solo state" for all other channels // apply "other solo state" for all other channels
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
if ( i != iChannelIdx ) if ( i != iChannelIdx )
{ {

View file

@ -35,7 +35,7 @@ void CNetBuf::Init ( const int iNewBlockSize,
// store block size value // store block size value
iBlockSize = iNewBlockSize; iBlockSize = iNewBlockSize;
// total size -> size of one block times number of blocks // total size -> size of one block times the number of blocks
CBufferBase<uint8_t>::Init ( iNewBlockSize * iNewNumBlocks ); CBufferBase<uint8_t>::Init ( iNewBlockSize * iNewNumBlocks );
// use the "get" flag to make sure the buffer is cleared // use the "get" flag to make sure the buffer is cleared
@ -46,7 +46,7 @@ void CNetBuf::Init ( const int iNewBlockSize,
} }
bool CNetBuf::Put ( const CVector<uint8_t>& vecbyData, bool CNetBuf::Put ( const CVector<uint8_t>& vecbyData,
const int iInSize ) const int iInSize )
{ {
bool bPutOK = true; bool bPutOK = true;

View file

@ -54,7 +54,8 @@ public:
eBufState = CBufferBase<TData>::BS_EMPTY; eBufState = CBufferBase<TData>::BS_EMPTY;
} }
virtual bool Put ( const CVector<TData>& vecData, const int iInSize ) virtual bool Put ( const CVector<TData>& vecData,
const int iInSize )
{ {
// copy new data in internal buffer // copy new data in internal buffer
int iCurPos = 0; int iCurPos = 0;
@ -188,6 +189,58 @@ public:
protected: protected:
enum EBufState { BS_OK, BS_FULL, BS_EMPTY }; enum EBufState { BS_OK, BS_FULL, BS_EMPTY };
void PutSimulation ( const int iInSize )
{
// in this simulation only the buffer pointers and the buffer state
// is updated, no actual data is transferred
if ( iPutPos + iInSize > iMemSize )
{
// data must be written in two steps because of wrap around
iPutPos += iInSize - iMemSize - 1;
}
else
{
// data can be written in one step
iPutPos += iInSize - 1;
}
// set buffer state flag
if ( iPutPos == iGetPos )
{
eBufState = CBufferBase<TData>::BS_FULL;
}
else
{
eBufState = CBufferBase<TData>::BS_OK;
}
}
void GetSimulation ( const int iInSize )
{
// in this simulation only the buffer pointers and the buffer state
// is updated, no actual data is transferred
if ( iGetPos + iInSize > iMemSize )
{
// data must be read in two steps because of wrap around
iGetPos += iInSize - iMemSize - 1;
}
else
{
// data can be read in one step
iGetPos += iInSize - 1;
}
// set buffer state flag
if ( iPutPos == iGetPos )
{
eBufState = CBufferBase<TData>::BS_EMPTY;
}
else
{
eBufState = CBufferBase<TData>::BS_OK;
}
}
CVector<TData> vecMemory; CVector<TData> vecMemory;
int iMemSize; int iMemSize;
int iGetPos, iPutPos; int iGetPos, iPutPos;

View file

@ -27,7 +27,7 @@
// CChannel implementation ***************************************************** // CChannel implementation *****************************************************
CChannel::CChannel ( const bool bNIsServer ) : CChannel::CChannel ( const bool bNIsServer ) :
vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ), vecdGains ( MAX_NUM_CHANNELS, (double) 1.0 ),
bIsEnabled ( false ), bIsEnabled ( false ),
bIsServer ( bNIsServer ), bIsServer ( bNIsServer ),
iNetwFrameSizeFact ( FRAME_SIZE_FACTOR_PREFERRED ), iNetwFrameSizeFact ( FRAME_SIZE_FACTOR_PREFERRED ),
@ -189,7 +189,7 @@ void CChannel::SetGain ( const int iChanID, const double dNewGain )
QMutexLocker locker ( &Mutex ); QMutexLocker locker ( &Mutex );
// set value (make sure channel ID is in range) // set value (make sure channel ID is in range)
if ( ( iChanID >= 0 ) && ( iChanID < USED_NUM_CHANNELS ) ) if ( ( iChanID >= 0 ) && ( iChanID < MAX_NUM_CHANNELS ) )
{ {
vecdGains[iChanID] = dNewGain; vecdGains[iChanID] = dNewGain;
} }
@ -200,7 +200,7 @@ double CChannel::GetGain ( const int iChanID )
QMutexLocker locker ( &Mutex ); QMutexLocker locker ( &Mutex );
// get value (make sure channel ID is in range) // get value (make sure channel ID is in range)
if ( ( iChanID >= 0 ) && ( iChanID < USED_NUM_CHANNELS ) ) if ( ( iChanID >= 0 ) && ( iChanID < MAX_NUM_CHANNELS ) )
{ {
return vecdGains[iChanID]; return vecdGains[iChanID];
} }

View file

@ -148,7 +148,7 @@ LED bar: lbr
// actual number of used channels in the server // actual number of used channels in the server
// this parameter can safely be changed from 1 to MAX_NUM_CHANNELS // this parameter can safely be changed from 1 to MAX_NUM_CHANNELS
// without any other changes in the code // without any other changes in the code
#define USED_NUM_CHANNELS 6 // used number channels for server #define DEFAULT_USED_NUM_CHANNELS 6 // default used number channels for server
// maximum number of servers registered in the server list // maximum number of servers registered in the server list
#define MAX_NUM_SERVERS_IN_SERVER_LIST 100 #define MAX_NUM_SERVERS_IN_SERVER_LIST 100

View file

@ -165,8 +165,8 @@ lvwClients->setMinimumHeight ( 140 );
// insert items in reverse order because in Windows all of them are // insert items in reverse order because in Windows all of them are
// always visible -> put first item on the top // always visible -> put first item on the top
vecpListViewItems.Init ( USED_NUM_CHANNELS ); vecpListViewItems.Init ( MAX_NUM_CHANNELS );
for ( int i = USED_NUM_CHANNELS - 1; i >= 0; i-- ) for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- )
{ {
vecpListViewItems[i] = new CServerListViewItem ( lvwClients ); vecpListViewItems[i] = new CServerListViewItem ( lvwClients );
vecpListViewItems[i]->setHidden ( true ); vecpListViewItems[i]->setHidden ( true );
@ -435,8 +435,11 @@ void CLlconServerDlg::OnTimer()
veciJitBufNumFrames, veciJitBufNumFrames,
veciNetwFrameSizeFact ); veciNetwFrameSizeFact );
// we assume that all vectors have the same length
const int iNumChannels = vecHostAddresses.Size();
// fill list with connected clients // fill list with connected clients
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( !( vecHostAddresses[i].InetAddr == QHostAddress ( (quint32) 0 ) ) ) if ( !( vecHostAddresses[i].InetAddr == QHostAddress ( (quint32) 0 ) ) )
{ {

View file

@ -58,6 +58,7 @@ int main ( int argc, char** argv )
bool bStartMinimized = false; bool bStartMinimized = false;
bool bConnectOnStartup = false; bool bConnectOnStartup = false;
bool bDisalbeLEDs = false; bool bDisalbeLEDs = false;
int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS;
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER; quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
QString strIniFileName = ""; QString strIniFileName = "";
QString strHTMLStatusFileName = ""; QString strHTMLStatusFileName = "";
@ -96,6 +97,27 @@ int main ( int argc, char** argv )
} }
// Maximum number of channels ------------------------------------------
if ( GetNumericArgument ( tsConsole,
argc,
argv,
i,
"-u",
"--numchannels",
1,
MAX_NUM_CHANNELS,
rDbleArgument ) )
{
iNumServerChannels = static_cast<int> ( rDbleArgument );
tsConsole << "- maximum number of channels: "
<< iNumServerChannels << endl;
continue;
}
// Start minimized ----------------------------------------------------- // Start minimized -----------------------------------------------------
if ( GetFlagArgument ( argv, if ( GetFlagArgument ( argv,
i, i,
@ -348,7 +370,8 @@ int main ( int argc, char** argv )
{ {
// Server: // Server:
// actual server object // actual server object
CServer Server ( strLoggingFileName, CServer Server ( iNumServerChannels,
strLoggingFileName,
iPortNumber, iPortNumber,
strHTMLStatusFileName, strHTMLStatusFileName,
strHistoryFileName, strHistoryFileName,
@ -433,6 +456,7 @@ QString UsageArguments ( char **argv )
"\nRecognized options:\n" "\nRecognized options:\n"
" -s, --server start server\n" " -s, --server start server\n"
" -n, --nogui disable GUI (server only)\n" " -n, --nogui disable GUI (server only)\n"
" -u, --numchannels maximum number of channels (server only)\n"
" -z, --startminimized start minimizied (server only)\n" " -z, --startminimized start minimizied (server only)\n"
" -l, --log enable logging, set file name\n" " -l, --log enable logging, set file name\n"
" -i, --inifile initialization file name (client only)\n" " -i, --inifile initialization file name (client only)\n"

View file

@ -164,27 +164,30 @@ void CHighPrecisionTimer::OnTimer()
// CServer implementation ****************************************************** // CServer implementation ******************************************************
CServer::CServer ( const QString& strLoggingFileName, CServer::CServer ( const int iNewNumChan,
const QString& strLoggingFileName,
const quint16 iPortNumber, const quint16 iPortNumber,
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,
const QString& strHistoryFileName, const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile, const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer, const QString& strCentralServer,
const QString& strServerInfo ) : const QString& strServerInfo ) :
Socket ( this, iPortNumber ), iNumChannels ( iNewNumChan ),
Socket ( this, iPortNumber ),
bWriteStatusHTMLFile ( false ), bWriteStatusHTMLFile ( false ),
ServerListManager ( iPortNumber, ServerListManager ( iPortNumber,
strCentralServer, strCentralServer,
strServerInfo, strServerInfo,
&ConnLessProtocol ), iNewNumChan,
bAutoRunMinimized ( false ) &ConnLessProtocol ),
bAutoRunMinimized ( false )
{ {
int i; int i;
// create CELT encoder/decoder for each channel (must be done before // create CELT encoder/decoder for each channel (must be done before
// enabling the channels), create a mono and stereo encoder/decoder // enabling the channels), create a mono and stereo encoder/decoder
// for each channel // for each channel
for ( i = 0; i < USED_NUM_CHANNELS; i++ ) for ( i = 0; i < iNumChannels; i++ )
{ {
// init audio endocder/decoder (mono) // init audio endocder/decoder (mono)
CeltModeMono[i] = celt_mode_create ( CeltModeMono[i] = celt_mode_create (
@ -268,7 +271,7 @@ CServer::CServer ( const QString& strLoggingFileName,
// enable all channels (for the server all channel must be enabled the // enable all channels (for the server all channel must be enabled the
// entire life time of the software) // entire life time of the software)
for ( i = 0; i < USED_NUM_CHANNELS; i++ ) for ( i = 0; i < iNumChannels; i++ )
{ {
vecChannels[i].SetEnable ( true ); vecChannels[i].SetEnable ( true );
} }
@ -459,7 +462,7 @@ void CServer::OnTimer()
{ {
// first, get number and IDs of connected channels // first, get number and IDs of connected channels
vecChanID.Init ( 0 ); vecChanID.Init ( 0 );
for ( i = 0; i < USED_NUM_CHANNELS; i++ ) for ( i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
@ -785,7 +788,7 @@ CVector<CChannelShortInfo> CServer::CreateChannelList()
CVector<CChannelShortInfo> vecChanInfo ( 0 ); CVector<CChannelShortInfo> vecChanInfo ( 0 );
// look for free channels // look for free channels
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
@ -806,7 +809,7 @@ void CServer::CreateAndSendChanListForAllConChannels()
CVector<CChannelShortInfo> vecChanInfo ( CreateChannelList() ); CVector<CChannelShortInfo> vecChanInfo ( CreateChannelList() );
// now send connected channels list to all connected clients // now send connected channels list to all connected clients
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
@ -854,7 +857,7 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID
// Send chat text to all connected clients --------------------------------- // Send chat text to all connected clients ---------------------------------
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
@ -867,7 +870,7 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID
int CServer::GetFreeChan() int CServer::GetFreeChan()
{ {
// look for a free channel // look for a free channel
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( !vecChannels[i].IsConnected() ) if ( !vecChannels[i].IsConnected() )
{ {
@ -884,7 +887,7 @@ int CServer::GetNumberOfConnectedClients()
int iNumConnClients = 0; int iNumConnClients = 0;
// check all possible channels for connection status // check all possible channels for connection status
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
@ -901,7 +904,7 @@ int CServer::CheckAddr ( const CHostAddress& Addr )
CHostAddress InetAddr; CHostAddress InetAddr;
// check for all possible channels if IP is already in use // check for all possible channels if IP is already in use
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
@ -956,7 +959,7 @@ bool CServer::PutData ( const CVector<uint8_t>& vecbyRecBuf,
// reset the channel gains of current channel, at the same // reset the channel gains of current channel, at the same
// time reset gains of this channel ID for all other channels // time reset gains of this channel ID for all other channels
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
vecChannels[iCurChanID].SetGain ( i, (double) 1.0 ); vecChannels[iCurChanID].SetGain ( i, (double) 1.0 );
@ -1062,13 +1065,13 @@ void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
CHostAddress InetAddr; CHostAddress InetAddr;
// init return values // init return values
vecHostAddresses.Init ( USED_NUM_CHANNELS ); vecHostAddresses.Init ( iNumChannels );
vecsName.Init ( USED_NUM_CHANNELS ); vecsName.Init ( iNumChannels );
veciJitBufNumFrames.Init ( USED_NUM_CHANNELS ); veciJitBufNumFrames.Init ( iNumChannels );
veciNetwFrameSizeFact.Init ( USED_NUM_CHANNELS ); veciNetwFrameSizeFact.Init ( iNumChannels );
// check all possible channels // check all possible channels
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].GetAddress ( InetAddr ) ) if ( vecChannels[i].GetAddress ( InetAddr ) )
{ {
@ -1112,7 +1115,7 @@ void CServer::WriteHTMLChannelList()
// get the number of connected clients // get the number of connected clients
int iNumConnClients = 0; int iNumConnClients = 0;
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {
@ -1129,7 +1132,7 @@ void CServer::WriteHTMLChannelList()
else else
{ {
// write entry for each connected client // write entry for each connected client
for ( int i = 0; i < USED_NUM_CHANNELS; i++ ) for ( int i = 0; i < iNumChannels; i++ )
{ {
if ( vecChannels[i].IsConnected() ) if ( vecChannels[i].IsConnected() )
{ {

View file

@ -103,7 +103,8 @@ class CServer : public QObject
Q_OBJECT Q_OBJECT
public: public:
CServer ( const QString& strLoggingFileName, CServer ( const int iNewNumChan,
const QString& strLoggingFileName,
const quint16 iPortNumber, const quint16 iPortNumber,
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,
const QString& strHistoryFileName, const QString& strHistoryFileName,
@ -200,6 +201,7 @@ protected:
// do not use the vector class since CChannel does not have appropriate // do not use the vector class since CChannel does not have appropriate
// copy constructor/operator // copy constructor/operator
CChannel vecChannels[MAX_NUM_CHANNELS]; CChannel vecChannels[MAX_NUM_CHANNELS];
int iNumChannels;
CProtocol ConnLessProtocol; CProtocol ConnLessProtocol;
QMutex Mutex; QMutex Mutex;

View file

@ -29,6 +29,7 @@
CServerListManager::CServerListManager ( const quint16 iNPortNum, CServerListManager::CServerListManager ( const quint16 iNPortNum,
const QString& sNCentServAddr, const QString& sNCentServAddr,
const QString& strServerInfo, const QString& strServerInfo,
const int iNumChannels,
CProtocol* pNConLProt ) CProtocol* pNConLProt )
: iPortNumber ( iNPortNum ), : iPortNumber ( iNPortNum ),
iNumPredefinedServers ( 0 ), iNumPredefinedServers ( 0 ),
@ -65,7 +66,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
"", "",
QLocale::system().country(), QLocale::system().country(),
"", "",
USED_NUM_CHANNELS, iNumChannels,
true ); true );
// parse the server info string according to definition: // parse the server info string according to definition:
@ -113,7 +114,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum,
"", "",
QLocale::AnyCountry, QLocale::AnyCountry,
"", "",
USED_NUM_CHANNELS, iNumChannels,
true ); true );
// [server n address] // [server n address]

View file

@ -128,6 +128,7 @@ public:
CServerListManager ( const quint16 iNPortNum, CServerListManager ( const quint16 iNPortNum,
const QString& sNCentServAddr, const QString& sNCentServAddr,
const QString& strServerInfo, const QString& strServerInfo,
const int iNumChannels,
CProtocol* pNConLProt ); CProtocol* pNConLProt );
// the update has to be called if any change to the server list // the update has to be called if any change to the server list