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 )
{
// 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 );
}
@ -354,7 +354,7 @@ void CAudioMixerBoard::SetGUIDesign ( const EGUIDesign eNewDesign )
void CAudioMixerBoard::HideAll()
{
// 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();
}
@ -370,7 +370,7 @@ void CAudioMixerBoard::ApplyNewConClientList ( CVector<CChannelShortInfo>& vecCh
// search for channels with are already present and preserver their 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;
@ -422,7 +422,7 @@ void CAudioMixerBoard::OnChSoloStateChanged ( const int iChannelIdx,
( static_cast<Qt::CheckState> ( iValue ) == Qt::Checked );
// 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 )
{

View File

@ -35,7 +35,7 @@ void CNetBuf::Init ( const int iNewBlockSize,
// store block size value
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 );
// use the "get" flag to make sure the buffer is cleared

View File

@ -54,7 +54,8 @@ public:
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
int iCurPos = 0;
@ -188,6 +189,58 @@ public:
protected:
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;
int iMemSize;
int iGetPos, iPutPos;

View File

@ -27,7 +27,7 @@
// CChannel implementation *****************************************************
CChannel::CChannel ( const bool bNIsServer ) :
vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ),
vecdGains ( MAX_NUM_CHANNELS, (double) 1.0 ),
bIsEnabled ( false ),
bIsServer ( bNIsServer ),
iNetwFrameSizeFact ( FRAME_SIZE_FACTOR_PREFERRED ),
@ -189,7 +189,7 @@ void CChannel::SetGain ( const int iChanID, const double dNewGain )
QMutexLocker locker ( &Mutex );
// 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;
}
@ -200,7 +200,7 @@ double CChannel::GetGain ( const int iChanID )
QMutexLocker locker ( &Mutex );
// 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];
}

View File

@ -148,7 +148,7 @@ LED bar: lbr
// actual number of used channels in the server
// this parameter can safely be changed from 1 to MAX_NUM_CHANNELS
// 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
#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
// always visible -> put first item on the top
vecpListViewItems.Init ( USED_NUM_CHANNELS );
for ( int i = USED_NUM_CHANNELS - 1; i >= 0; i-- )
vecpListViewItems.Init ( MAX_NUM_CHANNELS );
for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- )
{
vecpListViewItems[i] = new CServerListViewItem ( lvwClients );
vecpListViewItems[i]->setHidden ( true );
@ -435,8 +435,11 @@ void CLlconServerDlg::OnTimer()
veciJitBufNumFrames,
veciNetwFrameSizeFact );
// we assume that all vectors have the same length
const int iNumChannels = vecHostAddresses.Size();
// 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 ) ) )
{

View File

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

View File

@ -164,18 +164,21 @@ void CHighPrecisionTimer::OnTimer()
// CServer implementation ******************************************************
CServer::CServer ( const QString& strLoggingFileName,
CServer::CServer ( const int iNewNumChan,
const QString& strLoggingFileName,
const quint16 iPortNumber,
const QString& strHTMLStatusFileName,
const QString& strHistoryFileName,
const QString& strServerNameForHTMLStatusFile,
const QString& strCentralServer,
const QString& strServerInfo ) :
iNumChannels ( iNewNumChan ),
Socket ( this, iPortNumber ),
bWriteStatusHTMLFile ( false ),
ServerListManager ( iPortNumber,
strCentralServer,
strServerInfo,
iNewNumChan,
&ConnLessProtocol ),
bAutoRunMinimized ( false )
{
@ -184,7 +187,7 @@ CServer::CServer ( const QString& strLoggingFileName,
// create CELT encoder/decoder for each channel (must be done before
// enabling the channels), create a mono and stereo encoder/decoder
// for each channel
for ( i = 0; i < USED_NUM_CHANNELS; i++ )
for ( i = 0; i < iNumChannels; i++ )
{
// init audio endocder/decoder (mono)
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
// entire life time of the software)
for ( i = 0; i < USED_NUM_CHANNELS; i++ )
for ( i = 0; i < iNumChannels; i++ )
{
vecChannels[i].SetEnable ( true );
}
@ -459,7 +462,7 @@ void CServer::OnTimer()
{
// first, get number and IDs of connected channels
vecChanID.Init ( 0 );
for ( i = 0; i < USED_NUM_CHANNELS; i++ )
for ( i = 0; i < iNumChannels; i++ )
{
if ( vecChannels[i].IsConnected() )
{
@ -785,7 +788,7 @@ CVector<CChannelShortInfo> CServer::CreateChannelList()
CVector<CChannelShortInfo> vecChanInfo ( 0 );
// look for free channels
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
for ( int i = 0; i < iNumChannels; i++ )
{
if ( vecChannels[i].IsConnected() )
{
@ -806,7 +809,7 @@ void CServer::CreateAndSendChanListForAllConChannels()
CVector<CChannelShortInfo> vecChanInfo ( CreateChannelList() );
// 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() )
{
@ -854,7 +857,7 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID
// 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() )
{
@ -867,7 +870,7 @@ void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID
int CServer::GetFreeChan()
{
// 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() )
{
@ -884,7 +887,7 @@ int CServer::GetNumberOfConnectedClients()
int iNumConnClients = 0;
// 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() )
{
@ -901,7 +904,7 @@ int CServer::CheckAddr ( const CHostAddress& Addr )
CHostAddress InetAddr;
// 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() )
{
@ -956,7 +959,7 @@ bool CServer::PutData ( const CVector<uint8_t>& vecbyRecBuf,
// reset the channel gains of current channel, at the same
// 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 );
@ -1062,13 +1065,13 @@ void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
CHostAddress InetAddr;
// init return values
vecHostAddresses.Init ( USED_NUM_CHANNELS );
vecsName.Init ( USED_NUM_CHANNELS );
veciJitBufNumFrames.Init ( USED_NUM_CHANNELS );
veciNetwFrameSizeFact.Init ( USED_NUM_CHANNELS );
vecHostAddresses.Init ( iNumChannels );
vecsName.Init ( iNumChannels );
veciJitBufNumFrames.Init ( iNumChannels );
veciNetwFrameSizeFact.Init ( iNumChannels );
// 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 ) )
{
@ -1112,7 +1115,7 @@ void CServer::WriteHTMLChannelList()
// get the number of connected clients
int iNumConnClients = 0;
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
for ( int i = 0; i < iNumChannels; i++ )
{
if ( vecChannels[i].IsConnected() )
{
@ -1129,7 +1132,7 @@ void CServer::WriteHTMLChannelList()
else
{
// 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() )
{

View File

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

View File

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

View File

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