Commit 3e1864c4 authored by sletz's avatar sletz
Browse files

Move generic code and data in JackNetInterface and JackNetMasterInterface classes.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3335 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 0e86ff06
......@@ -25,7 +25,8 @@ Michael Voigt
2009-02-23 Stephane Letz <letz@grame.fr>
* Another fix in systemdeps.h and types.h: jack_time_t now uniquely defined in types.h.
* Another fix in systemdeps.h and types.h: jack_time_t now uniquely defined in types.h.
* Move generic code and data in JackNetInterface and JackNetMasterInterface classes.
2009-02-20 Stephane Letz <letz@grame.fr>
......
......@@ -42,6 +42,8 @@ namespace Jack
fNetAudioPlaybackBuffer = NULL;
fNetMidiCaptureBuffer = NULL;
fNetMidiPlaybackBuffer = NULL;
memset(&fSendTransportData, 0, sizeof(net_transport_data_t));
memset(&fReturnTransportData, 0, sizeof(net_transport_data_t));
}
JackNetInterface::JackNetInterface ( const char* multicast_ip, int port ) : fSocket ( multicast_ip, port )
......@@ -53,6 +55,8 @@ namespace Jack
fNetAudioPlaybackBuffer = NULL;
fNetMidiCaptureBuffer = NULL;
fNetMidiPlaybackBuffer = NULL;
memset(&fSendTransportData, 0, sizeof(net_transport_data_t));
memset(&fReturnTransportData, 0, sizeof(net_transport_data_t));
}
JackNetInterface::JackNetInterface ( session_params_t& params, JackNetSocket& socket, const char* multicast_ip ) : fSocket ( socket )
......@@ -65,6 +69,8 @@ namespace Jack
fNetAudioPlaybackBuffer = NULL;
fNetMidiCaptureBuffer = NULL;
fNetMidiPlaybackBuffer = NULL;
memset(&fSendTransportData, 0, sizeof(net_transport_data_t));
memset(&fReturnTransportData, 0, sizeof(net_transport_data_t));
}
JackNetInterface::~JackNetInterface()
......@@ -558,6 +564,41 @@ namespace Jack
}
return rx_bytes;
}
int JackNetMasterInterface::EncodeSyncPacket()
{
//this method contains every step of sync packet informations coding
//first of all, reset sync packet
memset ( fTxData, 0, fPayloadSize );
//then, first step : transport
if ( fParams.fTransportSync )
{
if ( EncodeTransportData() < 0 )
return -1;
//copy to TxBuffer
memcpy ( fTxData, &fSendTransportData, sizeof ( net_transport_data_t ) );
}
//then others (freewheel etc.)
//...
return 0;
}
int JackNetMasterInterface::DecodeSyncPacket()
{
//this method contains every step of sync packet informations decoding process
//first : transport
if ( fParams.fTransportSync )
{
//copy received transport data to transport data structure
memcpy ( &fReturnTransportData, fRxData, sizeof ( net_transport_data_t ) );
if ( DecodeTransportData() < 0 )
return -1;
}
//then others
//...
return 0;
}
// JackNetSlaveInterface ************************************************************************************************
......
......@@ -40,6 +40,10 @@ namespace Jack
//headers
packet_header_t fTxHeader;
packet_header_t fRxHeader;
// transport
net_transport_data_t fSendTransportData;
net_transport_data_t fReturnTransportData;
//network buffers
char* fTxBuffer;
......@@ -105,11 +109,18 @@ namespace Jack
bool Init();
int SetRxTimeout();
void SetParams();
void Exit();
int SyncRecv();
int SyncSend();
int DataRecv();
int DataSend();
//sync packet
int EncodeSyncPacket();
int DecodeSyncPacket();
int Send ( size_t size, int flags );
int Recv ( size_t size, int flags );
......@@ -135,10 +146,7 @@ namespace Jack
protected:
static uint fSlaveCounter;
net_transport_data_t fSendTransportData;
net_transport_data_t fReturnTransportData;
bool Init();
bool InitConnection();
bool InitRendering();
......
......@@ -343,41 +343,7 @@ namespace Jack
}
//sync--------------------------------------------------------------------------------
int JackNetMaster::EncodeSyncPacket()
{
//this method contains every step of sync packet informations coding
//first of all, reset sync packet
memset ( fTxData, 0, fPayloadSize );
//then, first step : transport
if ( fParams.fTransportSync )
{
if ( EncodeTransportData() < 0 )
return -1;
//copy to TxBuffer
memcpy ( fTxData, &fSendTransportData, sizeof ( net_transport_data_t ) );
}
//then others (freewheel etc.)
//...
return 0;
}
int JackNetMaster::DecodeSyncPacket()
{
//this method contains every step of sync packet informations decoding process
//first : transport
if ( fParams.fTransportSync )
{
//copy received transport data to transport data structure
memcpy ( &fReturnTransportData, fRxData, sizeof ( net_transport_data_t ) );
if ( DecodeTransportData() < 0 )
return -1;
}
//then others
//...
return 0;
}
bool JackNetMaster::IsSlaveReadyToRoll()
{
return ( fReturnTransportData.fState == JackTransportNetStarting );
......
......@@ -71,10 +71,6 @@ namespace Jack
int EncodeTransportData();
int DecodeTransportData();
//sync packet
int EncodeSyncPacket();
int DecodeSyncPacket();
int Process();
void TimebaseCallback ( jack_position_t* pos );
......
Supports Markdown
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