Commit 671c79a6 authored by Anne's avatar Anne

bugfix

parent bc14bb8e
......@@ -27,7 +27,7 @@ CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwap
void CITANetAudioMessage::ResetMessage()
{
if( m_oIncoming.GetTailSize() > 0 )
vstr::err() << "CITANetAudioMessage::ResetMessage() called before message was fully processed!" << std::endl;
//vstr::err() << "CITANetAudioMessage::ResetMessage() called before message was fully processed!" << std::endl;
// wait till sending is complete -> this prevents us
// from deleting the buffer while it is still being read
......@@ -46,7 +46,7 @@ void CITANetAudioMessage::ResetMessage()
m_nMessageType = CITANetAudioProtocol::NP_INVALID;
m_pConnection = NULL;
//m_pConnection = NULL;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [Preparing] (id=" << std::setw( 4 ) << m_nMessageId << ")" << std::endl;
......@@ -121,11 +121,12 @@ bool CITANetAudioMessage::ReadMessage()
double dTimeAfter = ITAClock::getDefaultClock( )->getTime( );
double DTimeDiff = dTimeAfter - dTimeBefore;
// TODO Timer entfernen
if ( nIncomingBytes < 4 )
if ( nIncomingBytes == -1)
{
m_nMessageType = CITANetAudioProtocol::NP_NO_MESSAGE;
return false;
}
nIncomingBytes = m_pConnection->WaitForIncomingData( 0 );
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Reading ] " << nIncomingBytes << " bytes incoming" << std::endl;
#endif
......@@ -144,10 +145,14 @@ bool CITANetAudioMessage::ReadMessage()
// Receive all incoming data (potentially splitted)
int iBytesReceivedTotal = 0;
while( nMessagePayloadSize != iBytesReceivedTotal )
while( nMessagePayloadSize > iBytesReceivedTotal )
{
int iIncommingBytes = m_pConnection->WaitForIncomingData( 0 );
int iBytesReceived = m_pConnection->Receive( &m_vecIncomingBuffer[ iBytesReceivedTotal ], iIncommingBytes );
int iBytesReceived;
if ( nMessagePayloadSize < iIncommingBytes )
iBytesReceived = m_pConnection->Receive( &m_vecIncomingBuffer[ iBytesReceivedTotal ], nMessagePayloadSize - iBytesReceivedTotal );
else
iBytesReceived = m_pConnection->Receive( &m_vecIncomingBuffer[ iBytesReceivedTotal ], iIncommingBytes );
iBytesReceivedTotal += iBytesReceived;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ CITANetAudioMessage ] " << std::setw( 3 ) << std::floor( iBytesReceivedTotal / float( nMessagePayloadSize ) * 100.0f ) << "% transmitted" << std::endl;
......
......@@ -236,14 +236,16 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
if( !GetIsConnected() )
{
m_sfOutputStreamBuffer[ uiChannel ].Zero( );
m_iStreamingStatus = STOPPED;
if (uiChannel == 0 )
m_iStreamingStatus = STOPPED;
}
else
{
if( GetIsRingBufferEmpty() )
{
m_sfOutputStreamBuffer[ uiChannel ].Zero();
m_iStreamingStatus = BUFFER_UNDERRUN;
if (uiChannel == 0 )
m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
......@@ -254,7 +256,8 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
{
// @todo: fade out
m_sfRingBuffer[ uiChannel ].Zero();
m_iStreamingStatus = BUFFER_UNDERRUN;
if (uiChannel == 0 )
m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
......@@ -263,7 +266,8 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
{
// Normal behaviour (if everything is OK with ring buffer status)
m_sfRingBuffer[ uiChannel ].cyclic_read( m_sfOutputStreamBuffer[ uiChannel ].GetData(), GetBlocklength(), m_iReadCursor );
m_iStreamingStatus = STREAMING;
if ( uiChannel == 0 )
m_iStreamingStatus = STREAMING;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ Stream ] Streaming" << std::endl;
#endif
......@@ -274,6 +278,7 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
if( uiChannel == 0 )
m_dLastStreamingTimeCode = pInfo->dTimecode;
return m_sfOutputStreamBuffer[uiChannel].GetData();
}
......@@ -283,26 +288,26 @@ void CITANetAudioStream::IncrementBlockPointer()
int iSavedSample = GetRingBufferSize( ) - GetRingBufferFreeSamples( );
if ( !GetIsConnected( ) )
{
m_iStreamingStatus = STOPPED;
//m_iStreamingStatus = STOPPED;
} else if ( iSavedSample >= int( GetBlocklength( ) ) )
{
//es wurden Samples abgespielt
m_iReadCursor = ( m_iReadCursor + m_sfOutputStreamBuffer.GetLength() ) % m_sfRingBuffer.GetLength();
m_iStreamingStatus = STREAMING;
//m_iStreamingStatus = STREAMING;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Streaming" << std::endl;
#endif
}
else if ( GetIsRingBufferEmpty( ) )
{
m_iStreamingStatus = BUFFER_UNDERRUN;
//m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
}
else
{
m_iStreamingStatus = BUFFER_UNDERRUN;
//m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
......@@ -310,7 +315,7 @@ void CITANetAudioStream::IncrementBlockPointer()
}
m_bRingBufferFull = false;
ITAStreamLog oLog;
ITAStreamLog oLog;
oLog.iStreamingStatus = m_iStreamingStatus;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime();
oLog.dStreamingTimeCode = m_dLastStreamingTimeCode;
......
......@@ -72,9 +72,9 @@ bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort
bool CITANetAudioStreamingServer::LoopBody( )
{
//m_pMessage->SetConnection( m_pConnection );
m_pMessage->ResetMessage( );
m_pMessage->SetConnection( m_pConnection );
m_pMessage->ReadMessage( );
if ( m_pMessage->ReadMessage( ) )
{
......
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