Commit 8e67fa3f authored by Anne's avatar Anne
Browse files

plot buffer Underruns + set streamining status

parent 0902aa00
......@@ -188,6 +188,7 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
if( !GetIsConnected() )
{
m_sfOutputStreamBuffer[ uiChannel ].Zero( );
m_iStreamingStatus = STOPPED;
}
else
{
......@@ -232,8 +233,10 @@ void CITANetAudioStream::IncrementBlockPointer()
{
// Increment read cursor by one audio block and wrap around if exceeding ring buffer
int iSavedSample = GetRingBufferSize( ) - GetRingBufferFreeSamples( );
if ( iSavedSample >= int( GetBlocklength( ) ) )
if ( !GetIsConnected( ) )
{
m_iStreamingStatus = STOPPED;
} else if ( iSavedSample >= int( GetBlocklength( ) ) )
{
//es wurden Samples abgespielt
m_iReadCursor = ( m_iReadCursor + m_sfOutputStreamBuffer.GetLength() ) % m_sfRingBuffer.GetLength();
......@@ -251,9 +254,9 @@ void CITANetAudioStream::IncrementBlockPointer()
}
else
{
m_iStreamingStatus = BUFFER_OVERRUN;
m_iStreamingStatus = BUFFER_UNDERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
//vstr::out() << "[ Stream ] Buffer overrun" << std::endl;
//vstr::out() << "[ Stream ] Buffer underrun" << std::endl;
#endif
m_iReadCursor = m_iWriteCursor;
}
......@@ -283,6 +286,7 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
if ( ( m_iWriteCursor == m_iReadCursor ) && m_bRingBufferFull )
{
// BufferFull
m_iStreamingStatus = BUFFER_OVERRUN;
oLog.iBufferStatus = 1;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ NetAudio ] Buffer overrun" << std::endl;
......@@ -293,6 +297,7 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
// @todo: only partly write
//std::cerr << "BUFFER_OVERRUN! Would partly write samples because ring buffer will be full then." << std::endl;
m_iStreamingStatus = BUFFER_OVERRUN;
m_iWriteCursor = m_iReadCursor;
oLog.iBufferStatus = 2;
}
......@@ -302,6 +307,7 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
m_sfRingBuffer.cyclic_write( sfNewSamples, iNumSamples, 0, iCurrentWriteCursor );
m_bRingBufferFull = false;
oLog.iBufferStatus = 1;
m_iStreamingStatus = STREAMING;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ NetAudio ] Buffer write" << std::endl;
#endif
......@@ -312,12 +318,14 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
{
m_bRingBufferFull = true;
oLog.iBufferStatus = 1;
m_iStreamingStatus = BUFFER_OVERRUN;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "[ NetAudio ] Buffer overrun" << std::endl;
#endif
}
}
oLog.iBufferStatus = m_iStreamingStatus;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock( )->getTime( );
oLog.uiBlockId = ++iAudioStreamingBlockID;
oLog.iFreeSamples = GetRingBufferFreeSamples( );
......
......@@ -5,34 +5,32 @@ NetAudioLogNet = readtable( 'NetAudioLogNet.txt' );
NetAudioLogStream = readtable( 'NetAudioLogStream.txt' );
NetAudioLogClient = readtable( 'NetAudioLogClient.txt' );
%% Plot Freie Smaples und Bufferstutus
minTime = min(NetAudioLogStream.WorldTimeStamp(1),NetAudioLogNet.WorldTimeStamp(1));
TimeNet = NetAudioLogNet.WorldTimeStamp - minTime;
TimeStream = NetAudioLogStream.WorldTimeStamp - minTime;
BlockLenght = NetAudioLogNet.NumSamplesTransmitted(1);
TimeState = [TimeStream NetAudioLogStream.StreamingStatus];
TimeUnderrun = TimeState(find(TimeState(:,2)==3), 1);
TimeOverrun = TimeState(find(TimeState(:,2)==4), 1);
TimeStream = TimeState(find(TimeState(:,2)==2), 1);
%% Plot Freie Smaples und Bufferstutus
Data = [NetAudioLogNet.WorldTimeStamp NetAudioLogNet.FreeSamples; NetAudioLogStream.WorldTimeStamp NetAudioLogStream.FreeSamples];
Data = sortrows(Data,1 );
Data(:,1) = Data(:,1) - minTime();
Data(:,2) = (Data(:,2)) / BlockLenght;
medianBlock = (max(Data(:,2)) - min(Data(:,2))) / 2;
subplot(2,2,1:2)
plot(Data(:,1), Data(:,2))
plot( Data(:,1), Data(:,2) )
hold on
plot( TimeUnderrun, zeros(size(TimeUnderrun)) + max(Data(:,2)),'r*')
plot( TimeOverrun, zeros(size(TimeOverrun)) + min(Data(:,2)),'r+')
title('Freie Blcke im Ring Buffer')
xlabel('Zeit in s')
ylabel('Anzahl der Blcke')
%% Plot Streaming Status
subplot(2,2,1:2)
plot( TimeNet, NetAudioLogNet.Bufferstatus )
plot( TimeStream, NetAudioLogStream.StreamingStatus )
ylim([1.9 3.1])
title('Streaming Status')
xlabel('Zeit in ms')
ylabel('Status')
%% Plot Latenz
subplot(2,2,3:4)
DiffTime = diff(NetAudioLogClient.WorldTimeStamp * 1000);
median = mean(DiffTime(:,1));
medianVec = zeros(size(DiffTime(:,1)));
......@@ -46,13 +44,17 @@ medianRunningVec = zeros(size(LatenzRunnning(:,1)));
medianRunningVec = medianRunningVec + medianRunning;
sollLatenz = (BlockLenght / 44100) * 1000;
sollLatenzVec = zeros(size(LatenzRunnning(:,1)));
sollLatenzVec = sollLatenzVec + sollLatenz;
sollLatenzVec = sollLatenzVec + sollLatenz
subplot(2,2,3:4)
plot( LatenzRunnning(:,1), LatenzRunnning(:,2))
hold on
plot( LatenzRunnning(:,1), medianRunningVec, 'r')
plot( LatenzRunnning(:,1), sollLatenzVec, 'g')
plot( TimeUnderrun, zeros(size(TimeUnderrun)) + sollLatenz,'r*')
plot( TimeOverrun, zeros(size(TimeOverrun)) + medianRunning,'r*')
title('Latenz pro Block')
legend('Latenz', 'Durchschnittliche Latenz', 'SollLatenz')
legend('Latenz', 'Durchschnittliche Latenz', 'SollLatenz', 'Underruns', 'Overruns')
xlabel('Zeit in ms')
ylabel('Latenz in ms')
legend('show')
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