Commit c5561a1d authored by Jonas Stienen's avatar Jonas Stienen

Cleaning up NetAudio server test

parent 6b4bb1b0
......@@ -10,38 +10,56 @@
using namespace std;
int main(int argc, char** argv)
string g_sServerName = "localhost";
int g_iServerPort = 12480;
double g_dSampleRate = 44100.0;
int g_iBlockLength = 32;
int g_iChannels = 2;
int g_iTargetLatencySamples = 64; // 1.4512ms
double g_dClientStatusMessageTimeout = 0.1; // seconds
string g_sFileName = "gershwin-mono.wav";
int main( int argc, char** argv )
{
if (argc != 6)
if( argc >= 6 )
{
fprintf(stderr, "Fehler: Syntax = ServerName ServerPort SampleRate BufferSize Channel!\n");
g_sServerName = argv[ 1 ];
g_iServerPort = atoi( argv[ 2 ] );
g_dSampleRate = strtod( argv[ 3 ], NULL );
g_iBlockLength = atoi( argv[ 4 ] );
g_iChannels = atoi( argv[ 5 ] );
}
string sServerName = argv[1];
unsigned int iServerPort = atoi(argv[2]);
double dSampleRate = strtod(argv[3], NULL);
int iBlockLength = atoi(argv[4]);
int iChannels = atoi(argv[5]);
ITADatasource* pSource = NULL;
try
{
pSource = new ITAFileDatasource( g_sFileName, g_iBlockLength );
static_cast< ITAFileDatasource* >( pSource )->SetIsLooping( true );
cout << "Found file " << g_sFileName << ", will use it for playback." << endl;
}
catch( ITAException& )
{
cout << "Could not find file " << g_sFileName << ", will use sine signal instead." << endl;
pSource = new ITAStreamFunctionGenerator( 1, g_dSampleRate, g_iBlockLength, ITAStreamFunctionGenerator::SINE, 250.0f, 0.7171f, true );
}
ITAFileDatasource oFile( "gershwin-mono.wav", iBlockLength );
oFile.SetIsLooping( true );
ITAStreamMultiplier1N oMuliplier( &oFile, iChannels );
ITAStreamMultiplier1N oMuliplier( pSource, g_iChannels );
CITANetAudioStreamingServer oStreamingServer;
oStreamingServer.SetInputStream( &oMuliplier );
cout << "Starting net audio server and waiting for connections on '" << sServerName << "' on port " << iServerPort << endl;
oStreamingServer.Start( sServerName, iServerPort , 0.1);
cout << "Starting net audio server and waiting for connections on '" << g_sServerName << "' on port " << g_iServerPort << endl;
oStreamingServer.Start( g_sServerName, g_iServerPort, g_dClientStatusMessageTimeout );
while (!oStreamingServer.IsClientConnected())
{
VistaTimeUtils::Sleep(100);
}
while (oStreamingServer.IsClientConnected())
{
VistaTimeUtils::Sleep(100);
}
while( !oStreamingServer.IsClientConnected() )
VistaTimeUtils::Sleep( 100 );
while( oStreamingServer.IsClientConnected() )
VistaTimeUtils::Sleep( 100 );
VistaTimeUtils::Sleep( 2000 );
VistaTimeUtils::Sleep(2000);
delete pSource;
return 0;
}
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