Aufgrund einer Wartung wird GitLab am 26.10. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 26.10. between 8:00 and 9:00 am.

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

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