Commit 11ebc640 authored by Jonas Stienen's avatar Jonas Stienen

Improving ITAsio streaming info and including panic watch for dropouts in...

Improving ITAsio streaming info and including panic watch for dropouts in audio output stream (triggers std::cout prints on occurance and a statistics print on ITAsioStop)
parent 516c72f7
......@@ -26,14 +26,16 @@ class ITAStreamInfo
{
public:
uint64_t nSamples; //!< Number of samples processed
double dTimecode; //!< Time code
double dStreamTimeCode; //!< Stream time code (starts with zero)
double dSysTimeCode; //!< System time stamp code (begings with current time stamp of system)
inline ITAStreamInfo()
: nSamples( 0 )
, dTimecode( 0 )
, dStreamTimeCode( 0.0f )
, dSysTimeCode( 0.0f )
{};
virtual ~ITAStreamInfo() {};
inline virtual ~ITAStreamInfo() {};
};
#endif // INCLUDE_WATCHER_ITA_STREAM_INFO
This diff is collapsed.
......@@ -6,6 +6,7 @@
#include <ITAException.h>
#include <ITAFunctors.h>
#include <ITANumericUtils.h>
#include <ITAClock.h>
#ifndef WIN32
#include <memory.h>
......@@ -98,7 +99,8 @@ void ITABufferDataSink::Transfer( unsigned int uiSamples )
m_uiWriteCursor += m;
m_siState.nSamples += m_pdsSource->GetBlocklength();
m_siState.dTimecode = ( double ) ( m_siState.nSamples ) / m_pdsSource->GetSampleRate();
m_siState.dStreamTimeCode = ( double ) ( m_siState.nSamples ) / m_pdsSource->GetSampleRate();
m_siState.dSysTimeCode = ITAClock::getDefaultClock()->getTime();
m_pdsSource->IncrementBlockPointer();
}
......
......@@ -8,6 +8,8 @@
#include <ITAStreamInfo.h>
#include <ITAAudiofileWriter.h>
#include <ITAException.h>
#include <ITAClock.h>
#include <cmath>
#include <string>
#include <vector>
......@@ -90,7 +92,8 @@ void WriteFromDatasourceToBuffer(ITADatasource* pSource,
n += uiBlocklength;
siState.nSamples += uiBlocklength;
siState.dTimecode = (double) (siState.nSamples) / dSamplerate;
siState.dStreamTimeCode = (double) (siState.nSamples) / dSamplerate;
siState.dSysTimeCode = ITAClock::getDefaultClock()->getTime();
if (bDisplayProgress)
{
......@@ -193,7 +196,8 @@ void WriteFromDatasourceToFile(ITADatasource* pSource,
pSource->IncrementBlockPointer();
siState.nSamples += uiBlocklength;
siState.dTimecode = (double) (siState.nSamples) / dSamplerate;
siState.dStreamTimeCode = (double) (siState.nSamples) / dSamplerate;
siState.dSysTimeCode = ITAClock::getDefaultClock()->getTime();
// Daten schreiben
writer->write((std::min)(uiBlocklength, (uiNumberOfSamples - n)), vpfData);
......
......@@ -4,13 +4,16 @@
#include <ITADataSource.h>
#include <ITAAudiofileWriter.h>
#include <ITANumericUtils.h>
#include <ITAClock.h>
ITAFileDatasink::ITAFileDatasink( std::string sFilename, ITADatasource* pdsSource, ITAQuantization eQuantization )
: m_pfSilence( NULL ) {
: m_pfSilence( NULL )
{
m_pdsSource = pdsSource;
m_pFileWriter = NULL;
if( pdsSource ) {
if( pdsSource )
{
m_vpfData.resize( pdsSource->GetNumberOfChannels() );
ITAAudiofileProperties props;
......@@ -24,19 +27,23 @@ ITAFileDatasink::ITAFileDatasink( std::string sFilename, ITADatasource* pdsSourc
}
}
ITAFileDatasink::~ITAFileDatasink() {
ITAFileDatasink::~ITAFileDatasink()
{
delete m_pFileWriter;
fm_free( m_pfSilence );
}
void ITAFileDatasink::Transfer( unsigned int uiSamples ) {
if( m_pdsSource ) {
void ITAFileDatasink::Transfer( unsigned int uiSamples )
{
if( m_pdsSource )
{
// Anzahl der zu transferrierenden Blcke bestimmen
unsigned int b = m_pdsSource->GetBlocklength();
unsigned int n = uprdivu( uiSamples, b );
for( unsigned int i = 0; i < n; i++ ) {
for( unsigned int j = 0; j < m_pdsSource->GetNumberOfChannels(); j++ ) {
for( unsigned int j = 0; j < m_pdsSource->GetNumberOfChannels(); j++ )
{
const float* pfSrc = m_pdsSource->GetBlockPointer( j, &m_siState );
if( pfSrc )
m_vpfData[ j ] = ( float* ) pfSrc;
......@@ -45,7 +52,8 @@ void ITAFileDatasink::Transfer( unsigned int uiSamples ) {
}
m_pdsSource->IncrementBlockPointer();
m_siState.nSamples += b;
m_siState.dTimecode = ( double ) ( m_siState.nSamples ) / m_pdsSource->GetSampleRate();
m_siState.dStreamTimeCode = ( double ) ( m_siState.nSamples ) / m_pdsSource->GetSampleRate();
m_siState.dSysTimeCode = ITAClock::getDefaultClock()->getTime();
m_pFileWriter->write( b, m_vpfData );
}
......
......@@ -207,7 +207,7 @@ const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const
}
if( uiChannel == 0 )
m_dLastStreamingTimeCode = pInfo->dTimecode;
m_dLastStreamingTimeCode = pInfo->dStreamTimeCode;
return m_sfOutputStreamBuffer[uiChannel].GetData();
......
......@@ -188,7 +188,8 @@ bool CITANetAudioStreamingServer::LoopBody()
{
ITAStreamInfo oStreamInfo;
oStreamInfo.nSamples = ( m_nStreamSampleCounts += m_iSendingBlockLength );
oStreamInfo.dTimecode = dNow - m_dStreamTimeStart;
oStreamInfo.dStreamTimeCode = dNow - m_dStreamTimeStart;
oStreamInfo.dSysTimeCode = dNow;
const float* pfData = m_pInputStream->GetBlockPointer( i, &oStreamInfo );
if( pfData != nullptr )
......
#include <ITAStreamPump.h>
#include <ITADataSource.h>
#include <ITAClock.h>
ITAStreamPump::ITAStreamPump(ITADatasource* pDatasource) : m_pDatasource(pDatasource), m_pTimer(NULL) {
m_pTimer = new ITATimer( (double) pDatasource->GetBlocklength() / pDatasource->GetSampleRate(), true);
m_pTimer->attach(this);
ITAStreamPump::ITAStreamPump( ITADatasource* pDatasource )
: m_pDatasource( pDatasource )
, m_pTimer( NULL )
{
m_pTimer = new ITATimer( ( double ) pDatasource->GetBlocklength() / pDatasource->GetSampleRate(), true );
m_pTimer->attach( this );
m_uiChannels = pDatasource->GetNumberOfChannels();
}
ITAStreamPump::~ITAStreamPump() {
ITAStreamPump::~ITAStreamPump()
{
delete m_pTimer;
}
}
void ITAStreamPump::StartStreaming() {
void ITAStreamPump::StartStreaming()
{
m_pTimer->start();
}
void ITAStreamPump::StopStreaming() {
void ITAStreamPump::StopStreaming()
{
m_pTimer->stop();
}
void ITAStreamPump::handleTimerEvent(const ITATimer& tSource) {
if (&tSource == m_pTimer) {
for (unsigned int i=0; i<m_uiChannels; i++) m_pDatasource->GetBlockPointer(i, &m_siState);
void ITAStreamPump::handleTimerEvent( const ITATimer& tSource )
{
if( &tSource == m_pTimer )
{
for( unsigned int i = 0; i < m_uiChannels; i++ ) m_pDatasource->GetBlockPointer( i, &m_siState );
m_pDatasource->IncrementBlockPointer();
m_siState.nSamples += m_pDatasource->GetBlocklength();
m_siState.dTimecode = (double) (m_siState.nSamples) / m_pDatasource->GetSampleRate();
}
m_siState.dStreamTimeCode = ( double ) ( m_siState.nSamples ) / m_pDatasource->GetSampleRate();
m_siState.dSysTimeCode = ITAClock::getDefaultClock()->getTime();
}
}
......@@ -14,17 +14,17 @@
using namespace std;
string g_sServerName = "137.226.61.85";
string g_sServerName = "137.226.61.200";
int g_iServerPort = 12480;
double g_dSampleRate = 44100.0;
int g_iBlockLength = 128;
int g_iChannels = 10;
int g_iTargetLatencySamples = 10 * g_iBlockLength; // 1.4512ms
int g_iChannels = 48;
int g_iTargetLatencySamples = 4 * g_iBlockLength; // 1.4512ms
int g_iRingBufferSize = 2 * g_iTargetLatencySamples;
int g_iSendingBlockLength = 8;
double g_dPlaybackDuration = 10 ; // seconds
const static string g_sAudioInterface = "ASIO MADIface USB";
//const static string g_sAudioInterface = "ASIO Hammerfall DSP";
//const static string g_sAudioInterface = "ASIO MADIface USB";
const static string g_sAudioInterface = "ASIO Hammerfall DSP";
//const static string g_sAudioInterface = "ASIO4ALL v2";
int main( int argc, char* argv[] )
......
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