Commit 836ee756 authored by Jonas Stienen's avatar Jonas Stienen
Browse files

Refactoring a lot for logging netaudio messages

parent db336c73
...@@ -47,6 +47,7 @@ class CITANetAudioStream; ...@@ -47,6 +47,7 @@ class CITANetAudioStream;
class ITA_DATA_SOURCES_API CITANetAudioProtocol class ITA_DATA_SOURCES_API CITANetAudioProtocol
{ {
public: public:
static const int NP_CLIENT_IDLE = 0;
static const int NP_CLIENT_OPEN = 100; static const int NP_CLIENT_OPEN = 100;
static const int NP_CLIENT_CLOSE = 101; static const int NP_CLIENT_CLOSE = 101;
static const int NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES = 111; static const int NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES = 111;
...@@ -65,8 +66,6 @@ public: ...@@ -65,8 +66,6 @@ public:
double dSampleRate; double dSampleRate;
int iBlockSize; int iBlockSize;
int iRingBufferSize; int iRingBufferSize;
int iTargetSampleLatency;
double dTimeIntervalSendInfos;
inline StreamingParameters() inline StreamingParameters()
{ {
...@@ -74,8 +73,6 @@ public: ...@@ -74,8 +73,6 @@ public:
dSampleRate = 0.0f; dSampleRate = 0.0f;
iBlockSize = 0; iBlockSize = 0;
iRingBufferSize = 0; iRingBufferSize = 0;
iTargetSampleLatency = 0;
dTimeIntervalSendInfos = 0;
}; };
inline bool operator==( const StreamingParameters& rhs ) inline bool operator==( const StreamingParameters& rhs )
...@@ -83,9 +80,7 @@ public: ...@@ -83,9 +80,7 @@ public:
if ( ( iChannels == rhs.iChannels ) if ( ( iChannels == rhs.iChannels )
&& ( dSampleRate == rhs.dSampleRate ) && ( dSampleRate == rhs.dSampleRate )
&& (iBlockSize == rhs.iBlockSize) && (iBlockSize == rhs.iBlockSize)
&& (iRingBufferSize == rhs.iRingBufferSize) && (iRingBufferSize == rhs.iRingBufferSize))
&& (iTargetSampleLatency == rhs.iTargetSampleLatency)
&& (dTimeIntervalSendInfos == rhs.dTimeIntervalSendInfos))
return true; return true;
else else
return false; return false;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <ITASampleFrame.h> #include <ITASampleFrame.h>
#include <ITAStreamProbe.h> #include <ITAStreamProbe.h>
#include <ITAStopWatch.h>
#include <VistaInterProcComm/Concurrency/VistaThreadEvent.h> #include <VistaInterProcComm/Concurrency/VistaThreadEvent.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h> #include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
...@@ -69,19 +70,21 @@ private: ...@@ -69,19 +70,21 @@ private:
CITANetAudioProtocol* m_pProtocol; CITANetAudioProtocol* m_pProtocol;
CITANetAudioMessage* m_pMessage; CITANetAudioMessage* m_pMessage;
VistaConnectionIP* m_pConnection; VistaConnectionIP* m_pConnection;
//VistaThreadEvent m_oBlockIncrementEvent;
ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data
CITANetAudioProtocol::StreamingParameters m_oParams; CITANetAudioProtocol::StreamingParameters m_oParams;
bool m_bStopIndicated; bool m_bStopIndicated;
bool m_bStopped; bool m_bStopped;
double m_dLastAckknowlengementTimeStamp;
int n; int m_iStreamingBlockId;
int iStreamingBlockId;
double m_dServerClockSyncRequestTimeInterval;
double m_dServerClockSyncLastSyncTime;
ITABufferedDataLoggerImplClient* m_pClientLogger; ITABufferedDataLoggerImplClient* m_pClientLogger;
ITAStopWatch m_swTryReadStats;
friend class CITANetAudioStream; friend class CITANetAudioStream;
}; };
......
...@@ -63,7 +63,7 @@ public: ...@@ -63,7 +63,7 @@ public:
CITANetAudioStreamingServer(); CITANetAudioStreamingServer();
~CITANetAudioStreamingServer(); ~CITANetAudioStreamingServer();
bool Start(const std::string& sAddress, int iPort, double dTimeIntervalCientSendStatus); bool Start( const std::string& sAddress, const int iPort, const double dTimeIntervalCientSendStatus );
bool IsClientConnected() const; bool IsClientConnected() const;
std::string GetNetworkAddress() const; std::string GetNetworkAddress() const;
int GetNetworkPort() const; int GetNetworkPort() const;
...@@ -71,13 +71,16 @@ public: ...@@ -71,13 +71,16 @@ public:
void Stop(); void Stop();
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;
void SetAutomaticUpdateRate(); void SetAutomaticUpdateRate();
void SetTargetLatencySamples( const int iTargetLatency );
void GetTargetLatencySamples() const;
protected: protected:
ITADatasource* GetInputStream() const; ITADatasource* GetInputStream() const;
...@@ -95,6 +98,7 @@ private: ...@@ -95,6 +98,7 @@ private:
int m_iUpdateStrategy; int m_iUpdateStrategy;
int m_iClientRingBufferFreeSamples; int m_iClientRingBufferFreeSamples;
int m_iTargetLatencySamples;
int m_iMaxSendBlocks; int m_iMaxSendBlocks;
double m_dLastTimeStamp; double m_dLastTimeStamp;
......
...@@ -15,45 +15,48 @@ ...@@ -15,45 +15,48 @@
static int S_nMessageIds = 0; static int S_nMessageIds = 0;
struct ITAProtocolLog : public ITALogDataBase struct ITANetAudioMessageLog : public ITALogDataBase
{ {
inline static std::ostream& outputDesc(std::ostream& os) inline static std::ostream& outputDesc( std::ostream& os )
{ {
os << "BlockId"; os << "BlockId";
os << "\t" << "WorldTimeStamp"; os << "\t" << "WorldTimeStamp";
os << "\t" << "MessageType"; os << "\t" << "MessageType";
os << "\t" << "Status"; os << "\t" << "Action";
os << "\t" << "Paketgroesse"; os << "\t" << "InternalProcessingTime";
os << "\t" << "PayloadSize";
os << std::endl; os << std::endl;
return os; return os;
}; };
inline std::ostream& outputData(std::ostream& os) const inline std::ostream& outputData( std::ostream& os ) const
{ {
os << uiBlockId; os << uiBlockId;
os << "\t" << std::setprecision(12) << dWorldTimeStamp; os << "\t" << std::setprecision( 12 ) << dWorldTimeStamp;
os << "\t" << iMessageType; os << "\t" << iMessageType;
os << "\t" << iStatus; os << "\t" << sAction;
os << "\t" << std::setprecision( 12 ) << dInternalProcessingTime;
os << "\t" << nMessagePayloadSize; os << "\t" << nMessagePayloadSize;
os << std::endl; os << std::endl;
return os; return os;
}; };
unsigned int uiBlockId; //!< Block identifier (audio streaming) unsigned int uiBlockId; //!< Block identifier (audio streaming)
double dWorldTimeStamp; double dWorldTimeStamp; //!< Time stamp at beginning of logged message process
int iMessageType; //!< ... usw int iMessageType; //!< Protocol message type
int iStatus; //!< ... usw std::string sAction; //!< Triggered action
VistaType::sint32 nMessagePayloadSize; double dInternalProcessingTime; //!< Processing within message class
VistaType::sint32 nMessagePayloadSize; //!< Data
}; };
class ITABufferedDataLoggerImplProtocol : public ITABufferedDataLogger < ITAProtocolLog > {}; class ITABufferedDataLoggerImplProtocol : public ITABufferedDataLogger < ITANetAudioMessageLog > {};
CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers ) CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwapBehavior bSwapBuffers )
: m_vecIncomingBuffer( 2048 ) : m_vecIncomingBuffer( 2048 )
, m_oOutgoing( 2048 ) , m_oOutgoing( 2048 )
, m_pConnection( NULL ) , m_pConnection( NULL )
, m_iBytesReceivedTotal(0) , m_iBytesReceivedTotal( 0 )
{ {
m_pProtocolLogger = new ITABufferedDataLoggerImplProtocol(); m_pProtocolLogger = new ITABufferedDataLoggerImplProtocol();
m_nMessageId = 0; m_nMessageId = 0;
...@@ -64,24 +67,26 @@ CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwap ...@@ -64,24 +67,26 @@ CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwap
void CITANetAudioMessage::ResetMessage() void CITANetAudioMessage::ResetMessage()
{ {
const double dInTime = ITAClock::getDefaultClock()->getTime();
ITAProtocolLog oLog; ITANetAudioMessageLog oLog;
oLog.uiBlockId = m_nMessageId; oLog.uiBlockId = m_nMessageId;
oLog.iMessageType = 0; oLog.iMessageType = 0;
oLog.nMessagePayloadSize = 0; oLog.nMessagePayloadSize = 0;
oLog.dWorldTimeStamp = dInTime;
oLog.sAction = "reset_message";
oLog.iStatus = 2; if( m_oIncoming.GetTailSize() > 0 )
if (m_oIncoming.GetTailSize() > 0)
{ {
vstr::err() << "CITANetAudioMessage::ResetMessage() called before message was fully processed!" << std::endl; vstr::err() << "CITANetAudioMessage::ResetMessage() called before message was fully processed!" << std::endl;
oLog.iStatus = -1; oLog.sAction ="reset_failed";
} }
// wait till sending is complete -> this prevents us // wait till sending is complete -> this prevents us
// from deleting the buffer while it is still being read // from deleting the buffer while it is still being read
// by the connection // by the connection
if (m_pConnection != NULL) if( m_pConnection != NULL )
m_pConnection->WaitForSendFinish(); m_pConnection->WaitForSendFinish();
m_nMessageId = S_nMessageIds++; m_nMessageId = S_nMessageIds++;
...@@ -94,11 +99,10 @@ void CITANetAudioMessage::ResetMessage() ...@@ -94,11 +99,10 @@ void CITANetAudioMessage::ResetMessage()
m_oIncoming.SetBuffer( NULL, 0 ); m_oIncoming.SetBuffer( NULL, 0 );
m_nMessageType = -1; m_nMessageType = -1;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime();
m_pProtocolLogger->log(oLog);
//m_pConnection = NULL; oLog.dInternalProcessingTime = ITAClock::getDefaultClock()->getTime() - dInTime;
m_pProtocolLogger->log( oLog );
#if NET_AUDIO_SHOW_TRAFFIC #if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [Preparing] (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl; vstr::out() << "CITANetAudioMessage [Preparing] (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
...@@ -112,7 +116,9 @@ void CITANetAudioMessage::SetConnection( VistaConnectionIP* pConn ) ...@@ -112,7 +116,9 @@ void CITANetAudioMessage::SetConnection( VistaConnectionIP* pConn )
void CITANetAudioMessage::WriteMessage() void CITANetAudioMessage::WriteMessage()
{ {
ITAProtocolLog oLog; const double dInTime = ITAClock::getDefaultClock()->getTime();
ITANetAudioMessageLog oLog;
oLog.dWorldTimeStamp = dInTime;
VistaType::byte* pBuffer = ( VistaType::byte* ) m_oOutgoing.GetBuffer(); VistaType::byte* pBuffer = ( VistaType::byte* ) m_oOutgoing.GetBuffer();
VistaType::sint32 iSwapDummy; VistaType::sint32 iSwapDummy;
...@@ -140,8 +146,8 @@ void CITANetAudioMessage::WriteMessage() ...@@ -140,8 +146,8 @@ void CITANetAudioMessage::WriteMessage()
if( m_oOutgoing.GetByteorderSwapFlag() ) if( m_oOutgoing.GetByteorderSwapFlag() )
VistaSerializingToolset::Swap4( &iSwapDummy ); VistaSerializingToolset::Swap4( &iSwapDummy );
std::memcpy( pBuffer, &iSwapDummy, sizeof( VistaType::sint32 ) ); std::memcpy( pBuffer, &iSwapDummy, sizeof( VistaType::sint32 ) );
oLog.iStatus = 0; oLog.sAction = "write_message";
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime(); oLog.dInternalProcessingTime = ITAClock::getDefaultClock()->getTime() - dInTime;
m_pProtocolLogger->log( oLog ); m_pProtocolLogger->log( oLog );
#if NET_AUDIO_SHOW_TRAFFIC #if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Writing] " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl; vstr::out() << "CITANetAudioMessage [ Writing] " << m_nMessageType << " (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
...@@ -158,30 +164,33 @@ void CITANetAudioMessage::WriteMessage() ...@@ -158,30 +164,33 @@ void CITANetAudioMessage::WriteMessage()
#endif #endif
m_pConnection->WaitForSendFinish(); m_pConnection->WaitForSendFinish();
//if( nRet != m_oOutgoing.GetBufferSize() ) if( nRet != m_oOutgoing.GetBufferSize() )
//VISTA_THROW( "ITANetAudioMessage: could not send all data from output buffer via network connection", 255 ); VISTA_THROW( "ITANetAudioMessage: could not send all data from output buffer via network connection", 255 );
} }
catch (VistaExceptionBase& ex) catch( VistaExceptionBase& ex )
{ {
ITA_EXCEPT1( NETWORK_ERROR, ex.GetExceptionText() ); ITA_EXCEPT1( NETWORK_ERROR, ex.GetExceptionText() );
} }
} }
bool CITANetAudioMessage::ReadMessage( int timeout) bool CITANetAudioMessage::ReadMessage( int timeout )
{ {
ITAProtocolLog oLog; ITANetAudioMessageLog oLog;
const double dInTime = ITAClock::getDefaultClock()->getTime();
oLog.dWorldTimeStamp = dInTime;
#if NET_AUDIO_SHOW_TRAFFIC #if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Reading ] Waiting for incoming data" << std::endl; vstr::out() << "CITANetAudioMessage [ Reading ] Waiting for incoming data" << std::endl;
#endif #endif
// WaitForIncomming Data int in ca ms // WaitForIncomming Data int in ca ms
long nIncomingBytes = m_pConnection->WaitForIncomingData( timeout ); long nIncomingBytes = m_pConnection->WaitForIncomingData( timeout );
// TODO Timer entfernen // TODO Timer entfernen
if (nIncomingBytes == -1) if( nIncomingBytes == -1 )
return false; return false;
//if (timeout != 0) //if (timeout != 0)
//nIncomingBytes = m_pConnection->WaitForIncomingData( 0 ); //nIncomingBytes = m_pConnection->WaitForIncomingData( 0 );
#if NET_AUDIO_SHOW_TRAFFIC #if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Reading ] " << nIncomingBytes << " bytes incoming" << std::endl; vstr::out() << "CITANetAudioMessage [ Reading ] " << nIncomingBytes << " bytes incoming" << std::endl;
#endif #endif
...@@ -193,24 +202,24 @@ bool CITANetAudioMessage::ReadMessage( int timeout) ...@@ -193,24 +202,24 @@ bool CITANetAudioMessage::ReadMessage( int timeout)
#if NET_AUDIO_SHOW_TRAFFIC #if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Reading ] Expecting " << nMessagePayloadSize << " bytes message payload" << std::endl; vstr::out() << "CITANetAudioMessage [ Reading ] Expecting " << nMessagePayloadSize << " bytes message payload" << std::endl;
#endif #endif
if (nMessagePayloadSize <= 0) if( nMessagePayloadSize <= 0 )
return false; return false;
// we need at least the two protocol ints // we need at least the two protocol ints
//assert( nMessagePayloadSize >= 2 * sizeof( VistaType::sint32 ) ); //assert( nMessagePayloadSize >= 2 * sizeof( VistaType::sint32 ) );
if( nMessagePayloadSize > ( int ) m_vecIncomingBuffer.size() ) if( nMessagePayloadSize > ( int ) m_vecIncomingBuffer.size() )
m_vecIncomingBuffer.resize( nMessagePayloadSize ); m_vecIncomingBuffer.resize( nMessagePayloadSize );
// Receive all incoming data (potentially splitted) // Receive all incoming data (potentially splitted)
while (nMessagePayloadSize > m_iBytesReceivedTotal) while( ( unsigned long ) nMessagePayloadSize > m_iBytesReceivedTotal )
{ {
int iIncommingBytes = m_pConnection->WaitForIncomingData( 0 ); int iIncommingBytes = m_pConnection->WaitForIncomingData( 0 );
int iBytesReceived; int iBytesReceived;
if ( nMessagePayloadSize < iIncommingBytes ) if( nMessagePayloadSize < iIncommingBytes )
iBytesReceived = m_pConnection->Receive(&m_vecIncomingBuffer[m_iBytesReceivedTotal], nMessagePayloadSize - m_iBytesReceivedTotal); iBytesReceived = m_pConnection->Receive( &m_vecIncomingBuffer[ m_iBytesReceivedTotal ], nMessagePayloadSize - m_iBytesReceivedTotal );
else else
iBytesReceived = m_pConnection->Receive(&m_vecIncomingBuffer[m_iBytesReceivedTotal], iIncommingBytes); iBytesReceived = m_pConnection->Receive( &m_vecIncomingBuffer[ m_iBytesReceivedTotal ], iIncommingBytes );
m_iBytesReceivedTotal += iBytesReceived; m_iBytesReceivedTotal += iBytesReceived;
#if NET_AUDIO_SHOW_TRAFFIC #if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ CITANetAudioMessage ] " << std::setw( 3 ) << std::floor( iBytesReceivedTotal / float( nMessagePayloadSize ) * 100.0f ) << "% transmitted" << std::endl; vstr::out() << "[ CITANetAudioMessage ] " << std::setw( 3 ) << std::floor( iBytesReceivedTotal / float( nMessagePayloadSize ) * 100.0f ) << "% transmitted" << std::endl;
...@@ -218,14 +227,14 @@ bool CITANetAudioMessage::ReadMessage( int timeout) ...@@ -218,14 +227,14 @@ bool CITANetAudioMessage::ReadMessage( int timeout)
} }
m_iBytesReceivedTotal = 0; m_iBytesReceivedTotal = 0;
oLog.iStatus = 1; oLog.sAction = "read_message";
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime();
// Transfer data into members // Transfer data into members
m_oIncoming.SetBuffer( &m_vecIncomingBuffer[ 0 ], nMessagePayloadSize, false ); m_oIncoming.SetBuffer( &m_vecIncomingBuffer[ 0 ], nMessagePayloadSize, false );
m_nMessageType = ReadInt(); m_nMessageType = ReadInt();
m_nMessageId = ReadInt(); m_nMessageId = ReadInt();
oLog.iMessageType = m_nMessageType; oLog.iMessageType = m_nMessageType;
oLog.uiBlockId = m_nMessageId; oLog.uiBlockId = m_nMessageId;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime() - dInTime;
m_pProtocolLogger->log( oLog ); m_pProtocolLogger->log( oLog );
#if NET_AUDIO_SHOW_TRAFFIC #if NET_AUDIO_SHOW_TRAFFIC
...@@ -241,7 +250,6 @@ int CITANetAudioMessage::GetMessageType() const ...@@ -241,7 +250,6 @@ int CITANetAudioMessage::GetMessageType() const
void CITANetAudioMessage::SetMessageType( int nType ) void CITANetAudioMessage::SetMessageType( int nType )
{ {
//assert( m_nMessageType == CITANetAudioProtocol::NP_INVALID ); // should only be set once
m_nMessageType = nType; m_nMessageType = nType;
} }
...@@ -354,12 +362,13 @@ VistaConnectionIP* CITANetAudioMessage::GetConnection() const ...@@ -354,12 +362,13 @@ VistaConnectionIP* CITANetAudioMessage::GetConnection() const
return m_pConnection; return m_pConnection;
} }
void CITANetAudioMessage::ClearConnection() { void CITANetAudioMessage::ClearConnection()
{
m_pConnection = NULL; m_pConnection = NULL;
delete m_pProtocolLogger; delete m_pProtocolLogger;
} }
void CITANetAudioMessage::WriteIntVector( const std::vector<int> viData ) void CITANetAudioMessage::WriteIntVector( const std::vector< int > viData )
{ {
int iSize = ( int ) viData.size(); int iSize = ( int ) viData.size();
WriteInt( iSize ); WriteInt( iSize );
...@@ -382,13 +391,11 @@ CITANetAudioProtocol::StreamingParameters CITANetAudioMessage::ReadStreamingPara ...@@ -382,13 +391,11 @@ CITANetAudioProtocol::StreamingParameters CITANetAudioMessage::ReadStreamingPara
CITANetAudioProtocol::StreamingParameters oParams; CITANetAudioProtocol::StreamingParameters oParams;
oParams.iChannels = ReadInt(); oParams.iChannels = ReadInt();
oParams.dSampleRate = ReadDouble( ); oParams.dSampleRate = ReadDouble();
oParams.iBlockSize = ReadInt(); oParams.iBlockSize = ReadInt();
oParams.iRingBufferSize = ReadInt(); oParams.iRingBufferSize = ReadInt();
oParams.iTargetSampleLatency = ReadInt();
oParams.dTimeIntervalSendInfos = ReadDouble();
std::string paras = std::string( "NetAudioLogProtocol" ) + std::string( "_BS" ) + std::to_string( oParams.iBlockSize ) + std::string( "_Ch" ) + std::to_string( oParams.iChannels ) + std::string( "_tl" ) + std::to_string( oParams.iTargetSampleLatency ) + std::string( ".txt" ); std::string paras = std::string( "NetAudioLogProtocol" ) + std::string( "_BS" ) + std::to_string( oParams.iBlockSize ) + std::string( "_Ch" ) + std::to_string( oParams.iChannels ) + std::string( "_tl" ) + std::string( ".txt" );
m_pProtocolLogger->setOutputFile( paras ); m_pProtocolLogger->setOutputFile( paras );
return oParams; return oParams;
...@@ -398,13 +405,11 @@ void CITANetAudioMessage::WriteStreamingParameters( const CITANetAudioProtocol:: ...@@ -398,13 +405,11 @@ void CITANetAudioMessage::WriteStreamingParameters( const CITANetAudioProtocol::
{ {
WriteInt( oParams.iChannels ); WriteInt( oParams.iChannels );
WriteDouble( oParams.dSampleRate ); WriteDouble( oParams.dSampleRate );
WriteInt(oParams.iBlockSize); WriteInt( oParams.iBlockSize );
WriteInt(oParams.iRingBufferSize); WriteInt( oParams.iRingBufferSize );
WriteInt(oParams.iTargetSampleLatency);
WriteDouble(oParams.dTimeIntervalSendInfos);
std::string paras = std::string("NetAudioLogProtocol") + std::string("_BS") + std::to_string(oParams.iBlockSize) + std::string("_Ch") + std::to_string(oParams.iChannels) + std::string("_tl") + std::to_string(oParams.iTargetSampleLatency) + std::string(".txt"); std::string paras = std::string( "NetAudioLogProtocol" ) + std::string( "_BS" ) + std::to_string( oParams.iBlockSize ) + std::string( "_Ch" ) + std::to_string( oParams.iChannels ) + std::string( "_tl" ) + std::string( ".txt" );
m_pProtocolLogger->setOutputFile(paras); m_pProtocolLogger->setOutputFile( paras );
} }
int CITANetAudioMessage::ReadRingBufferSize() int CITANetAudioMessage::ReadRingBufferSize()
...@@ -435,12 +440,8 @@ void CITANetAudioMessage::ReadSampleFrame( ITASampleFrame* pSampleFrame ) ...@@ -435,12 +440,8 @@ void CITANetAudioMessage::ReadSampleFrame( ITASampleFrame* pSampleFrame )
pSampleFrame->init( iChannels, iSamples, false ); pSampleFrame->init( iChannels, iSamples, false );
for( int i = 0; i < iChannels; i++ ) for( int i = 0; i < iChannels; i++ )
{
for( int j = 0; j < iSamples; j++ ) for( int j = 0; j < iSamples; j++ )
{
( *pSampleFrame )[ i ][ j ] = ReadFloat(); ( *pSampleFrame )[ i ][ j ] = ReadFloat();
}
}
} }
void CITANetAudioMessage::WriteSampleFrame( ITASampleFrame* pSamples ) void CITANetAudioMessage::WriteSampleFrame( ITASampleFrame* pSamples )
...@@ -449,11 +450,7 @@ void CITANetAudioMessage::WriteSampleFrame( ITASampleFrame* pSamples ) ...@@ -449,11 +450,7 @@ void CITANetAudioMessage::WriteSampleFrame( ITASampleFrame* pSamples )
WriteInt( pSamples->GetLength() ); WriteInt( pSamples->GetLength() );
for( int i = 0; i < pSamples->channels(); i++ ) for( int i = 0; i < pSamples->channels(); i++ )
{
for( int j = 0; j < pSamples->GetLength(); j++ ) for( int j = 0; j < pSamples->GetLength(); j++ )
{
WriteFloat( ( *pSamples )[ i ][ j ] ); WriteFloat( ( *pSamples )[ i ][ j ] );
}
}
} }
...@@ -51,21 +51,22 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP ...@@ -51,21 +51,22 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
, m_pConnection( NULL ) , m_pConnection( NULL )
, m_bStopIndicated( false ) , m_bStopIndicated( false )
, m_bStopped( false ) , m_bStopped( false )
, m_iStreamingBlockId( 0 )
, m_dServerClockSyncRequestTimeInterval( 0.1f )
, m_dServerClockSyncLastSyncTime( 0.0f )
{ {
m_pClient = new CITANetAudioClient(); m_pClient = new CITANetAudioClient();
n = 0;
m_oParams.iChannels = pParent->GetNumberOfChannels(); m_oParams.iChannels = pParent->GetNumberOfChannels();
m_oParams.dSampleRate = pParent->GetSampleRate( ); m_oParams.dSampleRate = pParent->GetSampleRate();
m_oParams.iBlockSize = pParent->GetBlocklength(); m_oParams.iBlockSize = pParent->GetBlocklength();
m_oParams.iRingBufferSize = pParent->GetRingBufferSize();