Commit 1f77ee75 authored by Anne's avatar Anne

running, but with dropouts

parent 6d51e425
...@@ -40,15 +40,22 @@ bool CITANetAudioStream::GetIsConnected() const ...@@ -40,15 +40,22 @@ bool CITANetAudioStream::GetIsConnected() const
const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* ) const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* )
{ {
// @todo: is connected? // @todo: is connected?
int iCurrentWritePointer = m_iWriteCursor; m_sfOutputStreamBuffer[uiChannel].Zero();
if (iCurrentWritePointer > m_iReadCursor) { if (this->GetIsConnected())
m_sfOutputStreamBuffer[uiChannel].cyclic_write(&m_sfRingBuffer[uiChannel], {
m_sfOutputStreamBuffer.GetLength(), m_iReadCursor, iCurrentWritePointer);
} else { // todo restlichen kopieren und dann rein und raus faden
// diesen Block auf 0 setzen int iCurrentWritePointer = m_iWriteCursor;
m_sfOutputStreamBuffer[uiChannel].Zero(); if (iCurrentWritePointer > m_iReadCursor) {
m_sfRingBuffer[uiChannel].cyclic_read(m_sfOutputStreamBuffer[uiChannel].GetData(),
m_sfOutputStreamBuffer.GetLength(), m_iReadCursor);
}
else
{
// Hallo
int a = 0;
}
} }
return m_sfOutputStreamBuffer[ uiChannel ].GetData(); return m_sfOutputStreamBuffer[ uiChannel ].GetData();
} }
......
...@@ -99,9 +99,11 @@ bool CITANetAudioStreamingClient::LoopBody() ...@@ -99,9 +99,11 @@ bool CITANetAudioStreamingClient::LoopBody()
case CITANetAudioProtocol::NP_SERVER_SEND_SAMPLES: case CITANetAudioProtocol::NP_SERVER_SEND_SAMPLES:
// 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
//int iNumSamples = m_pMessage->ReadSampleFrame( &m_sfReceivingBuffer ); m_pMessage->ReadSampleFrame( &m_sfReceivingBuffer );
//if( m_pStream->GetRingbufferFreeSamples() >= iNumSamples ) if (m_pStream->GetRingbufferFreeSamples() >= m_sfReceivingBuffer.GetLength())
// m_pStream->Transmit( m_sfReceivingBuffer, iNumSamples ); m_pStream->Transmit(m_sfReceivingBuffer, m_sfReceivingBuffer.GetLength());
//else
// Fehler
break; break;
case CITANetAudioProtocol::NP_SERVER_GET_RINGBUFFER_FREE : case CITANetAudioProtocol::NP_SERVER_GET_RINGBUFFER_FREE :
......
...@@ -47,10 +47,15 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort ...@@ -47,10 +47,15 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters(); CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters();
bool bOK = false; bool bOK = false;
if( m_pInputStream->GetNumberOfChannels() == oClientParams.iChannels && if (m_pInputStream->GetNumberOfChannels() == oClientParams.iChannels &&
m_pInputStream->GetSampleRate() == oClientParams.dSampleRate && m_pInputStream->GetSampleRate() == oClientParams.dSampleRate &&
m_pInputStream->GetBlocklength() == oClientParams.iBlockSize ) m_pInputStream->GetBlocklength() == oClientParams.iBlockSize)
{
bOK = true; bOK = true;
std::cout << " Alle Daten Stimmen: \nAnzahl Channel: " << oClientParams.iChannels << std::endl;
std::cout << "SampleRate: " << oClientParams.dSampleRate << std::endl;
std::cout << "Blockgroesse: " << oClientParams.iBlockSize << std::endl;
}
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_OPEN ); m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_OPEN );
m_pMessage->WriteBool( bOK ); m_pMessage->WriteBool( bOK );
...@@ -117,13 +122,11 @@ bool CITANetAudioStreamingServer::LoopBody() ...@@ -117,13 +122,11 @@ bool CITANetAudioStreamingServer::LoopBody()
case CITANetAudioProtocol::NP_CLIENT_WAITING_FOR_SAMPLES: case CITANetAudioProtocol::NP_CLIENT_WAITING_FOR_SAMPLES:
{ {
int iFreeSamples = m_pMessage->ReadInt(); int iFreeSamples = m_pMessage->ReadInt();
// std::cout << "Freie Samples: " << iFreeSamples << std::endl;
// std::cout << "Laenge InputStram: " << m_pInputStream->GetBlocklength() << std::endl;
if( iFreeSamples >= m_pInputStream->GetBlocklength() ) if( iFreeSamples >= m_pInputStream->GetBlocklength() )
{ {
if (iFreeSamples < m_pInputStream->GetBlocklength()) { // Send Samples
// zurueckmelden 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;
...@@ -131,18 +134,21 @@ bool CITANetAudioStreamingServer::LoopBody() ...@@ -131,18 +134,21 @@ bool CITANetAudioStreamingServer::LoopBody()
m_sfTempTransmitBuffer[ i ].write( pfData, m_pInputStream->GetBlocklength() ); m_sfTempTransmitBuffer[ i ].write( pfData, m_pInputStream->GetBlocklength() );
} }
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 );
} }
else else
{ {
// Waiting for Trigger
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_WAITING_FOR_TRIGGER ); m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_WAITING_FOR_TRIGGER );
m_pMessage->WriteAnswer();
break;
} }
m_pMessage->WriteAnswer(); m_pMessage->WriteAnswer();
m_pInputStream->IncrementBlockPointer(); m_pInputStream->IncrementBlockPointer();
float fTimeOut = m_pInputStream->GetBlocklength() / m_pInputStream->GetSampleRate(); float fTimeOut = m_pInputStream->GetBlocklength() / m_pInputStream->GetSampleRate();
//VistaTimeUtils::Sleep( (int) ( fTimeOut * 1000 ) ); //VistaTimeUtils::Sleep( (int) ( 1 * 100 ) );
break; break;
} }
case CITANetAudioProtocol::NP_CLIENT_CLOSE: case CITANetAudioProtocol::NP_CLIENT_CLOSE:
......
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