Commit ab5dd839 authored by Anne's avatar Anne

Audio Server überarbeitet

parent 9c7683fd
......@@ -39,16 +39,15 @@ class VistaTCPServer;
class ITA_DATA_SOURCES_API CITANetAudioServer
{
public:
CITANetAudioServer( CITANetAudioStreamingServer* pParent );
CITANetAudioServer();
virtual ~CITANetAudioServer();
std::string GetServerAddress() const;
int GetNetworkPort() const;
double GetClientSampleRate() const;
bool Start( const std::string& sAddress, int iPort );
VistaTCPSocket* GetSocket() const;
void Disconnect();
bool IsConnected() const;
bool LoopBody();
private:
......@@ -58,11 +57,5 @@ private:
int m_iServerPort;
std::string m_sServerAddress;
CITANetAudioStreamingServer* m_pParent;
ITASampleFrame m_sfReceivingBuffer;
bool m_bStopIndicated;
};
#endif // INCLUDE_WATCHER_ITA_NET_AUDIO_SERVER
......@@ -29,6 +29,7 @@
class ITADatasource;
class CITANetAudioServer;
class VistaTCPSocket;
//! Network audio sample server (for connecting a net audio stream)
/**
......@@ -73,15 +74,17 @@ private:
CITANetAudioServer* m_pNetAudioServer;
ITASampleFrame m_sfTempTransmitBuffer;
ITADatasource* m_pInputStream;
VistaTCPSocket* m_pSocket;
int m_iUpdateStrategy;
int m_iClientRingBufferFreeSamples;
friend class CITANetAudioServer;
// TODO: in nem Struct speichern
int m_iClientChannels;
int m_iClientRingBufferSize;
int m_iClientBufferSize;
int m_iClientRingBufferFreeSamples;
double m_dClientSampleRate;
};
......
......@@ -19,15 +19,9 @@
#include <cmath>
#include <cassert>
CITANetAudioServer::CITANetAudioServer( CITANetAudioStreamingServer* pParent )
: m_pParent( pParent )
, m_bStopIndicated( false )
, m_pServer( NULL )
CITANetAudioServer::CITANetAudioServer()
: m_pServer( NULL )
, m_pSocket( NULL )
, m_iClientRingBufferSize( -1 )
, m_iClientBufferSize( -1 )
, m_iClientRingBufferFreeSamples( 0 )
, m_dClientSampleRate( -1 )
, m_iServerPort( -1 )
{
};
......@@ -46,12 +40,7 @@ int CITANetAudioServer::GetNetworkPort() const
return m_iServerPort;
}
double CITANetAudioServer::GetClientSampleRate() const
{
return m_dClientSampleRate;
}
bool CITANetAudioServer::Start( const std::string& sAddress, int iPort )
bool CITANetAudioServer::Start(const std::string& sAddress, int iPort)
{
if( m_pServer )
ITA_EXCEPT1( MODAL_EXCEPTION, "This net sample server is already started" );
......@@ -62,34 +51,22 @@ bool CITANetAudioServer::Start( const std::string& sAddress, int iPort )
// blocking wait for connection
m_pSocket = m_pServer->GetNextClient();
if (m_pSocket != NULL)
return true;
return false;
}
// TODO: Init neu mit Netmessage
long nIncomingBytes = m_pSocket->WaitForIncomingData( 0 );
int iBytesReceived = m_pSocket->ReceiveRaw( &m_iClientChannels, sizeof( int ) );
iBytesReceived = m_pSocket->ReceiveRaw( &m_dClientSampleRate, sizeof( double ) );
iBytesReceived = m_pSocket->ReceiveRaw( &m_iClientBufferSize, sizeof( int ) );
iBytesReceived = m_pSocket->ReceiveRaw( &m_iClientRingBufferSize, sizeof( int ) );
m_iClientRingBufferFreeSamples = m_iClientRingBufferFreeSamples;
int iMessageID = 1;
m_pSocket->SendRaw( &iMessageID, sizeof( int ) );
Run();
return true;
VistaTCPSocket* CITANetAudioServer::GetSocket() const
{
return m_pSocket;
}
void CITANetAudioServer::Disconnect()
{
m_bStopIndicated = true;
StopGently( true );
m_pSocket = NULL;
delete m_pServer;
m_pServer = NULL;
m_bStopIndicated = false;
}
bool CITANetAudioServer::IsConnected() const
......@@ -98,28 +75,4 @@ bool CITANetAudioServer::IsConnected() const
return false;
return m_pSocket->GetIsConnected();
}
bool CITANetAudioServer::LoopBody()
{
if( m_bStopIndicated )
return true;
if( m_pSocket->GetIsConnected() == false )
{
StopGently( true );
return false;
}
ITAStreamInfo oStreamInfo;
ITADatasource* pIn = m_pParent->GetInputStream();
for( int iChannelIndex = 0; iChannelIndex < int( m_pParent->GetInputStream()->GetNumberOfChannels() ); iChannelIndex++ )
{
const float* pfData = pIn->GetBlockPointer( iChannelIndex, &oStreamInfo );
int iNumSamples = pIn->GetBlocklength();
m_pSocket->SendRaw( pfData, iNumSamples * sizeof( float ) );
}
return true;
}
\ No newline at end of file
......@@ -21,14 +21,21 @@
CITANetAudioStreamingServer::CITANetAudioStreamingServer()
: m_pInputStream( NULL )
, m_iUpdateStrategy( AUTO )
, m_pSocket( NULL )
{
m_pNetAudioServer = new CITANetAudioServer( this );
m_pNetAudioServer = new CITANetAudioServer();
// TODO: Init members
}
bool CITANetAudioStreamingServer::Start( const std::string& sAddress, int iPort )
bool CITANetAudioStreamingServer::Start(const std::string& sAddress, int iPort)
{
return m_pNetAudioServer->Start( sAddress, iPort );
// TODO: vorrckgabe noch anfangen zu senden (Samples)
if (m_pNetAudioServer->Start(sAddress, iPort))
{
m_pSocket = m_pNetAudioServer->GetSocket();
return true;
}
return false;
}
bool CITANetAudioStreamingServer::IsClientConnected() const
......@@ -68,7 +75,7 @@ int CITANetAudioStreamingServer::GetNetStreamNumberOfChannels() const
double CITANetAudioStreamingServer::GetNetStreamSampleRate() const
{
return m_pNetAudioServer->GetClientSampleRate();
return m_dClientSampleRate;
}
void CITANetAudioStreamingServer::SetAutomaticUpdateRate()
......
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