Commit 3bbfc4dc authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

adding comments and todos, removing outcommented lines

also changes in protocol id (!)
Some fixes after closing connection
parent 5e71a29e
...@@ -28,6 +28,7 @@ class VistaConnectionIP; ...@@ -28,6 +28,7 @@ class VistaConnectionIP;
//! A network audio client that connects to a network audio server //! A network audio client that connects to a network audio server
/** /**
* Use CITANetAudioStreamingClient to start an audio stream with the connection of this client. * Use CITANetAudioStreamingClient to start an audio stream with the connection of this client.
* This class is basically a helper around Vista TCP/IP network functionality.
* *
*/ */
class CITANetAudioClient class CITANetAudioClient
......
...@@ -54,7 +54,7 @@ public: ...@@ -54,7 +54,7 @@ public:
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_WAITING_FOR_SAMPLES = 102; static const int NP_CLIENT_WAITING_FOR_SAMPLES = 111;
static const int NP_SERVER_CLOSE = 200; static const int NP_SERVER_CLOSE = 200;
static const int NP_SERVER_OPEN = 201; static const int NP_SERVER_OPEN = 201;
......
...@@ -37,6 +37,8 @@ class VistaTCPSocket; ...@@ -37,6 +37,8 @@ class VistaTCPSocket;
/** /**
* Can be connected to an ITADataSource as a streaming source * Can be connected to an ITADataSource as a streaming source
* or to a user-implemented sample producer, i.e. an audio sythesizer. * or to a user-implemented sample producer, i.e. an audio sythesizer.
*
* @todo: move to src folder
*/ */
class ITA_DATA_SOURCES_API CITANetAudioServer class ITA_DATA_SOURCES_API CITANetAudioServer
{ {
......
...@@ -40,7 +40,9 @@ class CITANetAudioStream; ...@@ -40,7 +40,9 @@ class CITANetAudioStream;
//! Network audio streaming client //! Network audio streaming client
/** /**
* Audio streaming for a signal source that is connected via TCP/IP. * Audio streaming for a signal source that is connected via TCP/IP.
* Implements the ITA network protocol for audio streaming in client side. * Implements the ITA network protocol for audio streaming on client side.
*
* @todo: move to src folder
* *
* \note not thread-safe * \note not thread-safe
*/ */
......
...@@ -31,7 +31,6 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient() ...@@ -31,7 +31,6 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
m_pMessage->SetConnection( m_pConnection ); m_pMessage->SetConnection( m_pConnection );
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_CLOSE ); m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_CLOSE );
m_pMessage->WriteMessage(); m_pMessage->WriteMessage();
m_pMessage->ReadAnswer();
m_pClient->Disconnect(); m_pClient->Disconnect();
} }
} }
...@@ -99,7 +98,6 @@ bool CITANetAudioStreamingClient::LoopBody() ...@@ -99,7 +98,6 @@ bool CITANetAudioStreamingClient::LoopBody()
case CITANetAudioProtocol::NP_SERVER_WAITING_FOR_TRIGGER: case CITANetAudioProtocol::NP_SERVER_WAITING_FOR_TRIGGER:
// Wait until block increment is triggered by audio context (more free samples in ring buffer) // Wait until block increment is triggered by audio context (more free samples in ring buffer)
//std::cout << "Will wait for block increment" << std::endl;
m_oBlockIncrementEvent.WaitForEvent( true ); m_oBlockIncrementEvent.WaitForEvent( true );
break; break;
...@@ -107,7 +105,6 @@ bool CITANetAudioStreamingClient::LoopBody() ...@@ -107,7 +105,6 @@ bool CITANetAudioStreamingClient::LoopBody()
// Receive samples from net message and forward them to the stream ring buffer // Receive samples from net message and forward them to the stream ring buffer
m_pMessage->ReadSampleFrame( &m_sfReceivingBuffer ); m_pMessage->ReadSampleFrame( &m_sfReceivingBuffer );
//std::cout << "Receiving " << m_sfReceivingBuffer.GetLength() << " samples from streaming server" << std::endl;
if ( m_pStream->GetRingBufferFreeSamples( ) >= m_sfReceivingBuffer.GetLength( ) ) if ( m_pStream->GetRingBufferFreeSamples( ) >= m_sfReceivingBuffer.GetLength( ) )
m_pStream->Transmit( m_sfReceivingBuffer, m_sfReceivingBuffer.GetLength( ) ); m_pStream->Transmit( m_sfReceivingBuffer, m_sfReceivingBuffer.GetLength( ) );
//else //else
......
...@@ -144,26 +144,20 @@ bool CITANetAudioStreamingServer::LoopBody() ...@@ -144,26 +144,20 @@ bool CITANetAudioStreamingServer::LoopBody()
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_SEND_SAMPLES ); m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_SEND_SAMPLES );
m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer ); m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer );
m_pMessage->WriteAnswer(); m_pMessage->WriteAnswer();
//std::cout << "Transmitted " << m_pInputStream->GetBlocklength() << " samples, because there where " << iFreeSamples << " free samples on client side" << std::endl;
} }
else else
{ {
//std::cout << "Could not transmitt, because there where only " << iFreeSamples << " free samples on client side" << std::endl;
// Waiting for Trigger // Waiting for Trigger
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_WAITING_FOR_TRIGGER ); m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_WAITING_FOR_TRIGGER );
m_pMessage->WriteAnswer(); m_pMessage->WriteAnswer();
break; break;
} }
float fTimeOut = m_pInputStream->GetBlocklength() / m_pInputStream->GetSampleRate(); float fTimeOut = m_pInputStream->GetBlocklength() / m_pInputStream->GetSampleRate();
//VistaTimeUtils::Sleep( (int) ( 1 * 100 ) );
break; break;
} }
case CITANetAudioProtocol::NP_CLIENT_CLOSE: case CITANetAudioProtocol::NP_CLIENT_CLOSE:
{ {
m_pMessage->WriteAnswer();
m_pConnection = NULL; m_pConnection = NULL;
StopGently( true ); StopGently( true );
Stop(); Stop();
......
...@@ -45,7 +45,7 @@ int main( int , char** ) ...@@ -45,7 +45,7 @@ int main( int , char** )
cout << "Connected." << endl; cout << "Connected." << endl;
// Playback // Playback
float fSeconds = 10.0f; float fSeconds = 100.0f;
cout << "Playback started, waiting " << fSeconds << " seconds" << endl; cout << "Playback started, waiting " << fSeconds << " seconds" << endl;
ITAPA.Sleep( fSeconds ); // blocking ITAPA.Sleep( fSeconds ); // blocking
cout << "Done." << endl; cout << "Done." << endl;
......
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