Commit 856ce0b9 authored by Anne's avatar Anne

merge fixed bodyloop

parent 5c42938a
...@@ -78,7 +78,10 @@ public: ...@@ -78,7 +78,10 @@ public:
void WriteString( const std::string& ); void WriteString( const std::string& );
void WriteIntVector( const std::vector< int > ); void WriteIntVector( const std::vector< int > );
void WriteFloatVector( const std::vector< float > ); void WriteFloatVector( const std::vector< float > );
void WriteStreamingParameters( const CITANetAudioProtocol::StreamingParameters &); void WriteStreamingParameters(const CITANetAudioProtocol::StreamingParameters &);
void WriteRingBufferSize(const int);
void WriteRingBufferFree(const int);
void WriteSampleFrame(ITASampleFrame*);
std::string ReadString(); std::string ReadString();
int ReadInt(); int ReadInt();
...@@ -88,7 +91,10 @@ public: ...@@ -88,7 +91,10 @@ public:
double ReadDouble(); double ReadDouble();
std::vector< int > ReadIntVector(); std::vector< int > ReadIntVector();
std::vector< float > ReadFloatVector(); std::vector< float > ReadFloatVector();
CITANetAudioProtocol::StreamingParameters ReadStreamingParameters(); CITANetAudioProtocol::StreamingParameters ReadStreamingParameters();
int ReadRingBufferSize();
int ReadRingBufferFree();
void ReadSampleFrame(ITASampleFrame* pSampleFrame);
private: private:
......
...@@ -74,8 +74,6 @@ public: ...@@ -74,8 +74,6 @@ public:
void SetAutomaticUpdateRate(); void SetAutomaticUpdateRate();
bool LoopBody();
protected: protected:
int Transmit( const ITASampleFrame& sfNewSamples, int iNumSamples ); int Transmit( const ITASampleFrame& sfNewSamples, int iNumSamples );
ITADatasource* GetInputStream() const; ITADatasource* GetInputStream() const;
......
This diff is collapsed.
...@@ -24,7 +24,6 @@ CITANetAudioServer::CITANetAudioServer() ...@@ -24,7 +24,6 @@ CITANetAudioServer::CITANetAudioServer()
, m_pSocket( NULL ) , m_pSocket( NULL )
, m_pConnection( NULL ) , m_pConnection( NULL )
, m_iServerPort( -1 ) , m_iServerPort( -1 )
, m_pConnection( NULL )
{ {
}; };
......
...@@ -13,9 +13,9 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP ...@@ -13,9 +13,9 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
{ {
m_pClient = new CITANetAudioClient(); m_pClient = new CITANetAudioClient();
m_oClientParams.iChannels = pParent->GetNumberOfChannels(); m_oParams.iChannels = pParent->GetNumberOfChannels();
m_oClientParams.dSampleRate = pParent->GetSampleRate(); m_oParams.dSampleRate = pParent->GetSampleRate();
m_oClientParams.iBlockSize = pParent->GetBlocklength(); m_oParams.iBlockSize = pParent->GetBlocklength();
m_pMessage = new CITANetAudioMessage( VistaSerializingToolset::SWAPS_MULTIBYTE_VALUES ); m_pMessage = new CITANetAudioMessage( VistaSerializingToolset::SWAPS_MULTIBYTE_VALUES );
} }
...@@ -24,6 +24,8 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient() ...@@ -24,6 +24,8 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
{ {
if( m_pConnection ) if( m_pConnection )
{ {
m_pMessage->ResetMessage();
m_pMessage->SetConnection( m_pConnection );
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_CLOSE ); m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_CLOSE );
m_pMessage->WriteAnswer(); m_pMessage->WriteAnswer();
} }
...@@ -79,9 +81,17 @@ bool CITANetAudioStreamingClient::LoopBody() ...@@ -79,9 +81,17 @@ bool CITANetAudioStreamingClient::LoopBody()
if( m_bStopIndicated ) if( m_bStopIndicated )
return true; return true;
// Receive message // send freesamples
m_pMessage->ReadMessage(); m_pMessage->ResetMessage();
switch( m_pMessage->GetMessageType() ) m_pMessage->SetConnection(m_pConnection);
m_pMessage->SetMessageType(CITANetAudioProtocol::NP_CLIENT_WAITING_FOR_SAMPLES);
m_pMessage->WriteInt( m_pStream->GetRingbufferFreeSamples() );
m_pMessage->WriteMessage();
m_pMessage->ReadAnswer();
switch( m_pMessage->GetAnswerType() )
{ {
case CITANetAudioProtocol::NP_INVALID: case CITANetAudioProtocol::NP_INVALID:
break; break;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <ITANetAudioMessage.h> #include <ITANetAudioMessage.h>
// ITA includes // ITA includes
#include <ITADataSource.h> #include <ITADataSource.h>
#include <ITANetAudioMessage.h> #include <ITANetAudioMessage.h>
#include <ITAException.h> #include <ITAException.h>
#include <ITAStreamInfo.h> #include <ITAStreamInfo.h>
...@@ -70,10 +70,6 @@ int CITANetAudioStreamingServer::GetNetworkPort() const ...@@ -70,10 +70,6 @@ int CITANetAudioStreamingServer::GetNetworkPort() const
{ {
return m_pNetAudioServer->GetNetworkPort(); return m_pNetAudioServer->GetNetworkPort();
} }
bool CITANetAudioStreamingServer::LoopBody()
{
return true;
}
void CITANetAudioStreamingServer::Stop() void CITANetAudioStreamingServer::Stop()
{ {
...@@ -118,16 +114,26 @@ bool CITANetAudioStreamingServer::LoopBody() ...@@ -118,16 +114,26 @@ bool CITANetAudioStreamingServer::LoopBody()
case CITANetAudioProtocol::NP_CLIENT_WAITING_FOR_SAMPLES: case CITANetAudioProtocol::NP_CLIENT_WAITING_FOR_SAMPLES:
if( m_pInputStream ) if( m_pInputStream )
{ {
int iFreeSamples = m_pMessage->ReadInt();
if (iFreeSamples < m_pInputStream->GetBlocklength()) {
// zurückmelden und warten auf exeption
break;
}
for( int i = 0; i < m_pInputStream->GetNumberOfChannels(); i++ ) for( int i = 0; i < m_pInputStream->GetNumberOfChannels(); i++ )
{ {
ITAStreamInfo oStreamInfo; ITAStreamInfo oStreamInfo;
const float* pfData = m_pInputStream->GetBlockPointer( i, &oStreamInfo ); const float* pfData = m_pInputStream->GetBlockPointer( i, &oStreamInfo );
m_sfTempTransmitBuffer[ i ].write( pfData, m_pInputStream->GetBlocklength() ); m_sfTempTransmitBuffer[ i ].write( pfData, m_pInputStream->GetBlocklength() );
} }
m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer );
} }
//m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer );
m_pMessage->WriteAnswer(); m_pMessage->WriteAnswer();
m_pInputStream->IncrementBlockPointer();
float fTimeOut = m_pInputStream->GetBlocklength() / m_pInputStream->GetSampleRate();
//VistaTimeUtils::Sleep( (int) ( fTimeOut * 1000 ) );
break; break;
} }
......
...@@ -16,8 +16,8 @@ int main( int , char** ) ...@@ -16,8 +16,8 @@ int main( int , char** )
{ {
ITAStreamFunctionGenerator oGenerator( 1, g_dSampleRate, g_iBlockLength, ITAStreamFunctionGenerator::SINE, 456.78f, 0.81f, true ); ITAStreamFunctionGenerator oGenerator( 1, g_dSampleRate, g_iBlockLength, ITAStreamFunctionGenerator::SINE, 456.78f, 0.81f, true );
//CITANetAudioStream oStreamingServer; CITANetAudioStreamingServer oStreamingServer;
//oStreamingServer.SetInputStream( &oGenerator ); oStreamingServer.SetInputStream( &oGenerator );
cout << "Starting server and waiting for connections on '" << g_sServerName << "' on port " << g_iServerPort << endl; cout << "Starting server and waiting for connections on '" << g_sServerName << "' on port " << g_iServerPort << endl;
oStreamingServer.Start( g_sServerName, g_iServerPort ); oStreamingServer.Start( g_sServerName, g_iServerPort );
......
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