Commit f841f8d3 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Merge branch 'ba_2016_heimes' of https://git.rwth-aachen.de/ita/ITADataSources into ba_2016_heimes

parents 82be59b0 bc6f5812
......@@ -36,6 +36,7 @@
#include <vector>
class VistaConnectionIP;
class ITABufferedDataLoggerImplProtocol;
//! Network audio messages
/**
......@@ -94,6 +95,9 @@ public:
int ReadRingBufferFree();
void ReadSampleFrame(ITASampleFrame* pSampleFrame);
void SetMessageLoggerBaseName( const std::string& );
std::string GetMessageLoggerBaseName() const;
private:
int m_nMessageType;
int m_nMessageId;
......@@ -105,8 +109,8 @@ private:
VistaConnectionIP* m_pConnection;
//DEBUG
int i;
ITABufferedDataLoggerImplProtocol* m_pMessageLogger;
std::string m_sMessageLoggerBaseName;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_MESSAGE
......@@ -47,6 +47,7 @@ class CITANetAudioStream;
class ITA_DATA_SOURCES_API CITANetAudioProtocol
{
public:
static const int NP_CLIENT_IDLE = 0;
static const int NP_CLIENT_OPEN = 100;
static const int NP_CLIENT_CLOSE = 101;
static const int NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES = 111;
......@@ -65,7 +66,6 @@ public:
double dSampleRate;
int iBlockSize;
int iRingBufferSize;
int iTargetSampleLatency;
inline StreamingParameters()
{
......@@ -73,7 +73,6 @@ public:
dSampleRate = 0.0f;
iBlockSize = 0;
iRingBufferSize = 0;
iTargetSampleLatency = 0;
};
inline bool operator==( const StreamingParameters& rhs )
......@@ -81,8 +80,7 @@ public:
if ( ( iChannels == rhs.iChannels )
&& ( dSampleRate == rhs.dSampleRate )
&& (iBlockSize == rhs.iBlockSize)
&& (iRingBufferSize == rhs.iRingBufferSize)
&& (iTargetSampleLatency == rhs.iTargetSampleLatency))
&& (iRingBufferSize == rhs.iRingBufferSize))
return true;
else
return false;
......
......@@ -87,17 +87,6 @@ public:
*/
bool GetIsConnected() const;
//! Set allowed latency (s)
/**
* Sets the latency that will be used for reading and writing from ring buffer.
* New samples will be requested and send if the latency / ring buffer samples
* is lower than the target latency.
*/
void SetAllowedLatencySeconds( float fLatencySeconds );
void SetAllowedLatencySamples( int iLatencySamples );
float GetAllowedLatencySeconds() const;
int GetAllowedLatencySamples() const;
//! Sets the minimal latency possible
/**
* Real-time network audio is considered to process at lowest latency possible.
......@@ -113,17 +102,11 @@ public:
int GetMinimumLatencySamples() const;
int GetMaximumLatencySamples() const;
//! Sets the latency for real-time processing
/**
* Real-time network audio is considered to process at lowest latency possible.
* However, this implementation requires at least one block. Hence latency is
* depending on sampling rate and block length. This method basically
* sets the minimum allowed latency to this value.
*
* @sa GetMinimumLatencySeconds()
* @sa SetAllowedLatencySeconds()
*/
void SetLatencyForRealtime();
//! Returns the NetAudio streaming logger base name
std::string GetNetAudioStreamLoggerBaseName() const;
//! Sets the NetAudio streaming logger base name
void SetNetAudioStreamingLoggerBaseName( const std::string& sBaseName );
//! Returns (static) size of ring buffer
/**
......@@ -169,6 +152,7 @@ public:
*/
void IncrementBlockPointer();
protected:
//! This method is called by the networkg client and pushes samples into the ring buffer
/**
......@@ -206,14 +190,14 @@ private:
int m_iWriteCursor; //!< Cursor where samples will be fed into ring buffer from net audio producer (always ahead)
bool m_bRingBufferFull; //!< Indicator if ring buffer is full (and read cursor equals write cursor)
ITASampleFrame m_sfRingBuffer; //!< Ring buffer
int m_iTargetSampleLatencyServer; //!< Maximum allowed samples / target sample latency
int m_iStreamingStatus; //!< Current streaming status
double m_dLastStreamingTimeCode;
ITABufferedDataLoggerImplAudio* m_pAudioLogger; //!< Logging for the audio stream
ITABufferedDataLoggerImplStream* m_pStreamLogger; //!< Logging for the audio stream
ITABufferedDataLoggerImplNet* m_pNetLogger; //!< Logging for the network stream
ITABufferedDataLoggerImplStream* m_pAudioStreamLogger; //!< Logging for the audio stream
ITABufferedDataLoggerImplNet* m_pNetworkStreamLogger; //!< Logging for the network stream
std::string m_sNetAudioStreamLoggerBaseName;
int iAudioStreamingBlockID; //!< Audio streaming block id
int iNetStreamingBlockID; //!< Network streaming block id
......
......@@ -25,6 +25,7 @@
#include <ITASampleFrame.h>
#include <ITAStreamProbe.h>
#include <ITAStopWatch.h>
#include <VistaInterProcComm/Concurrency/VistaThreadEvent.h>
#include <VistaInterProcComm/Concurrency/VistaThreadLoop.h>
......@@ -59,6 +60,9 @@ public:
bool LoopBody();
std::string GetClientLoggerBaseName() const;
void SetClientLoggerBaseName( const std::string& );
protected:
void TriggerBlockIncrement();
......@@ -69,17 +73,22 @@ private:
CITANetAudioProtocol* m_pProtocol;
CITANetAudioMessage* m_pMessage;
VistaConnectionIP* m_pConnection;
//VistaThreadEvent m_oBlockIncrementEvent;
ITASampleFrame m_sfReceivingBuffer; //!< Buffer incoming data
CITANetAudioProtocol::StreamingParameters m_oParams;
bool m_bStopIndicated;
bool m_bStopped;
int iStreamingBlockId;
int m_iStreamingBlockId;
double m_dServerClockSyncRequestTimeInterval;
double m_dServerClockSyncLastSyncTime;
ITABufferedDataLoggerImplClient* m_pClientLogger;
std::string m_sClientLoggerBaseName;
ITAStopWatch m_swTryReadStats;
friend class CITANetAudioStream;
};
......
......@@ -63,21 +63,30 @@ public:
CITANetAudioStreamingServer();
~CITANetAudioStreamingServer();
bool Start( const std::string& sAddress, int iPort );
//! Start to listen on a socket (blocking)
bool Start( const std::string& sAddress, const int iPort, const double dTimeIntervalCientSendStatus );
bool IsClientConnected() const;
std::string GetNetworkAddress() const;
int GetNetworkPort() const;
bool LoopBody();
void Stop();
void SetInputStream( ITADatasource* pInStream );
int GetNetStreamBlocklength() const;
int GetNetStreamNumberOfChannels() const;
double GetNetStreamSampleRate() const;
void SetAutomaticUpdateRate();
void SetTargetLatencySamples( const int iTargetLatency );
int GetTargetLatencySamples() const;
void SetServerLogBaseName( const std::string& sBaseName );
std::string GetServerLogBaseName() const;
bool LoopBody();
protected:
ITADatasource* GetInputStream() const;
......@@ -92,9 +101,11 @@ private:
int iServerBlockId;
ITABufferedDataLoggerImplServer* m_pServerLogger;
std::string m_sServerLogBaseName;
int m_iUpdateStrategy;
int m_iClientRingBufferFreeSamples;
int m_iTargetLatencySamples;
int m_iMaxSendBlocks;
double m_dLastTimeStamp;
......
......@@ -220,7 +220,7 @@ private:
ITADatasource* pDatasource; //!< Datasource assigned to the input
std::vector< const float* > vpfInputData; //!< Pointers to the next stream blocks
inline InputDesc( const int iChannels, const int iBlockLength )
inline InputDesc( const int iChannels, const int )
: vpfInputData( iChannels, nullptr )
, iChannels( iChannels )
, fCurrentGain( 1.0f )
......
......@@ -23,6 +23,7 @@ bool CITANetAudioClient::Connect( const std::string& sAddress, int iPort )
// Attempt to connect and check parameters
m_pConnection = new VistaConnectionIP( VistaConnectionIP::CT_TCP, sAddress, iPort );
if( !GetIsConnected() )
{
delete m_pConnection;
......@@ -46,5 +47,8 @@ void CITANetAudioClient::Disconnect()
bool CITANetAudioClient::GetIsConnected() const
{
return ( m_pConnection != NULL ) ? true : false;
if( m_pConnection )
return m_pConnection->GetIsOpen();
else
return false;
}
This diff is collapsed.
......@@ -16,39 +16,9 @@
#include <cmath>
#include <iostream>
//! Audio streaming log item
struct ITAAudioLog : public ITALogDataBase
{
inline static std::ostream& outputDesc( std::ostream& os )
{
os << "\t" << "Channel";
os << "\t" << "Samplerate";
os << "\t" << "BufferSize";
os << "\t" << "RingBufferSize";
os << "\t" << "TargetSampleLatency";
os << std::endl;
return os;
};
inline std::ostream& outputData( std::ostream& os ) const
{
os << "\t" << iChannel;
os << "\t" << dSampleRate;
os << "\t" << iBufferSize;
os << "\t" << iRingBufferSize;
os << "\t" << iTargetSampleLatency;
os << std::endl;
return os;
};
int iChannel;
double dSampleRate;
int iBufferSize;
int iRingBufferSize;
int iTargetSampleLatency;
};
//! Audio streaming log item
struct ITAStreamLog : public ITALogDataBase
//! Audio streaming log item
struct ITAAudioStreamLog : public ITALogDataBase
{
inline static std::ostream& outputDesc( std::ostream& os )
{
......@@ -81,7 +51,7 @@ struct ITAStreamLog : public ITALogDataBase
};
//! Network streaming log item
struct ITANetLog : public ITALogDataBase
struct ITANetworkStreamLog : public ITALogDataBase
{
inline static std::ostream& outputDesc( std::ostream& os )
{
......@@ -112,9 +82,8 @@ struct ITANetLog : public ITALogDataBase
int iNumSamplesTransmitted;
};
class ITABufferedDataLoggerImplAudio : public ITABufferedDataLogger < ITAAudioLog > {};
class ITABufferedDataLoggerImplStream : public ITABufferedDataLogger < ITAStreamLog > {};
class ITABufferedDataLoggerImplNet : public ITABufferedDataLogger < ITANetLog > {};
class ITABufferedDataLoggerImplStream : public ITABufferedDataLogger < ITAAudioStreamLog > {};
class ITABufferedDataLoggerImplNet : public ITABufferedDataLogger < ITANetworkStreamLog > {};
CITANetAudioStream::CITANetAudioStream(int iChannels, double dSamplingRate, int iBufferSize, int iTargetSampleLatencyServer)
......@@ -124,7 +93,6 @@ CITANetAudioStream::CITANetAudioStream(int iChannels, double dSamplingRate, int
, m_bRingBufferFull( false )
, m_iStreamingStatus( INVALID )
, m_dLastStreamingTimeCode( 0.0f )
, m_iTargetSampleLatencyServer( iTargetSampleLatencyServer )
{
m_bRingBufferFull = false;
if (iBufferSize > iTargetSampleLatencyServer)
......@@ -137,33 +105,19 @@ CITANetAudioStream::CITANetAudioStream(int iChannels, double dSamplingRate, int
m_iStreamingStatus = STOPPED;
// Logging
std::string paras = std::string("_BS") + std::to_string(iBufferSize) + std::string("_Ch") + std::to_string(iChannels) + std::string("_tl") + std::to_string(iTargetSampleLatencyServer) + std::string(".txt");
m_pAudioLogger = new ITABufferedDataLoggerImplAudio( );
m_pAudioLogger->setOutputFile(std::string("NetAudioLogBaseData") + paras);
m_pStreamLogger = new ITABufferedDataLoggerImplStream();
m_pStreamLogger->setOutputFile(std::string("NetAudioLogStream") + paras);
m_pAudioStreamLogger = new ITABufferedDataLoggerImplStream();
iAudioStreamingBlockID = 0;
m_pNetLogger = new ITABufferedDataLoggerImplNet();
m_pNetLogger->setOutputFile(std::string("NetAudioLogNet") + paras);
m_pNetworkStreamLogger = new ITABufferedDataLoggerImplNet();
iNetStreamingBlockID = 0;
// Logging Base Data
ITAAudioLog oLog;
oLog.iChannel = GetNumberOfChannels();
oLog.dSampleRate = m_dSampleRate;
oLog.iBufferSize = GetBlocklength();
oLog.iRingBufferSize = GetRingBufferSize();
oLog.iTargetSampleLatency = m_iTargetSampleLatencyServer;
m_pAudioLogger->log( oLog );
SetNetAudioStreamingLoggerBaseName( "ITANetAudioStream" );
}
CITANetAudioStream::~CITANetAudioStream()
{
delete m_pNetLogger;
delete m_pStreamLogger;
delete m_pAudioLogger;
delete m_pAudioStreamLogger;
delete m_pNetworkStreamLogger;
delete m_pNetAudioStreamingClient;
}
......@@ -182,11 +136,6 @@ bool CITANetAudioStream::GetIsConnected() const
return m_pNetAudioStreamingClient->GetIsConnected();
}
void CITANetAudioStream::SetAllowedLatencySeconds( float fLatencySeconds )
{
SetAllowedLatencySamples( (int) std::floor( GetSampleRate() * fLatencySeconds ) );
}
float CITANetAudioStream::GetMaximumLatencySeconds() const
{
return float( GetMaximumLatencySamples() / GetSampleRate() );
......@@ -197,27 +146,6 @@ float CITANetAudioStream::GetMinimumLatencySeconds() const
return float( GetMinimumLatencySamples() / GetSampleRate() );
}
void CITANetAudioStream::SetAllowedLatencySamples( int iLatencySamples )
{
if( iLatencySamples < GetMinimumLatencySamples() )
ITA_EXCEPT1( INVALID_PARAMETER, "Can not set latency lower than the minimum possible" );
if( iLatencySamples > GetMaximumLatencySamples() )
ITA_EXCEPT1( INVALID_PARAMETER, "Can not set latency greater than the maximum possible" );
m_iTargetSampleLatencyServer = iLatencySamples;
}
float CITANetAudioStream::GetAllowedLatencySeconds() const
{
return float(m_iTargetSampleLatencyServer / GetSampleRate());
}
int CITANetAudioStream::GetAllowedLatencySamples() const
{
return m_iTargetSampleLatencyServer;
}
int CITANetAudioStream::GetMinimumLatencySamples() const
{
// At least one block
......@@ -229,11 +157,6 @@ int CITANetAudioStream::GetMaximumLatencySamples() const
return GetRingBufferSize();
}
void CITANetAudioStream::SetLatencyForRealtime()
{
SetAllowedLatencySamples( GetMinimumLatencySamples() );
}
const float* CITANetAudioStream::GetBlockPointer( unsigned int uiChannel, const ITAStreamInfo* pInfo )
{
if( !GetIsConnected() )
......@@ -318,13 +241,13 @@ void CITANetAudioStream::IncrementBlockPointer()
}
m_bRingBufferFull = false;
ITAStreamLog oLog;
ITAAudioStreamLog oLog;
oLog.iStreamingStatus = m_iStreamingStatus;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime();
oLog.dStreamingTimeCode = m_dLastStreamingTimeCode;
oLog.uiBlockId = ++iAudioStreamingBlockID;
oLog.iFreeSamples = GetRingBufferFreeSamples( );
m_pStreamLogger->log( oLog );
m_pAudioStreamLogger->log( oLog );
//m_pNetAudioStreamingClient->TriggerBlockIncrement();
}
......@@ -335,7 +258,7 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
int iCurrentReadCursor = m_iReadCursor;
int iCurrentWriteCursor = m_iWriteCursor;
ITANetLog oLog;
ITANetworkStreamLog oLog;
if( iCurrentWriteCursor < iCurrentReadCursor )
iCurrentWriteCursor += GetRingBufferSize(); // Unwrap, because write cursor always ahead
......@@ -380,7 +303,7 @@ int CITANetAudioStream::Transmit( const ITASampleFrame& sfNewSamples, int iNumSa
oLog.uiBlockId = ++iAudioStreamingBlockID;
oLog.iFreeSamples = GetRingBufferFreeSamples( );
oLog.iNumSamplesTransmitted = iNumSamples;
m_pNetLogger->log( oLog );
m_pNetworkStreamLogger->log( oLog );
return GetRingBufferFreeSamples();
}
......@@ -400,6 +323,18 @@ int CITANetAudioStream::GetRingBufferFreeSamples() const
return iFreeSamples;
}
std::string CITANetAudioStream::GetNetAudioStreamLoggerBaseName() const
{
return m_sNetAudioStreamLoggerBaseName;
}
void CITANetAudioStream::SetNetAudioStreamingLoggerBaseName( const std::string& sBaseName )
{
m_sNetAudioStreamLoggerBaseName = sBaseName;
m_pAudioStreamLogger->setOutputFile( GetNetAudioStreamLoggerBaseName() + "_AudioStream" );
m_pNetworkStreamLogger->setOutputFile( GetNetAudioStreamLoggerBaseName() + "_NetworkStream" );
}
int CITANetAudioStream::GetRingBufferSize() const
{
return m_sfRingBuffer.GetLength();
......
......@@ -51,21 +51,22 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
, m_pConnection( NULL )
, m_bStopIndicated( false )
, m_bStopped( false )
, m_iStreamingBlockId( 0 )
, m_dServerClockSyncRequestTimeInterval( 0.1f )
, m_dServerClockSyncLastSyncTime( 0.0f )
{
m_pClient = new CITANetAudioClient();
m_oParams.iChannels = pParent->GetNumberOfChannels();
m_oParams.dSampleRate = pParent->GetSampleRate( );
m_oParams.dSampleRate = pParent->GetSampleRate();
m_oParams.iBlockSize = pParent->GetBlocklength();
m_oParams.iRingBufferSize = pParent->GetRingBufferSize();
m_oParams.iTargetSampleLatency = pParent->GetAllowedLatencySamples();
m_sfReceivingBuffer.init( m_oParams.iChannels, m_oParams.iRingBufferSize, false );
std::string paras = std::string("NetAudioLogClient") + std::string("_BS") + std::to_string(pParent->GetBlocklength()) + std::string("_Ch") + std::to_string(pParent->GetNumberOfChannels()) + std::string("_tl") + std::to_string(pParent->GetAllowedLatencySamples()) + std::string(".txt");
m_pClientLogger = new ITABufferedDataLoggerImplClient( );
m_pClientLogger->setOutputFile(paras);
iStreamingBlockId = 0;
m_pMessage = new CITANetAudioMessage( VistaSerializingToolset::SWAPS_MULTIBYTE_VALUES );
m_sfReceivingBuffer.init(m_oParams.iChannels, m_oParams.iRingBufferSize, false);
m_pClientLogger = new ITABufferedDataLoggerImplClient();
SetClientLoggerBaseName( "ITANetAudioStreamingClient" );
}
CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
......@@ -73,7 +74,7 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
if( GetIsConnected() )
Disconnect();
StopGently( true );
StopGently( false );
delete m_pClientLogger;
delete m_pClient;
......@@ -84,10 +85,13 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
{
if( GetIsConnected() )
return false;
if( !m_pClient->Connect( sAddress, iPort ) )
ITA_EXCEPT1( INVALID_PARAMETER, "Could not connect to " + sAddress );
if( !m_pClient->GetIsConnected() )
return false;
m_pConnection = m_pClient->GetConnection();
m_pMessage->ResetMessage();
......@@ -96,17 +100,17 @@ bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPor
// Validate streaming parameters of server and client
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_OPEN );
m_pMessage->WriteStreamingParameters( m_oParams );
m_pMessage->WriteMessage( );
m_pMessage->ResetMessage( );
m_pMessage->WriteMessage();
m_pMessage->ResetMessage();
while ( !m_pMessage->ReadMessage( 0 ) );
assert( m_pMessage->GetMessageType( ) == CITANetAudioProtocol::NP_SERVER_OPEN );
bool bOK = m_pMessage->ReadBool();
if( !bOK )
ITA_EXCEPT1( INVALID_PARAMETER, "Streaming server declined connection, detected streaming parameter mismatch." );
while( !m_pMessage->ReadMessage( 0 ) );
assert( m_pMessage->GetMessageType() == CITANetAudioProtocol::NP_SERVER_OPEN );
// Clock sync vars
m_dServerClockSyncRequestTimeInterval = m_pMessage->ReadDouble();
m_dServerClockSyncLastSyncTime = 0;
Run();
return true;
......@@ -118,7 +122,12 @@ bool CITANetAudioStreamingClient::LoopBody()
return true;
ITAClientLog oLog;
oLog.uiBlockId = ++iStreamingBlockId;
oLog.uiBlockId = ++m_iStreamingBlockId;
oLog.iChannel = m_pStream->GetNumberOfChannels();
oLog.iFreeSamples = m_pStream->GetRingBufferFreeSamples();
oLog.iProtocolStatus = CITANetAudioProtocol::NP_CLIENT_IDLE;
oLog.dWorldTimeStamp = ITAClock::getDefaultClock()->getTime();
if( m_bStopIndicated && !m_bStopped )
{
......@@ -143,12 +152,13 @@ bool CITANetAudioStreamingClient::LoopBody()
return true;
}
// Read answer (blocking)
m_pMessage->ResetMessage( );
// Try-read message (blocking for a timeout of 1ms)
m_pMessage->ResetMessage();
m_swTryReadStats.start();
if( m_pMessage->ReadMessage( 1 ) )
{
m_swTryReadStats.stop();
int iMsgType = m_pMessage->GetMessageType();
switch( iMsgType )
{
......@@ -160,36 +170,58 @@ bool CITANetAudioStreamingClient::LoopBody()
vstr::out() << "[ITANetAudioStreamingClient] Recived " << m_sfReceivingBuffer.GetLength() << " samples" << std::endl;
#endif
break;
case CITANetAudioProtocol::NP_SERVER_GET_RINGBUFFER_FREE_SAMPLES:
m_pMessage->ReadBool();
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES );
m_pMessage->WriteInt( m_pStream->GetRingBufferFreeSamples() );
m_pMessage->WriteMessage();
break;
case CITANetAudioProtocol::NP_SERVER_CLOSE:
Disconnect();
break;
default:
vstr::out() << "[ITANetAudioStreamingServer] Unkown protocol type : " << iMsgType << std::endl;
break;
}
oLog.iChannel = m_pStream->GetNumberOfChannels();
// Also log message type on incoming message
oLog.iProtocolStatus = iMsgType;
oLog.iFreeSamples = m_pStream->GetRingBufferFreeSamples();
oLog.dWorldTimeStamp = ITAClock::getDefaultClock( )->getTime( );
m_pClientLogger->log( oLog );
}
else
m_swTryReadStats.stop();
m_pClientLogger->log( oLog );
// Send ring buffer free samples occasionally (as requested by server)
const double dNow = ITAClock::getDefaultClock()->getTime();
if( ( m_dServerClockSyncLastSyncTime + m_dServerClockSyncRequestTimeInterval ) < dNow )
{
// sende mal freie samples
m_pMessage->SetMessageType(CITANetAudioProtocol::NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES);
m_pMessage->WriteInt(m_pStream->GetRingBufferFreeSamples());
m_pMessage->SetMessageType( CITANetAudioProtocol::NP_CLIENT_SENDING_RINGBUFFER_FREE_SAMPLES );
m_pMessage->WriteInt( m_pStream->GetRingBufferFreeSamples() );
m_pMessage->WriteMessage();
m_dServerClockSyncLastSyncTime = dNow;
}
return false;
}
std::string CITANetAudioStreamingClient::GetClientLoggerBaseName() const
{
return m_sClientLoggerBaseName;
}
void CITANetAudioStreamingClient::SetClientLoggerBaseName( const std::string& sBaseName )
{
m_sClientLoggerBaseName = sBaseName;
m_pClientLogger->setOutputFile( m_sClientLoggerBaseName );
m_pMessage->SetMessageLoggerBaseName( GetClientLoggerBaseName() + "_Messages" );
}
bool CITANetAudioStreamingClient::GetIsConnected() const
{
return m_pClient->GetIsConnected();
......@@ -201,8 +233,9 @@ void CITANetAudioStreamingClient::Disconnect()
while( !m_bStopped )
VistaTimeUtils::Sleep( 100 );
m_pConnection = NULL;
m_pMessage->ClearConnection();
m_pClient->Disconnect();
m_bStopIndicated = false;
m_bStopped = false;
......
This diff is collapsed.
#include <iostream>
#include <string>
#include <sstream>
#include <ITANetAudioStream.h>
#include <ITAPortaudioInterface.h>
......@@ -13,127 +14,97 @@
using namespace std;
int main(int argc, char* argv[])
string g_sServerName = "localhost";
int g_iServerPort = 12480;
double g_dSampleRate = 44100.0;
int g_iBlockLength = 64;
int g_iChannels = 2;
int g_iRingBufferSize = 88200;
double g_dPlaybackDuration = 10; // seconds
int main( int argc, char* argv[] )
{
if (argc != 7)
if( argc >= 7 )
{
fprintf(stderr, "Fehler: Syntax = ServerName ServerPort SampleRate BufferSize Channel RingBufferSize!\n");
}
string sServerName = argv[1];
unsigned int iServerPort = atoi(argv[2]);
double dSampleRate = strtod(argv[3], NULL);
int iBlockLength = atoi(argv[4]);
int iChannels = atoi(argv[5]);
int iBufferSize = atoi(argv[6]);
cout << "Channel " << iChannels << endl;
CITANetAudioStream oNetAudioStream(iChannels, dSampleRate, iBlockLength, 1 * iBufferSize);
ITAStreamPatchbay oPatchbay(dSampleRate, iBlockLength);