Statistics for try-read access

parent 33a76773
......@@ -202,6 +202,7 @@ private:
int iNetStreamingBlockID; //!< Network streaming block id
friend class CITANetAudioStreamingClient;
static std::string GetStreamingStatusString( int iStreamingStatus );
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_STREAM
......@@ -88,7 +88,7 @@ private:
ITABufferedDataLoggerImplClient* m_pClientLogger;
std::string m_sClientLoggerBaseName;
ITAStopWatch m_swTryReadStats;
ITAStopWatch m_swTryReadBlockStats, m_swTryReadAccessStats;
friend class CITANetAudioStream;
};
......
......@@ -36,7 +36,7 @@ struct ITAAudioStreamLog : public ITALogDataBase
os << uiBlockId;
os << "\t" << std::setprecision( 12 ) << dWorldTimeStamp;
os << "\t" << std::setprecision( 12 ) << dStreamingTimeCode;
os << "\t" << iStreamingStatus;
os << "\t" << sStreamingStatus;
os << "\t" << iFreeSamples;
os << std::endl;
return os;
......@@ -45,7 +45,7 @@ struct ITAAudioStreamLog : public ITALogDataBase
unsigned int uiBlockId; //!< Block identifier (audio streaming)
double dWorldTimeStamp;
double dStreamingTimeCode;
int iStreamingStatus; //!< ... usw
std::string sStreamingStatus;
int iFreeSamples;
};
......@@ -242,7 +242,7 @@ void CITANetAudioStream::IncrementBlockPointer()
m_bRingBufferFull = false;
ITAAudioStreamLog oLog;
oLog.iStreamingStatus = m_iStreamingStatus;
oLog.sStreamingStatus = GetStreamingStatusString( m_iStreamingStatus );
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime();
oLog.dStreamingTimeCode = m_dLastStreamingTimeCode;
oLog.uiBlockId = ++iAudioStreamingBlockID;
......@@ -323,6 +323,24 @@ int CITANetAudioStream::GetRingBufferFreeSamples() const
return iFreeSamples;
}
std::string CITANetAudioStream::GetStreamingStatusString( int iStreamingStatus )
{
if( iStreamingStatus == CITANetAudioStream::INVALID )
return "INVALID";
if( iStreamingStatus == CITANetAudioStream::STOPPED )
return "STOPPED";
if( iStreamingStatus == CITANetAudioStream::CONNECTED )
return "CONNECTED";
if( iStreamingStatus == CITANetAudioStream::STREAMING )
return "STREAMING";
if( iStreamingStatus == CITANetAudioStream::BUFFER_UNDERRUN )
return "BUFFER_UNDERRUN";
if( iStreamingStatus == CITANetAudioStream::BUFFER_OVERRUN )
return "BUFFER_OVERRUN";
return "UNKOWN";
}
std::string CITANetAudioStream::GetNetAudioStreamLoggerBaseName() const
{
return m_sNetAudioStreamLoggerBaseName;
......
......@@ -19,7 +19,6 @@ struct ITAClientLog : public ITALogDataBase
os << "\t" << "WorldTimeStamp";
os << "\t" << "ProtocolStatus";
os << "\t" << "FreeSamples";
os << "\t" << "Channel";
os << std::endl;
return os;
};
......@@ -30,7 +29,6 @@ struct ITAClientLog : public ITALogDataBase
os << "\t" << std::setprecision( 12 ) << dWorldTimeStamp;
os << "\t" << iProtocolStatus;
os << "\t" << iFreeSamples;
os << "\t" << iChannel;
os << std::endl;
return os;
};
......@@ -39,7 +37,6 @@ struct ITAClientLog : public ITALogDataBase
double dWorldTimeStamp;
int iProtocolStatus; //!< ... usw
int iFreeSamples;
int iChannel;
};
......@@ -79,6 +76,9 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
delete m_pClientLogger;
delete m_pClient;
delete m_pMessage;
vstr::out() << "Try-read block calc time (ms): " << m_swTryReadBlockStats.ToString() << endl;
vstr::out() << "Try-read access time : " << m_swTryReadAccessStats.ToString() << endl;
}
bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPort )
......@@ -123,7 +123,6 @@ bool CITANetAudioStreamingClient::LoopBody()
ITAClientLog oLog;
oLog.uiBlockId = ++m_iStreamingBlockId;
oLog.iChannel = m_pStream->GetNumberOfChannels();
oLog.iFreeSamples = m_pStream->GetRingBufferFreeSamples();
oLog.iProtocolStatus = CITANetAudioProtocol::NP_CLIENT_IDLE;
......@@ -155,10 +154,13 @@ bool CITANetAudioStreamingClient::LoopBody()
// Try-read message (blocking for a timeout of 1ms)
m_pMessage->ResetMessage();
m_swTryReadStats.start();
m_swTryReadBlockStats.start();
m_swTryReadAccessStats.start();
if( m_pMessage->ReadMessage( 1 ) )
{
m_swTryReadStats.stop();
double dAccessTime = m_swTryReadAccessStats.stop();
int iMsgType = m_pMessage->GetMessageType();
switch( iMsgType )
{
......@@ -192,7 +194,7 @@ bool CITANetAudioStreamingClient::LoopBody()
oLog.iProtocolStatus = iMsgType;
}
m_swTryReadStats.stop();
m_swTryReadBlockStats.stop();
m_pClientLogger->log( oLog );
......
......@@ -23,7 +23,8 @@ const static int g_iServerPort = 12480;
const static double g_dSampleRate = 44100;
const static int g_iBlockLength = 512;
const static int g_iChannels = 2;
const static int g_iTargetLatencySamples = 512;
const static int g_iTargetLatencySamples = g_iBlockLength * 10;
const static int g_iRingerBufferSize = g_iBlockLength * 10;
class CServer : public VistaThread
{
......@@ -71,7 +72,7 @@ int main( int, char** )
CServer* pServer = new CServer( g_sInputFilePath );
// Client dumping received stream and mixing down to two channels
CITANetAudioStream oNetAudioStream( g_iChannels, g_dSampleRate, g_iBlockLength, 20 * g_iBlockLength );
CITANetAudioStream oNetAudioStream( g_iChannels, g_dSampleRate, g_iBlockLength, g_iRingerBufferSize );
oNetAudioStream.SetNetAudioStreamingLoggerBaseName( "ITANetAudioTest_NetAudioStream" );
ITAStreamPatchbay oPatchbay( g_dSampleRate, g_iBlockLength );
......
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