Nicer output formatting for VAServer

parent 17e23536
cmake_minimum_required( VERSION 2.8 )
if( NOT VANET_COMMON_BUILD )
if( NOT VA_COMMON_BUILD )
project( VAServer )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
......
......@@ -44,10 +44,10 @@ int main( int argc, char* argv[] )
sServerAddress = "0.0.0.0:12340";
cout << "No bind address and port given, using default: " << sServerAddress << endl;
string sDefaultConfigFile = "VACore.ini";
if (doesFileExist(sDefaultConfigFile))
if( doesFileExist( sDefaultConfigFile ) )
{
sVACoreConfigPath = sDefaultConfigFile;
cout << "Using default configuration file '" << sVACoreConfigPath << "'." << endl;
cout << "[VAServer ] Using default configuration file '" << sVACoreConfigPath << "'." << endl;
}
}
else
......@@ -60,9 +60,9 @@ int main( int argc, char* argv[] )
}
if( argc >= 2 )
sServerAddress = argv[1];
sServerAddress = argv[ 1 ];
if( argc >= 3 )
sVACoreConfigPath = argv[2];
sVACoreConfigPath = argv[ 2 ];
}
......@@ -72,49 +72,45 @@ int main( int argc, char* argv[] )
IVACore* pCore = NULL;
IVANetServer* pServer = NULL;
try
try
{
int ec;
if( sVACoreConfigPath.empty() )
{
CVAStruct oDefaultCoreConfig, oAudioDriver, oRenderer, oReproduction, oOutput, oOutputDevice;
oAudioDriver["Driver"] = "Portaudio";
oAudioDriver["Device"] = "default";
oDefaultCoreConfig["Audio driver"] = oAudioDriver;
oRenderer["Class"] = "BinauralFreefield";
oRenderer["Enabled"] = true;
oRenderer["Outputs"] = "DefaultTalkthrough";
oDefaultCoreConfig["Renderer:DefaultBinauralFreefield"] = oRenderer;
oReproduction["Class"] = "Talkthrough";
oReproduction["Enabled"] = true;
oReproduction["Name"] = "Default talkthrough reproduction";
oReproduction["Outputs"] = "DefaultOutput";
oDefaultCoreConfig["Reproduction:DefaultTalkthrough"] = oReproduction;
oOutput["Devices"] = "DefaultStereoChannels";
oOutput["Description"] = "Default stereo channels (headphones)";
oDefaultCoreConfig["Output:DefaultOutput"] = oOutput;
oOutputDevice["Type"] = "HP";
oOutputDevice["Description"] = "Default headphone hardware device (two-channels)";
oOutputDevice["Channels"] = "1,2";
oDefaultCoreConfig["OutputDevice:DefaultStereoChannels"] = oOutputDevice;
oAudioDriver[ "Driver" ] = "Portaudio";
oAudioDriver[ "Device" ] = "default";
oDefaultCoreConfig[ "Audio driver" ] = oAudioDriver;
oRenderer[ "Class" ] = "BinauralFreefield";
oRenderer[ "Enabled" ] = true;
oRenderer[ "Outputs" ] = "DefaultTalkthrough";
oDefaultCoreConfig[ "Renderer:DefaultBinauralFreefield" ] = oRenderer;
oReproduction[ "Class" ] = "Talkthrough";
oReproduction[ "Enabled" ] = true;
oReproduction[ "Name" ] = "Default talkthrough reproduction";
oReproduction[ "Outputs" ] = "DefaultOutput";
oDefaultCoreConfig[ "Reproduction:DefaultTalkthrough" ] = oReproduction;
oOutput[ "Devices" ] = "DefaultStereoChannels";
oOutput[ "Description" ] = "Default stereo channels (headphones)";
oDefaultCoreConfig[ "Output:DefaultOutput" ] = oOutput;
oOutputDevice[ "Type" ] = "HP";
oOutputDevice[ "Description" ] = "Default headphone hardware device (two-channels)";
oOutputDevice[ "Channels" ] = "1,2";
oDefaultCoreConfig[ "OutputDevice:DefaultStereoChannels" ] = oOutputDevice;
pCore = VACore::CreateCoreInstance( oDefaultCoreConfig );
}
else
{
cout << "VACore configuration path: " << correctPath( sVACoreConfigPath ) << endl;
cout << "[VAServer ] Core configuration path: " << correctPath( sVACoreConfigPath ) << endl;
pCore = VACore::CreateCoreInstance( sVACoreConfigPath );
}
CVACoreVersionInfo ver;
pCore->GetVersionInfo( &ver );
cout << ver.ToString() << endl;
// If only version requested, exit.
if( bVersionInfoRequest )
{
......@@ -133,15 +129,19 @@ int main( int argc, char* argv[] )
int iPort;
SplitServerString( sServerAddress, sServer, iPort );
pServer->SetCoreInstance(pCore);
pServer->SetCoreInstance( pCore );
if ((ec = pServer->Initialize(sServer, iPort)) != 0) {
if( ( ec = pServer->Initialize( sServer, iPort ) ) != 0 )
{
cerr << "Failed to initialize network communication (errorcode " << ec << ")" << endl;
return ec;
}
cout << endl << "VAServer successfully started and listening on " << sServer << ":" << iPort << endl << endl;
cout << "Controls:\n\n" <<
CVACoreVersionInfo ver;
pCore->GetVersionInfo( &ver );
cout << endl << "[VAServer ] Core version: " << ver.ToString() << endl;
cout << "[VAServer ] Successfully started and listening on " << sServer << ":" << iPort << endl << endl;
cout << "Controls:\n\n" <<
" m Toggle output muting" << endl <<
" + Increase output gain by 3dB" << endl <<
" 0 Output gain 0dB" << endl <<
......@@ -189,16 +189,16 @@ int main( int argc, char* argv[] )
if( ( char ) c == 'l' )
{
CVAStruct oArgs, oReturn, oNewArgs;
oArgs["command"] = "get";
oArgs["debug"] = CVAStruct();
oArgs["debug"]["loglevel"] = true;
oArgs[ "command" ] = "get";
oArgs[ "debug" ] = CVAStruct();
oArgs[ "debug" ][ "loglevel" ] = true;
pServer->GetCoreInstance()->CallModule( "VACore", oArgs, oReturn );
int iCurrentLogLevel = oReturn["debug"]["loglevel"];
int iCurrentLogLevel = oReturn[ "debug" ][ "loglevel" ];
int iNewLogLevel = int( iCurrentLogLevel + 1 ) % 5;
cout << "Setting log level to: " << iNewLogLevel << endl;
oNewArgs["command"] = "set";
oNewArgs["debug"] = CVAStruct();
oNewArgs["debug"]["loglevel"] = iNewLogLevel;
oNewArgs[ "command" ] = "set";
oNewArgs[ "debug" ] = CVAStruct();
oNewArgs[ "debug" ][ "loglevel" ] = iNewLogLevel;
pServer->GetCoreInstance()->CallModule( "VACore", oNewArgs, oReturn );
}
......@@ -214,7 +214,7 @@ int main( int argc, char* argv[] )
delete pCore;
}
catch (CVAException& e)
catch( CVAException& e )
{
cerr << "Error: " << e << endl;
......@@ -228,7 +228,7 @@ int main( int argc, char* argv[] )
catch( ... )
{
delete pServer;
if (pCore)
if( pCore )
pCore->Finalize();
delete pCore;
......
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