Commit 8545bea8 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Improved output formatting and added new command 'c' for more information on client connections

parent cc2ed6cb
...@@ -47,12 +47,12 @@ int main( int argc, char* argv[] ) ...@@ -47,12 +47,12 @@ int main( int argc, char* argv[] )
if( argc == 1 ) if( argc == 1 )
{ {
sServerAddress = "0.0.0.0:12340"; sServerAddress = "0.0.0.0:12340";
cout << "No bind address and port given, using default: " << sServerAddress << endl; cout << "[ VAServer ] No bind address and port given, using default: " << sServerAddress << endl;
string sDefaultConfigFile = "VACore.ini"; string sDefaultConfigFile = "VACore.ini";
if( doesFileExist( sDefaultConfigFile ) ) if( doesFileExist( sDefaultConfigFile ) )
{ {
sVACoreConfigPath = sDefaultConfigFile; sVACoreConfigPath = sDefaultConfigFile;
cout << "[VAServer ] Using default configuration file '" << sVACoreConfigPath << "'." << endl; cout << "[ VAServer ] Using default configuration file '" << sVACoreConfigPath << "'." << endl;
} }
} }
else else
...@@ -112,7 +112,7 @@ int main( int argc, char* argv[] ) ...@@ -112,7 +112,7 @@ int main( int argc, char* argv[] )
} }
else else
{ {
cout << "[VAServer ] Core configuration path: " << correctPath( sVACoreConfigPath ) << endl; cout << "[ VAServer ] Core configuration path: " << correctPath( sVACoreConfigPath ) << endl;
pCore = VACore::CreateCoreInstance( sVACoreConfigPath ); pCore = VACore::CreateCoreInstance( sVACoreConfigPath );
} }
...@@ -121,7 +121,7 @@ int main( int argc, char* argv[] ) ...@@ -121,7 +121,7 @@ int main( int argc, char* argv[] )
{ {
CVACoreVersionInfo ver; CVACoreVersionInfo ver;
pCore->GetVersionInfo( &ver ); pCore->GetVersionInfo( &ver );
cout << ver.ToString() << endl; cout << "[ VAServer ] " << ver.ToString() << endl;
delete pCore; delete pCore;
return 0; return 0;
...@@ -142,23 +142,24 @@ int main( int argc, char* argv[] ) ...@@ -142,23 +142,24 @@ int main( int argc, char* argv[] )
if( ( ec = pServer->Initialize( sServer, iPort ) ) != 0 ) if( ( ec = pServer->Initialize( sServer, iPort ) ) != 0 )
{ {
cerr << "Failed to initialize network communication (errorcode " << ec << ")" << endl; cerr << "[ VAServer ][Error ] Failed to initialize network communication (errorcode " << ec << ")" << endl;
return ec; return ec;
} }
CVACoreVersionInfo ver; CVACoreVersionInfo ver;
pCore->GetVersionInfo( &ver ); pCore->GetVersionInfo( &ver );
cout << endl << "[VAServer ] Core version: " << ver.ToString() << endl; cout << endl << "[ VAServer ] Core version: " << ver.ToString() << endl;
cout << "[VAServer ] Successfully started and listening on " << sServer << ":" << iPort << endl << endl; cout << "[ VAServer ] Successfully started and listening on " << sServer << ":" << iPort << endl << endl;
cout << "Controls:\n\n" << cout << "[ VAServer ] Controls:\n" <<
" m Toggle output muting" << endl << "[ VAServer ] m Toggle output muting" << endl <<
" + Increase output gain by 3dB" << endl << "[ VAServer ] + Increase output gain by 3dB" << endl <<
" 0 Output gain 0dB" << endl << "[ VAServer ] 0 Output gain 0dB" << endl <<
" - Decrease output gain by 3dB" << endl << "[ VAServer ] - Decrease output gain by 3dB" << endl <<
" r Reset core" << endl << "[ VAServer ] r Reset core" << endl <<
" l Circulate log levels" << endl << "[ VAServer ] l Circulate log levels" << endl <<
" q Quit" << endl << endl; "[ VAServer ] c List connected clients" << endl <<
"[ VAServer ] q Quit" << endl << endl;
while( true ) while( true )
{ {
...@@ -170,13 +171,13 @@ int main( int argc, char* argv[] ) ...@@ -170,13 +171,13 @@ int main( int argc, char* argv[] )
if( ( char ) c == 'm' ) if( ( char ) c == 'm' )
{ {
bool bMuted = pServer->GetCoreInstance()->IsOutputMuted(); bool bMuted = pServer->GetCoreInstance()->IsOutputMuted();
cout << ( !bMuted ? "Muting" : "Unmuting" ) << " global output" << endl; cout << "[ VAServer ] " << ( !bMuted ? "Muting" : "Unmuting" ) << " global output" << endl;
pServer->GetCoreInstance()->SetOutputMuted( !bMuted ); pServer->GetCoreInstance()->SetOutputMuted( !bMuted );
} }
if( ( char ) c == '0' ) if( ( char ) c == '0' )
{ {
cout << "Setting output gain to 0 dB" << endl; cout << "[ VAServer ] Setting output gain to 0 dB" << endl;
pServer->GetCoreInstance()->SetOutputGain( 1.0 ); pServer->GetCoreInstance()->SetOutputGain( 1.0 );
} }
...@@ -184,7 +185,7 @@ int main( int argc, char* argv[] ) ...@@ -184,7 +185,7 @@ int main( int argc, char* argv[] )
{ {
double dGain = pServer->GetCoreInstance()->GetOutputGain(); double dGain = pServer->GetCoreInstance()->GetOutputGain();
dGain *= 1.4125; dGain *= 1.4125;
cout << "Setting output gain to " << ratio_to_db20_str( dGain ) << endl; cout << "[ VAServer ] Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
pServer->GetCoreInstance()->SetOutputGain( dGain ); pServer->GetCoreInstance()->SetOutputGain( dGain );
} }
...@@ -192,7 +193,7 @@ int main( int argc, char* argv[] ) ...@@ -192,7 +193,7 @@ int main( int argc, char* argv[] )
{ {
double dGain = pServer->GetCoreInstance()->GetOutputGain(); double dGain = pServer->GetCoreInstance()->GetOutputGain();
dGain /= 1.4125; dGain /= 1.4125;
cout << "Setting output gain to " << ratio_to_db20_str( dGain ) << endl; cout << "[ VAServer ] Setting output gain to " << ratio_to_db20_str( dGain ) << endl;
pServer->GetCoreInstance()->SetOutputGain( dGain ); pServer->GetCoreInstance()->SetOutputGain( dGain );
} }
...@@ -200,24 +201,44 @@ int main( int argc, char* argv[] ) ...@@ -200,24 +201,44 @@ int main( int argc, char* argv[] )
{ {
CVAStruct oArgs, oReturn, oNewArgs; CVAStruct oArgs, oReturn, oNewArgs;
oArgs[ "command" ] = "get"; oArgs[ "command" ] = "get";
oArgs[ std::string("debug") ] = CVAStruct(); oArgs[ std::string( "debug" ) ] = CVAStruct();
oArgs[ std::string("debug") ][ std::string("loglevel") ] = true; oArgs[ std::string( "debug" ) ][ std::string( "loglevel" ) ] = true;
pServer->GetCoreInstance()->CallModule( "VACore", oArgs, oReturn ); pServer->GetCoreInstance()->CallModule( "VACore", oArgs, oReturn );
int iCurrentLogLevel = oReturn[ std::string("debug") ][ std::string("loglevel") ]; int iCurrentLogLevel = oReturn[ std::string( "debug" ) ][ std::string( "loglevel" ) ];
int iNewLogLevel = int( iCurrentLogLevel + 1 ) % 6; int iNewLogLevel = int( iCurrentLogLevel + 1 ) % 6;
oNewArgs[ "command" ] = "set"; oNewArgs[ "command" ] = "set";
oNewArgs[ "debug" ] = CVAStruct(); oNewArgs[ "debug" ] = CVAStruct();
oNewArgs[ std::string("debug") ][ std::string("loglevel") ] = iNewLogLevel; oNewArgs[ std::string( "debug" ) ][ std::string( "loglevel" ) ] = iNewLogLevel;
pServer->GetCoreInstance()->CallModule( "VACore", oNewArgs, oReturn ); pServer->GetCoreInstance()->CallModule( "VACore", oNewArgs, oReturn );
cout << "Switched to log level: " << IVACore::GetLogLevelStr( iNewLogLevel ) << endl; cout << "[ VAServer ] Switched to log level: " << IVACore::GetLogLevelStr( iNewLogLevel ) << endl;
} }
if( ( char ) c == 'r' ) if( ( char ) c == 'r' )
{ {
cout << "Resetting server manually" << endl; cout << "[ VAServer ] Resetting server manually" << endl;
pServer->GetCoreInstance()->Reset(); pServer->GetCoreInstance()->Reset();
} }
if( ( char ) c == 'c' )
{
if( !pServer->IsClientConnected() )
{
cout << "[ VAServer ] Nothing yet, still waiting for connections" << endl;
}
else
{
const int iNumClients = pServer->GetNumConnectedClients();
if( iNumClients == 1 )
cout << "[ VAServer ] One client connected" << endl;
else
cout << "[ VAServer ] Counting " << iNumClients << " connections" << endl;
for( int i = 0; i < iNumClients; i++ )
{
cout << "[ VAServer ] + " << pServer->GetClientHostname( i ) << endl;
}
}
}
} }
delete pServer; delete pServer;
...@@ -227,7 +248,7 @@ int main( int argc, char* argv[] ) ...@@ -227,7 +248,7 @@ int main( int argc, char* argv[] )
} }
catch( CVAException& e ) catch( CVAException& e )
{ {
cerr << "Error: " << e << endl; cerr << "[ VAServer ][ Error ] " << e << endl;
delete pServer; delete pServer;
if( pCore ) if( pCore )
...@@ -243,7 +264,7 @@ int main( int argc, char* argv[] ) ...@@ -243,7 +264,7 @@ int main( int argc, char* argv[] )
pCore->Finalize(); pCore->Finalize();
delete pCore; delete pCore;
cerr << "Error: An unknown error occured" << endl; cerr << "[ VAServer ][ Error ] An unknown error occured" << endl;
return 255; return 255;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment