Refactoring #4

parent 03ea1737
......@@ -59,6 +59,7 @@ CITANetAudioMessage::CITANetAudioMessage( VistaSerializingToolset::ByteOrderSwap
, m_pConnection( NULL )
, m_iBytesReceivedTotal( 0 )
, m_sMessageLoggerBaseName( "ITANetAudioMessage" )
, m_bDebuggingEnabled( false )
{
m_pMessageLogger = new ITABufferedDataLoggerImplProtocol();
m_pMessageLogger->setOutputFile( m_sMessageLoggerBaseName + ".log" );
......@@ -201,8 +202,8 @@ bool CITANetAudioMessage::ReadMessage( int timeout )
VistaType::sint32 nMessagePayloadSize;
int nBytesRead = m_pConnection->ReadInt32( nMessagePayloadSize );
oLog.nMessagePayloadSize = nMessagePayloadSize;
assert( nBytesRead == sizeof( VistaType::sint32 ) );
oLog.nMessagePayloadSize = nMessagePayloadSize;
#if NET_AUDIO_SHOW_TRAFFIC
vstr::out() << "CITANetAudioMessage [ Reading ] Expecting " << nMessagePayloadSize << " bytes message payload" << std::endl;
#endif
......@@ -369,6 +370,8 @@ VistaConnectionIP* CITANetAudioMessage::GetConnection() const
void CITANetAudioMessage::ClearConnection()
{
m_pConnection = NULL;
if( GetIsDebuggingEnabled() == false )
m_pMessageLogger->setOutputFile( "" ); // disable output
delete m_pMessageLogger;
}
......@@ -462,4 +465,14 @@ void CITANetAudioMessage::SetMessageLoggerBaseName( const std::string& sBaseName
std::string CITANetAudioMessage::GetMessageLoggerBaseName() const
{
return m_sMessageLoggerBaseName;
}
\ No newline at end of file
}
void CITANetAudioMessage::SetDebuggingEnabled( bool bEnabled )
{
m_bDebuggingEnabled = bEnabled;
}
bool CITANetAudioMessage::GetIsDebuggingEnabled() const
{
return m_bDebuggingEnabled;
}
......@@ -98,6 +98,8 @@ public:
void SetMessageLoggerBaseName( const std::string& );
std::string GetMessageLoggerBaseName() const;
void SetDebuggingEnabled( bool bEnabled );
bool GetIsDebuggingEnabled() const;
private:
int m_nMessageType;
......@@ -112,6 +114,7 @@ private:
ITABufferedDataLoggerImplProtocol* m_pMessageLogger;
std::string m_sMessageLoggerBaseName;
bool m_bDebuggingEnabled;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_MESSAGE
......@@ -115,7 +115,7 @@ CITANetAudioStream::CITANetAudioStream(int iChannels, double dSamplingRate, int
CITANetAudioStream::~CITANetAudioStream()
{
if( m_bDebuggingEnabled == false )
if( GetIsDebuggingEnabled() == false )
{
m_pAudioStreamLogger->setOutputFile( "" ); // Disables file storing
m_pNetworkStreamLogger->setOutputFile( "" ); // Disables file storing
......@@ -391,6 +391,7 @@ void CITANetAudioStream::SetNetAudioStreamingLoggerBaseName( const std::string&
void CITANetAudioStream::SetDebuggingEnabled( bool bEnabled )
{
m_bDebuggingEnabled = bEnabled;
m_pNetAudioStreamingClient->SetDebuggingEnabled( bEnabled );
}
bool CITANetAudioStream::GetIsDebuggingEnabled() const
......
......@@ -57,6 +57,7 @@ CITANetAudioStreamingClient::CITANetAudioStreamingClient( CITANetAudioStream* pP
, m_iStreamingBlockId( 0 )
, m_dServerClockSyncRequestTimeInterval( 0.1f )
, m_dServerClockSyncLastSyncTime( 0.0f )
, m_bDebuggingEnabled( false )
{
m_pClient = new CITANetAudioClient();
......@@ -78,12 +79,18 @@ CITANetAudioStreamingClient::~CITANetAudioStreamingClient()
StopGently( false );
if( GetIsDebuggingEnabled() )
{
vstr::out() << "[ ITANetAudioStreamingClient ] Processing statistics: " << m_swTryReadBlockStats.ToString() << std::endl;
vstr::out() << "[ ITANetAudioStreamingClient ] Try-read access statistics: " << m_swTryReadAccessStats.ToString() << std::endl;
}
else
m_pClientLogger->setOutputFile( "" ); // disable output
delete m_pClientLogger;
delete m_pClient;
delete m_pMessage;
vstr::out() << "[ ITANetAudioStreamingClient ] Processing statistics: " << m_swTryReadBlockStats.ToString() << std::endl;
vstr::out() << "[ ITANetAudioStreamingClient ] Try-read access statistics: " << m_swTryReadAccessStats.ToString() << std::endl;
}
bool CITANetAudioStreamingClient::Connect( const std::string& sAddress, int iPort )
......@@ -249,6 +256,17 @@ void CITANetAudioStreamingClient::SetClientLoggerBaseName( const std::string& sB
m_pMessage->SetMessageLoggerBaseName( GetClientLoggerBaseName() + "_Messages" );
}
void CITANetAudioStreamingClient::SetDebuggingEnabled( bool bEnabled )
{
m_bDebuggingEnabled = bEnabled;
m_pMessage->SetDebuggingEnabled( bEnabled );
}
bool CITANetAudioStreamingClient::GetIsDebuggingEnabled() const
{
return m_bDebuggingEnabled;
}
bool CITANetAudioStreamingClient::GetIsConnected() const
{
return m_pClient->GetIsConnected();
......
......@@ -62,6 +62,9 @@ public:
std::string GetClientLoggerBaseName() const;
void SetClientLoggerBaseName( const std::string& );
void SetDebuggingEnabled( bool bEnabled );
bool GetIsDebuggingEnabled() const;
protected:
void TriggerBlockIncrement();
......@@ -86,6 +89,7 @@ private:
ITABufferedDataLoggerImplClient* m_pClientLogger;
std::string m_sClientLoggerBaseName;
ITAStopWatch m_swTryReadBlockStats, m_swTryReadAccessStats;
bool m_bDebuggingEnabled;
friend class CITANetAudioStream;
};
......
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