Commit 856ce0b9 authored by Anne's avatar Anne

merge fixed bodyloop

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