Commit 01cb7c2a authored by Anne Heimes's avatar Anne Heimes

sendet jetzt bis buffer voll und horcht erst dann - not running

parent a37247be
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include <ITADataSource.h> #include <ITADataSource.h>
#include <ITANetAudioMessage.h> #include <ITANetAudioMessage.h>
#include <ITAException.h> #include <ITAException.h>
#include <ITAStreamInfo.h> #include <ITAStreamInfo.h>
#include <ITAClock.h> #include <ITAClock.h>
// Vista includes // Vista includes
...@@ -15,39 +15,39 @@ ...@@ -15,39 +15,39 @@
#include <VistaInterProcComm/IPNet/VistaTCPSocket.h> #include <VistaInterProcComm/IPNet/VistaTCPSocket.h>
#include <VistaBase/VistaTimeUtils.h> #include <VistaBase/VistaTimeUtils.h>
#include <VistaInterProcComm/IPNet/VistaIPAddress.h> #include <VistaInterProcComm/IPNet/VistaIPAddress.h>
#include <VistaBase/VistaStreamUtils.h> #include <VistaBase/VistaStreamUtils.h>
#include <ITADataLog.h> #include <ITADataLog.h>
// STL // STL
#include <cmath> #include <cmath>
#include <cassert> #include <cassert>
struct ITAServerLog : public ITALogDataBase struct ITAServerLog : 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" << "ProtocolStatus"; os << "\t" << "ProtocolStatus";
os << "\t" << "FreeSamples"; os << "\t" << "FreeSamples";
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" << iProtocolStatus; os << "\t" << iProtocolStatus;
os << "\t" << iFreeSamples; os << "\t" << iFreeSamples;
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;
int iProtocolStatus; //!< ... usw int iProtocolStatus; //!< ... usw
int iFreeSamples; int iFreeSamples;
}; };
class ITABufferedDataLoggerImplServer : public ITABufferedDataLogger < ITAServerLog > {}; class ITABufferedDataLoggerImplServer : public ITABufferedDataLogger < ITAServerLog > {};
...@@ -57,7 +57,7 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer( ) ...@@ -57,7 +57,7 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer( )
, m_iUpdateStrategy( AUTO ) , m_iUpdateStrategy( AUTO )
, m_pConnection( NULL ) , m_pConnection( NULL )
, m_pNetAudioServer( new CITANetAudioServer( ) ) , m_pNetAudioServer( new CITANetAudioServer( ) )
{ {
iServerBlockId = 0; iServerBlockId = 0;
} }
...@@ -74,7 +74,7 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort ...@@ -74,7 +74,7 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
m_pMessage = new CITANetAudioMessage( m_pConnection->GetByteorderSwapFlag( ) ); m_pMessage = new CITANetAudioMessage( m_pConnection->GetByteorderSwapFlag( ) );
m_pMessage->ResetMessage( ); m_pMessage->ResetMessage( );
m_pMessage->SetConnection( m_pConnection ); m_pMessage->SetConnection( m_pConnection );
while ( !m_pMessage->ReadMessage( 0 ) ); //blocking while ( !m_pMessage->ReadMessage( 0 ) ); //blocking
assert( m_pMessage->GetMessageType( ) == CITANetAudioProtocol::NP_CLIENT_OPEN ); assert( m_pMessage->GetMessageType( ) == CITANetAudioProtocol::NP_CLIENT_OPEN );
CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters( ); CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters( );
...@@ -93,9 +93,9 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort ...@@ -93,9 +93,9 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
vstr::out() << "[ITANetAudioStreamingServer] Server and client parameters mismatch detected. Will notify client and stop." << std::endl; vstr::out() << "[ITANetAudioStreamingServer] Server and client parameters mismatch detected. Will notify client and stop." << std::endl;
#endif #endif
} }
std::string paras = std::string( "NetAudioLogServer" ) + std::string( "_BS" ) + std::to_string( m_oServerParams.iBlockSize ) + std::string( "_Ch" ) + std::to_string( m_oServerParams.iChannels ) + std::string( ".txt" ); std::string paras = std::string( "NetAudioLogServer" ) + std::string( "_BS" ) + std::to_string( m_oServerParams.iBlockSize ) + std::string( "_Ch" ) + std::to_string( m_oServerParams.iChannels ) + std::string( ".txt" );
m_pServerLogger = new ITABufferedDataLoggerImplServer( ); m_pServerLogger = new ITABufferedDataLoggerImplServer( );
m_pServerLogger->setOutputFile( paras ); m_pServerLogger->setOutputFile( paras );
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_SERVER_OPEN ); m_pMessage->SetMessageType( CITANetAudioProtocol::NP_SERVER_OPEN );
...@@ -118,24 +118,27 @@ bool CITANetAudioStreamingServer::LoopBody( ) ...@@ -118,24 +118,27 @@ bool CITANetAudioStreamingServer::LoopBody( )
if ( m_iClientRingBufferFreeSamples >= int( m_pInputStream->GetBlocklength( ) ) ) if ( m_iClientRingBufferFreeSamples >= int( m_pInputStream->GetBlocklength( ) ) )
{ {
// Send Samples // Send Samples
for ( int i = 0; i < int( m_pInputStream->GetNumberOfChannels( ) ); i++ ) while ( m_iClientRingBufferFreeSamples >= int( m_pInputStream->GetBlocklength( ) ) )
{ {
ITAStreamInfo oStreamInfo; for ( int i = 0; i < int( m_pInputStream->GetNumberOfChannels( ) ); i++ )
oStreamInfo.nSamples = m_sfTempTransmitBuffer.GetLength( ); {
const float* pfData = m_pInputStream->GetBlockPointer( i, &oStreamInfo ); ITAStreamInfo oStreamInfo;
if ( pfData != 0 ) oStreamInfo.nSamples = m_sfTempTransmitBuffer.GetLength( );
m_sfTempTransmitBuffer[ i ].write( pfData, m_sfTempTransmitBuffer.GetLength( ) ); const float* pfData = m_pInputStream->GetBlockPointer( i, &oStreamInfo );
} if ( pfData != 0 )
m_pInputStream->IncrementBlockPointer( ); m_sfTempTransmitBuffer[ i ].write( pfData, m_sfTempTransmitBuffer.GetLength( ) );
iMsgType = CITANetAudioProtocol::NP_SERVER_SENDING_SAMPLES; }
m_pMessage->SetMessageType( iMsgType ); m_pInputStream->IncrementBlockPointer( );
m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer ); iMsgType = CITANetAudioProtocol::NP_SERVER_SENDING_SAMPLES;
m_pMessage->WriteMessage( ); m_pMessage->SetMessageType( iMsgType );
m_iClientRingBufferFreeSamples -= m_sfTempTransmitBuffer.GetLength( ); m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer );
m_pMessage->WriteMessage( );
m_iClientRingBufferFreeSamples -= m_sfTempTransmitBuffer.GetLength( );
#ifdef NET_AUDIO_SHOW_TRAFFIC #ifdef NET_AUDIO_SHOW_TRAFFIC
vstr::out( ) << "[ITANetAudioStreamingServer] Transmitted " << m_sfTempTransmitBuffer.GetLength( ) << " samples for " vstr::out( ) << "[ITANetAudioStreamingServer] Transmitted " << m_sfTempTransmitBuffer.GetLength( ) << " samples for "
<< m_pInputStream->GetNumberOfChannels( ) << " channels" << std::endl; << m_pInputStream->GetNumberOfChannels( ) << " channels" << std::endl;
#endif #endif
}
} }
else else
{ {
...@@ -148,9 +151,9 @@ bool CITANetAudioStreamingServer::LoopBody( ) ...@@ -148,9 +151,9 @@ bool CITANetAudioStreamingServer::LoopBody( )
vstr::out( ) << "[ITANetAudioStreamingServer] Not enough free samples in client buffer, requesting a trigger when more free samples available" << std::endl; vstr::out( ) << "[ITANetAudioStreamingServer] Not enough free samples in client buffer, requesting a trigger when more free samples available" << std::endl;
#endif #endif
} }
oLog.iFreeSamples = m_iClientRingBufferFreeSamples; oLog.iFreeSamples = m_iClientRingBufferFreeSamples;
oLog.iProtocolStatus = iMsgType; oLog.iProtocolStatus = iMsgType;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock( )->getTime( ); oLog.dWorldTimeStamp = ITAClock::getDefaultClock( )->getTime( );
m_pServerLogger->log( oLog ); m_pServerLogger->log( oLog );
...@@ -158,7 +161,7 @@ bool CITANetAudioStreamingServer::LoopBody( ) ...@@ -158,7 +161,7 @@ bool CITANetAudioStreamingServer::LoopBody( )
//m_pMessage->SetConnection( m_pConnection ); //m_pMessage->SetConnection( m_pConnection );
m_pMessage->ResetMessage( ); m_pMessage->ResetMessage( );
if ( m_pMessage->ReadMessage( 1 ) ) if ( m_pMessage->ReadMessage( 1 ) )
{ {
ITAServerLog oLog; ITAServerLog oLog;
oLog.uiBlockId = ++iServerBlockId; oLog.uiBlockId = ++iServerBlockId;
...@@ -184,12 +187,12 @@ bool CITANetAudioStreamingServer::LoopBody( ) ...@@ -184,12 +187,12 @@ bool CITANetAudioStreamingServer::LoopBody( )
vstr::out( ) << "[ITANetAudioStreamingServer] Unkown protocol type : " << iMsgType << std::endl; vstr::out( ) << "[ITANetAudioStreamingServer] Unkown protocol type : " << iMsgType << std::endl;
break; break;
} }
} }
oLog.iFreeSamples = m_iClientRingBufferFreeSamples; oLog.iFreeSamples = m_iClientRingBufferFreeSamples;
oLog.iProtocolStatus = iMsgType; oLog.iProtocolStatus = iMsgType;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock( )->getTime( ); oLog.dWorldTimeStamp = ITAClock::getDefaultClock( )->getTime( );
m_pServerLogger->log( oLog ); m_pServerLogger->log( oLog );
} }
return false; return false;
......
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