Commit c2ba8c23 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merge branch 'ba_2016_heimes' of https://git.rwth-aachen.de/ita/ITADataSources into ba_2016_heimes

# Conflicts:
#	src/ITANetAudioMessage.cpp
#	tests/NetAudio/ITANetAudioTest.cpp
parents 5aceb84c eb656507
......@@ -65,14 +65,17 @@ public:
void SetInputStream( ITADatasource* pInStream );
int GetNetStreamBlocklength() const;
int GetNetStreamNumberOfChannels() const;
double GetNetStreamSampleRate() const;
//! Enabled/disables export of loggers
void SetDebuggingEnabled( bool bEnabled );
//! Logging export flag getter
int GetNetStreamNumberOfChannels( ) const;
double GetNetStreamSampleRate( ) const;
double GetEstimatedCorrFactor( ) const;
void SetEstimatedCorrFactor( double dcorrFactor );
//! Enabled/disables export of loggers
void SetDebuggingEnabled( bool bEnabled );
//! Logging export flag getter
bool GetIsDebuggingEnabled() const;
int GetSendingBlockLength() const;
......@@ -104,6 +107,7 @@ private:
int m_iServerBlockId;
double m_dLastTimeStamp;
double m_dEstimatedCorrFactor;
int m_iTargetLatencySamples;
int m_iEstimatedClientRingBufferFreeSamples;
......
......@@ -31,6 +31,7 @@ struct CITAServerLog : public ITALogDataBase
os << "\t" << "ProtocolStatus";
os << "\t" << "EstimatedFreeSamples";
os << "\t" << "TransmittedSamples";
os << "\t" << "EstimatedCorrFactor";
os << std::endl;
return os;
};
......@@ -42,6 +43,7 @@ struct CITAServerLog : public ITALogDataBase
os << "\t" << sProtocolStatus;
os << "\t" << iEstimatedFreeSamples;
os << "\t" << iTransmittedSamples;
os << "\t" << dEstimatedCorrFactor;
os << std::endl;
return os;
};
......@@ -51,6 +53,7 @@ struct CITAServerLog : public ITALogDataBase
std::string sProtocolStatus;
int iEstimatedFreeSamples;
int iTransmittedSamples;
double dEstimatedCorrFactor;
};
class CITABufferedDataLoggerImplServer : public ITABufferedDataLogger < CITAServerLog > {};
......@@ -67,6 +70,7 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer()
, m_iServerBlockId( 0 )
, m_iEstimatedClientRingBufferFreeSamples( 0 )
, m_iClientRingBufferSize( 0 )
, m_dEstimatedCorrFactor( 1 )
{
// Careful with this:
//SetPriority( VistaPriority::VISTA_MID_PRIORITY );
......@@ -246,7 +250,7 @@ bool CITANetAudioStreamingServer::LoopBody()
// There is no status message, so we estimate the client-side ring buffer status
const double dTimeDiff = dNow - m_dLastTimeStamp;
m_dLastTimeStamp = dNow;
double dEstimatedSamples = dTimeDiff * m_pInputStream->GetSampleRate();
double dEstimatedSamples = m_dEstimatedCorrFactor * dTimeDiff * m_pInputStream->GetSampleRate();
m_iEstimatedClientRingBufferFreeSamples += ( int ) dEstimatedSamples;
oLog.sProtocolStatus = "SERVER_ESTIMATION";
}
......@@ -254,6 +258,7 @@ bool CITANetAudioStreamingServer::LoopBody()
m_swTryReadBlockStats.stop();
oLog.iEstimatedFreeSamples = m_iEstimatedClientRingBufferFreeSamples;
oLog.dEstimatedCorrFactor = m_dEstimatedCorrFactor;
m_pServerLogger->log( oLog );
return false;
......@@ -309,7 +314,7 @@ void CITANetAudioStreamingServer::SetTargetLatencySamples( const int iTargetLate
ITA_EXCEPT1( MODAL_EXCEPTION, "Server not connected, client ring buffer unkown" );
if( m_pInputStream )
if( m_iTargetLatencySamples < int( m_pInputStream->GetBlocklength() ) )
if ( iTargetLatency < int( m_pInputStream->GetBlocklength( ) ) )
ITA_EXCEPT1( INVALID_PARAMETER, "Target latency has to be at least the block size of the audio streaming at client side." );
m_iTargetLatencySamples = iTargetLatency;
......@@ -344,6 +349,18 @@ int CITANetAudioStreamingServer::GetNetworkPort() const
return m_pNetAudioServer->GetNetworkPort();
}
double CITANetAudioStreamingServer::GetEstimatedCorrFactor( ) const
{
return m_dEstimatedCorrFactor;
}
void CITANetAudioStreamingServer::SetEstimatedCorrFactor( double dCorrFactor )
{
m_dEstimatedCorrFactor = dCorrFactor;
}
void CITANetAudioStreamingServer::Stop()
{
m_pNetAudioServer->Stop();
......
......@@ -14,19 +14,22 @@
using namespace std;
string g_sServerName = "localhost";
string g_sServerName = "137.226.61.85";
int g_iServerPort = 12480;
double g_dSampleRate = 44100.0;
int g_iBlockLength = 512;
int g_iChannels = 2;
int g_iBlockLength = 32;
int g_iChannels = 100;
int g_iTargetLatencySamples = 2 * g_iBlockLength; // 1.4512ms
int g_iRingBufferSize = 2 * g_iTargetLatencySamples;
int g_iSendingBlockLength = 8;
double g_dPlaybackDuration = 10 ; // seconds
const static string g_sAudioInterface = "ASIO MADIface USB";
//const static string g_sAudioInterface = "ASIO Hammerfall DSP";
//const static string g_sAudioInterface = "ASIO4ALL v2";
int main( int argc, char* argv[] )
{
if( argc >= 8 )
if( argc >= 9 )
{
g_sServerName = argv[ 1 ];
......@@ -41,8 +44,8 @@ int main( int argc, char* argv[] )
g_iSendingBlockLength = atoi(argv[8]);
}
if( argc >= 9 )
g_dPlaybackDuration = strtod( argv[ 8 ], NULL );;
if( argc >= 10 )
g_dPlaybackDuration = strtod( argv[ 9 ], NULL );;
}
else
{
......@@ -78,7 +81,7 @@ int main( int argc, char* argv[] )
cout << "Will attempt to connect to '" << g_sServerName << "' on port " << g_iServerPort << endl;
ITAsioInitializeLibrary();
ITAsioInitializeDriver( "ASIO4ALL v2" );
ITAsioInitializeDriver( g_sAudioInterface );
long lBuffersize, lDummy;
ITAsioGetBufferSize( &lDummy, &lDummy, &lBuffersize, &lDummy );
......
......@@ -12,12 +12,12 @@
using namespace std;
string g_sServerName = "localhost";
string g_sServerName = "137.226.61.85";
int g_iServerPort = 12480;
double g_dSampleRate = 44100.0;
int g_iBlockLength = 512;
int g_iChannels = 1;
int g_iTargetLatencySamples = 4 * g_iBlockLength; // 1.4512ms
int g_iBlockLength = 32;
int g_iChannels = 100;
int g_iTargetLatencySamples = 10 * g_iBlockLength; // 1.4512ms
int g_iRingBufferSize = 2 * g_iTargetLatencySamples;
int g_iSendingBlockLength = 8;
double g_dClientStatusMessageTimeout = 0.001; // seconds
......
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