More stuff for streaming

parent dd34eff7
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +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_SERVER_CLOSE = 200; static const int NP_SERVER_CLOSE = 200;
static const int NP_SERVER_OPEN = 201; static const int NP_SERVER_OPEN = 201;
......
...@@ -49,7 +49,8 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort ...@@ -49,7 +49,8 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
m_pMessage->WriteInt( 2 * 42 ); m_pMessage->WriteInt( 2 * 42 );
m_pMessage->WriteAnswer(); m_pMessage->WriteAnswer();
Run(); if( m_pInputStream )
Run();
return true; return true;
} }
...@@ -76,7 +77,14 @@ void CITANetAudioStreamingServer::Stop() ...@@ -76,7 +77,14 @@ void CITANetAudioStreamingServer::Stop()
void CITANetAudioStreamingServer::SetInputStream( ITADatasource* pInStream ) void CITANetAudioStreamingServer::SetInputStream( ITADatasource* pInStream )
{ {
if( VistaThreadLoop::IsRunning() )
ITA_EXCEPT1( MODAL_EXCEPTION, "Streaming loop already running, can not change input stream" );
m_pInputStream = pInStream; m_pInputStream = pInStream;
m_sfTempTransmitBuffer.init( m_pInputStream->GetNumberOfChannels(), m_pInputStream->GetBlocklength(), true );
if( m_pConnection )
Run();
} }
int CITANetAudioStreamingServer::GetNetStreamBlocklength() const int CITANetAudioStreamingServer::GetNetStreamBlocklength() const
...@@ -96,6 +104,28 @@ void CITANetAudioStreamingServer::SetAutomaticUpdateRate() ...@@ -96,6 +104,28 @@ void CITANetAudioStreamingServer::SetAutomaticUpdateRate()
bool CITANetAudioStreamingServer::LoopBody() bool CITANetAudioStreamingServer::LoopBody()
{ {
m_pMessage->ResetMessage();
m_pMessage->SetConnection( m_pConnection );
m_pMessage->ReadMessage(); // blocking
switch( m_pMessage->GetMessageType() )
{
case CITANetAudioProtocol::NP_CLIENT_WAITING_FOR_SAMPLES:
if( m_pInputStream )
{
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->WriteAnswer();
break;
}
return true; return true;
} }
......
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