Commit 1f77ee75 authored by Anne's avatar Anne

running, but with dropouts

parent 6d51e425
......@@ -40,15 +40,22 @@ bool CITANetAudioStream::GetIsConnected() const
const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* )
{
// @todo: is connected?
int iCurrentWritePointer = m_iWriteCursor;
if (iCurrentWritePointer > m_iReadCursor) {
m_sfOutputStreamBuffer[uiChannel].cyclic_write(&m_sfRingBuffer[uiChannel],
m_sfOutputStreamBuffer.GetLength(), m_iReadCursor, iCurrentWritePointer);
} else {
// diesen Block auf 0 setzen
m_sfOutputStreamBuffer[uiChannel].Zero();
m_sfOutputStreamBuffer[uiChannel].Zero();
if (this->GetIsConnected())
{
// todo restlichen kopieren und dann rein und raus faden
int iCurrentWritePointer = m_iWriteCursor;
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();
}
......
......@@ -99,9 +99,11 @@ bool CITANetAudioStreamingClient::LoopBody()
case CITANetAudioProtocol::NP_SERVER_SEND_SAMPLES:
// Receive samples from net message and forward them to the stream ring buffer
//int iNumSamples = m_pMessage->ReadSampleFrame( &m_sfReceivingBuffer );
//if( m_pStream->GetRingbufferFreeSamples() >= iNumSamples )
// m_pStream->Transmit( m_sfReceivingBuffer, iNumSamples );
m_pMessage->ReadSampleFrame( &m_sfReceivingBuffer );
if (m_pStream->GetRingbufferFreeSamples() >= m_sfReceivingBuffer.GetLength())
m_pStream->Transmit(m_sfReceivingBuffer, m_sfReceivingBuffer.GetLength());
//else
// Fehler
break;
case CITANetAudioProtocol::NP_SERVER_GET_RINGBUFFER_FREE :
......
......@@ -47,10 +47,15 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
CITANetAudioProtocol::StreamingParameters oClientParams = m_pMessage->ReadStreamingParameters();
bool bOK = false;
if( m_pInputStream->GetNumberOfChannels() == oClientParams.iChannels &&
if (m_pInputStream->GetNumberOfChannels() == oClientParams.iChannels &&
m_pInputStream->GetSampleRate() == oClientParams.dSampleRate &&
m_pInputStream->GetBlocklength() == oClientParams.iBlockSize )
m_pInputStream->GetBlocklength() == oClientParams.iBlockSize)
{
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->WriteBool( bOK );
......@@ -117,13 +122,11 @@ bool CITANetAudioStreamingServer::LoopBody()
case CITANetAudioProtocol::NP_CLIENT_WAITING_FOR_SAMPLES:
{
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()) {
// zurueckmelden und warten auf exeption
break;
}
// Send Samples
for( int i = 0; i < m_pInputStream->GetNumberOfChannels(); i++ )
{
ITAStreamInfo oStreamInfo;
......@@ -131,18 +134,21 @@ bool CITANetAudioStreamingServer::LoopBody()
m_sfTempTransmitBuffer[ i ].write( pfData, m_pInputStream->GetBlocklength() );
}
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_SEND_SAMPLES );
//m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer );
m_pMessage->WriteSampleFrame( &m_sfTempTransmitBuffer );
}
else
{
// Waiting for Trigger
m_pMessage->SetAnswerType( CITANetAudioProtocol::NP_SERVER_WAITING_FOR_TRIGGER );
m_pMessage->WriteAnswer();
break;
}
m_pMessage->WriteAnswer();
m_pInputStream->IncrementBlockPointer();
float fTimeOut = m_pInputStream->GetBlocklength() / m_pInputStream->GetSampleRate();
//VistaTimeUtils::Sleep( (int) ( fTimeOut * 1000 ) );
//VistaTimeUtils::Sleep( (int) ( 1 * 100 ) );
break;
}
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