Implementing missing audio stream info on NetAudio server side

parent 37d22377
...@@ -31,16 +31,35 @@ public: ...@@ -31,16 +31,35 @@ public:
inline CITASampleProcessor( const double dSampleRate, const int iNumChannels, const int iBlockLength ) inline CITASampleProcessor( const double dSampleRate, const int iNumChannels, const int iBlockLength )
: ITADatasourceRealization( ( unsigned int ) ( iNumChannels ), dSampleRate, ( unsigned int ) ( iBlockLength ) ) : ITADatasourceRealization( ( unsigned int ) ( iNumChannels ), dSampleRate, ( unsigned int ) ( iBlockLength ) )
{ {
m_vvfSampleBuffer.resize( iNumChannels );
for( size_t c = 0; c < iNumChannels; c++ ) for( size_t c = 0; c < iNumChannels; c++ )
{ m_vvfSampleBuffer[ c ].resize( iBlockLength );
m_vvfSampleBuffer.push_back( std::vector< float >() );
for( size_t n = 0; n < iBlockLength; n++ ) Zero();
m_vvfSampleBuffer[ c ].push_back( 0.0f );
}
}; };
inline ~CITASampleProcessor() {};
//! Sets all channels and samples to zero
inline void Zero()
{
/*
* Use this as an example how to work with the buffer structure.
*/
// Iterate over channels
for( size_t c = 0; c < m_vvfSampleBuffer.size(); c++ )
{
std::vector< float >& vfSingleChannelSampleBuffer( m_vvfSampleBuffer[ c ] ); // One channel
// Iterate over samples of channel
for( size_t n = 0; n < vfSingleChannelSampleBuffer.size(); n++ )
{
float& fSample( vfSingleChannelSampleBuffer[ n ] ); // One sample
fSample = 0.0f; // -> Manipulation
}
}
};
//! Process samples (overwrite this virtual method) //! Process samples (overwrite this virtual method)
/** /**
* Method that is called in audio streaming context and requests * Method that is called in audio streaming context and requests
...@@ -51,9 +70,9 @@ public: ...@@ -51,9 +70,9 @@ public:
virtual void Process( const ITAStreamInfo* pStreamInfo ) =0; virtual void Process( const ITAStreamInfo* pStreamInfo ) =0;
protected: protected:
std::vector< std::vector< float > > m_vvfSampleBuffer; //!< Multi-channel sample buffer std::vector< std::vector< float > > m_vvfSampleBuffer; //!< Multi-channel sample buffer to be filled
public: private:
//! Delegate internal buffer to audio stream //! Delegate internal buffer to audio stream
inline void ProcessStream( const ITAStreamInfo* pInfo ) inline void ProcessStream( const ITAStreamInfo* pInfo )
{ {
......
...@@ -115,6 +115,9 @@ private: ...@@ -115,6 +115,9 @@ private:
int m_iSendingBlockLength; int m_iSendingBlockLength;
int m_iMaxSendBlocks; int m_iMaxSendBlocks;
double m_dStreamTimeStart; //!< Stream time start
long unsigned int m_nStreamSampleCounts; //!< Samples that has been streamed
friend class CITANetAudioServer; friend class CITANetAudioServer;
}; };
......
...@@ -71,6 +71,8 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer() ...@@ -71,6 +71,8 @@ CITANetAudioStreamingServer::CITANetAudioStreamingServer()
, m_iEstimatedClientRingBufferFreeSamples( 0 ) , m_iEstimatedClientRingBufferFreeSamples( 0 )
, m_iClientRingBufferSize( 0 ) , m_iClientRingBufferSize( 0 )
, m_dEstimatedCorrFactor( 1 ) , m_dEstimatedCorrFactor( 1 )
, m_dStreamTimeStart( 0.0f )
, m_nStreamSampleCounts( 0 )
{ {
// Careful with this: // Careful with this:
//SetPriority( VistaPriority::VISTA_MID_PRIORITY ); //SetPriority( VistaPriority::VISTA_MID_PRIORITY );
...@@ -160,6 +162,9 @@ bool CITANetAudioStreamingServer::LoopBody() ...@@ -160,6 +162,9 @@ bool CITANetAudioStreamingServer::LoopBody()
{ {
const double dNow = ITAClock::getDefaultClock()->getTime(); const double dNow = ITAClock::getDefaultClock()->getTime();
if( m_dStreamTimeStart == 0.0f )
m_dStreamTimeStart = dNow;
CITAServerLog oLog; CITAServerLog oLog;
oLog.dWorldTimeStamp = dNow; oLog.dWorldTimeStamp = dNow;
oLog.uiBlockId = ++m_iServerBlockId; oLog.uiBlockId = ++m_iServerBlockId;
...@@ -182,10 +187,11 @@ bool CITANetAudioStreamingServer::LoopBody() ...@@ -182,10 +187,11 @@ bool CITANetAudioStreamingServer::LoopBody()
for( int i = 0; i < int( m_pInputStream->GetNumberOfChannels() ); i++ ) for( int i = 0; i < int( m_pInputStream->GetNumberOfChannels() ); i++ )
{ {
ITAStreamInfo oStreamInfo; ITAStreamInfo oStreamInfo;
oStreamInfo.nSamples = m_iSendingBlockLength; oStreamInfo.nSamples = ( m_nStreamSampleCounts += m_iSendingBlockLength );
oStreamInfo.dTimecode = dNow - m_dStreamTimeStart;
const float* pfData = m_pInputStream->GetBlockPointer( i, &oStreamInfo ); const float* pfData = m_pInputStream->GetBlockPointer( i, &oStreamInfo );
if( pfData != 0 ) if( pfData != nullptr )
m_sfTempTransmitBuffer[ i ].write( pfData, m_iSendingBlockLength, 0 ); m_sfTempTransmitBuffer[ i ].write( pfData, m_iSendingBlockLength, 0 );
} }
......
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