git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2503 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
@@ -35,7 +35,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
namespace Jack | |||
{ | |||
JackNetDriver::JackNetDriver ( const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, | |||
const char* ip, size_t port, int midi_input_ports, int midi_output_ports, const char* net_name ) | |||
const char* ip, unsigned int port, int midi_input_ports, int midi_output_ports, const char* net_name ) | |||
: JackAudioDriver ( name, alias, engine, table ) | |||
{ | |||
fMulticastIP = new char[strlen ( ip ) + 1]; | |||
@@ -411,7 +411,7 @@ namespace Jack | |||
return static_cast<JackMidiBuffer*> ( fGraphManager->GetBuffer ( fMidiPlaybackPortList[port_index], fEngineControl->fBufferSize ) ); | |||
} | |||
int JackNetDriver::Recv ( size_t size, int flags ) | |||
int JackNetDriver::Recv ( unsigned int size, int flags ) | |||
{ | |||
int rx_bytes; | |||
if ( ( rx_bytes = recv ( fSockfd, fRxBuffer, size, flags ) ) < 0 ) | |||
@@ -435,7 +435,7 @@ namespace Jack | |||
return rx_bytes; | |||
} | |||
int JackNetDriver::Send ( size_t size, int flags ) | |||
int JackNetDriver::Send ( unsigned int size, int flags ) | |||
{ | |||
int tx_bytes; | |||
if ( ( tx_bytes = send ( fSockfd, fTxBuffer, size, flags ) ) < 0 ) | |||
@@ -456,7 +456,7 @@ namespace Jack | |||
int JackNetDriver::Read() | |||
{ | |||
int rx_bytes; | |||
size_t recvd_midi_pckt = 0; | |||
unsigned int recvd_midi_pckt = 0; | |||
packet_header_t* rx_head = reinterpret_cast<packet_header_t*> ( fRxBuffer ); | |||
fRxHeader.fIsLastPckt = 'n'; | |||
@@ -536,7 +536,7 @@ namespace Jack | |||
fTxHeader.fDataType = 'm'; | |||
fTxHeader.fMidiDataSize = fNetMidiPlaybackBuffer->RenderFromJackPorts(); | |||
fTxHeader.fNMidiPckt = GetNMidiPckt ( &fParams, fTxHeader.fMidiDataSize ); | |||
for ( size_t subproc = 0; subproc < fTxHeader.fNMidiPckt; subproc++ ) | |||
for ( unsigned int subproc = 0; subproc < fTxHeader.fNMidiPckt; subproc++ ) | |||
{ | |||
fTxHeader.fSubCycle = subproc; | |||
if ( ( subproc == ( fTxHeader.fNMidiPckt - 1 ) ) && !fParams.fReturnAudioChannels ) | |||
@@ -551,7 +551,7 @@ namespace Jack | |||
if ( fParams.fReturnAudioChannels ) | |||
{ | |||
fTxHeader.fDataType = 'a'; | |||
for ( size_t subproc = 0; subproc < fNSubProcess; subproc++ ) | |||
for ( unsigned int subproc = 0; subproc < fNSubProcess; subproc++ ) | |||
{ | |||
fTxHeader.fSubCycle = subproc; | |||
if ( subproc == ( fNSubProcess - 1 ) ) | |||
@@ -577,7 +577,7 @@ namespace Jack | |||
desc->nparams = 7; | |||
desc->params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) ); | |||
size_t i = 0; | |||
unsigned int i = 0; | |||
strcpy ( desc->params[i].name, "multicast_ip" ); | |||
desc->params[i].character = 'a'; | |||
desc->params[i].type = JackDriverParamString; | |||
@@ -32,10 +32,10 @@ namespace Jack | |||
private: | |||
session_params_t fParams; | |||
char* fMulticastIP; | |||
size_t fPort; | |||
unsigned int fPort; | |||
int fSockfd; | |||
struct sockaddr_in fMasterAddr; | |||
size_t fNSubProcess; | |||
unsigned int fNSubProcess; | |||
jack_port_id_t* fMidiCapturePortList; | |||
jack_port_id_t* fMidiPlaybackPortList; | |||
@@ -67,12 +67,12 @@ namespace Jack | |||
JackMidiBuffer* GetMidiInputBuffer ( int port_index ); | |||
JackMidiBuffer* GetMidiOutputBuffer ( int port_index ); | |||
int Recv ( size_t size, int flags ); | |||
int Send ( size_t size, int flags ); | |||
int Recv ( unsigned int size, int flags ); | |||
int Send ( unsigned int size, int flags ); | |||
public: | |||
JackNetDriver ( const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, | |||
const char* ip, size_t port, int midi_input_ports, int midi_output_ports, const char* master_name ); | |||
const char* ip, unsigned int port, int midi_input_ports, int midi_output_ports, const char* master_name ); | |||
~JackNetDriver(); | |||
int Open ( jack_nframes_t frames_per_cycle, jack_nframes_t rate, bool capturing, bool playing, | |||
@@ -130,7 +130,7 @@ namespace Jack | |||
struct timeval timeout; | |||
timeout.tv_sec = 1; | |||
timeout.tv_usec = 0; | |||
size_t attempt = 0; | |||
unsigned int attempt = 0; | |||
int rx_bytes = 0; | |||
//socket | |||
@@ -273,7 +273,7 @@ namespace Jack | |||
close ( mcast_sockfd ); | |||
} | |||
int JackNetMaster::Send ( char* buffer, size_t size, int flags ) | |||
int JackNetMaster::Send ( char* buffer, unsigned int size, int flags ) | |||
{ | |||
int tx_bytes; | |||
if ( ( tx_bytes = send ( fSockfd, buffer, size, flags ) ) < 0 ) | |||
@@ -292,7 +292,7 @@ namespace Jack | |||
return tx_bytes; | |||
} | |||
int JackNetMaster::Recv ( size_t size, int flags ) | |||
int JackNetMaster::Recv ( unsigned int size, int flags ) | |||
{ | |||
int rx_bytes; | |||
if ( ( rx_bytes = recv ( fSockfd, fRxBuffer, size, flags ) ) < 0 ) | |||
@@ -333,7 +333,7 @@ namespace Jack | |||
return 0; | |||
int tx_bytes, rx_bytes, copy_size; | |||
size_t midi_recvd_pckt = 0; | |||
unsigned int midi_recvd_pckt = 0; | |||
fTxHeader.fCycle++; | |||
fTxHeader.fSubCycle = 0; | |||
fTxHeader.fIsLastPckt = 'n'; | |||
@@ -368,7 +368,7 @@ namespace Jack | |||
fTxHeader.fDataType = 'm'; | |||
fTxHeader.fMidiDataSize = fNetMidiCaptureBuffer->RenderFromJackPorts(); | |||
fTxHeader.fNMidiPckt = GetNMidiPckt ( &fParams, fTxHeader.fMidiDataSize ); | |||
for ( size_t subproc = 0; subproc < fTxHeader.fNMidiPckt; subproc++ ) | |||
for ( unsigned int subproc = 0; subproc < fTxHeader.fNMidiPckt; subproc++ ) | |||
{ | |||
fTxHeader.fSubCycle = subproc; | |||
if ( ( subproc == ( fTxHeader.fNMidiPckt - 1 ) ) && !fParams.fSendAudioChannels ) | |||
@@ -385,7 +385,7 @@ namespace Jack | |||
if ( fParams.fSendAudioChannels ) | |||
{ | |||
fTxHeader.fDataType = 'a'; | |||
for ( size_t subproc = 0; subproc < fNSubProcess; subproc++ ) | |||
for ( unsigned int subproc = 0; subproc < fNSubProcess; subproc++ ) | |||
{ | |||
fTxHeader.fSubCycle = subproc; | |||
if ( subproc == ( fNSubProcess - 1 ) ) | |||
@@ -479,7 +479,7 @@ namespace Jack | |||
struct timeval timeout; | |||
timeout.tv_sec = 2; | |||
timeout.tv_usec = 0; | |||
size_t attempt = 0; | |||
unsigned int attempt = 0; | |||
//network | |||
int mcast_sockfd; | |||
@@ -617,7 +617,7 @@ namespace Jack | |||
sprintf ( params.fName, "%s-%u", params.fName, params.fID ); | |||
} | |||
master_list_it_t JackNetMasterManager::FindMaster ( size_t id ) | |||
master_list_it_t JackNetMasterManager::FindMaster ( unsigned int id ) | |||
{ | |||
jack_log ( "JackNetMasterManager::FindMaster, ID %u.", id ); | |||
master_list_it_t it; | |||
@@ -43,8 +43,8 @@ namespace Jack | |||
struct sockaddr_in fAddr; | |||
struct sockaddr_in fMcastAddr; | |||
int fSockfd; | |||
size_t fNSubProcess; | |||
size_t fNetJumpCnt; | |||
unsigned int fNSubProcess; | |||
unsigned int fNetJumpCnt; | |||
bool fRunning; | |||
jack_client_t* fJackClient; | |||
@@ -75,8 +75,8 @@ namespace Jack | |||
void FreePorts(); | |||
void Exit(); | |||
int Send ( char* buffer, size_t size, int flags ); | |||
int Recv ( size_t size, int flags ); | |||
int Send ( char* buffer, unsigned int size, int flags ); | |||
int Recv ( unsigned int size, int flags ); | |||
int Process(); | |||
public: | |||
JackNetMaster ( JackNetMasterManager* manager, session_params_t& params, struct sockaddr_in& address, struct sockaddr_in& mcast_addr ); | |||
@@ -97,13 +97,13 @@ namespace Jack | |||
const char* fMCastIP; | |||
pthread_t fManagerThread; | |||
master_list_t fMasterList; | |||
size_t fGlobalID; | |||
unsigned int fGlobalID; | |||
bool fRunning; | |||
size_t fPort; | |||
unsigned int fPort; | |||
void Run(); | |||
JackNetMaster* MasterInit ( session_params_t& params, struct sockaddr_in& address, struct sockaddr_in& mcast_addr ); | |||
master_list_it_t FindMaster ( size_t client_id ); | |||
master_list_it_t FindMaster ( unsigned int client_id ); | |||
void KillMaster ( session_params_t* params ); | |||
void SetSlaveName ( session_params_t& params ); | |||
int Process(); | |||
@@ -8,7 +8,7 @@ namespace Jack | |||
{ | |||
// NetMidiBuffer********************************************************************************** | |||
NetMidiBuffer::NetMidiBuffer ( session_params_t* params, size_t nports, char* net_buffer ) | |||
NetMidiBuffer::NetMidiBuffer ( session_params_t* params, unsigned int nports, char* net_buffer ) | |||
{ | |||
fNPorts = nports; | |||
fMaxBufsize = fNPorts * sizeof ( sample_t ) * params->fPeriodSize ; | |||
@@ -26,7 +26,7 @@ namespace Jack | |||
delete[] fPortBuffer; | |||
} | |||
size_t NetMidiBuffer::GetSize() | |||
unsigned int NetMidiBuffer::GetSize() | |||
{ | |||
return fMaxBufsize; | |||
} | |||
@@ -35,7 +35,7 @@ namespace Jack | |||
{ | |||
for ( int port_index = 0; port_index < fNPorts; port_index++ ) | |||
{ | |||
for ( size_t event = 0; event < fPortBuffer[port_index]->event_count; event++ ) | |||
for ( unsigned int event = 0; event < fPortBuffer[port_index]->event_count; event++ ) | |||
if ( fPortBuffer[port_index]->IsValid() ) | |||
jack_info ( "port %d : midi event %u/%u -> time : %u, size : %u", | |||
port_index + 1, event + 1, fPortBuffer[port_index]->event_count, | |||
@@ -75,13 +75,13 @@ namespace Jack | |||
return pos; | |||
} | |||
int NetMidiBuffer::RenderFromNetwork ( size_t subcycle, size_t copy_size ) | |||
int NetMidiBuffer::RenderFromNetwork ( unsigned int subcycle, unsigned int copy_size ) | |||
{ | |||
memcpy ( fBuffer + subcycle * fMaxPcktSize, fNetBuffer, copy_size ); | |||
return copy_size; | |||
} | |||
int NetMidiBuffer::RenderToNetwork ( size_t subcycle, size_t total_size ) | |||
int NetMidiBuffer::RenderToNetwork ( unsigned int subcycle, unsigned int total_size ) | |||
{ | |||
int size = total_size - subcycle * fMaxPcktSize; | |||
int copy_size = ( size <= fMaxPcktSize ) ? size : fMaxPcktSize; | |||
@@ -91,7 +91,7 @@ namespace Jack | |||
// net audio buffer ********************************************************************************* | |||
NetAudioBuffer::NetAudioBuffer ( session_params_t* params, size_t nports, char* net_buffer ) | |||
NetAudioBuffer::NetAudioBuffer ( session_params_t* params, unsigned int nports, char* net_buffer ) | |||
{ | |||
fNPorts = nports; | |||
fPeriodSize = params->fPeriodSize; | |||
@@ -108,18 +108,18 @@ namespace Jack | |||
delete[] fPortBuffer; | |||
} | |||
size_t NetAudioBuffer::GetSize() | |||
unsigned int NetAudioBuffer::GetSize() | |||
{ | |||
return fNPorts * fSubPeriodBytesSize; | |||
} | |||
void NetAudioBuffer::RenderFromJackPorts ( size_t subcycle ) | |||
void NetAudioBuffer::RenderFromJackPorts ( unsigned int subcycle ) | |||
{ | |||
for ( int port_index = 0; port_index < fNPorts; port_index++ ) | |||
memcpy ( fNetBuffer + port_index * fSubPeriodBytesSize, fPortBuffer[port_index] + subcycle * fSubPeriodSize, fSubPeriodBytesSize ); | |||
} | |||
void NetAudioBuffer::RenderToJackPorts ( size_t subcycle ) | |||
void NetAudioBuffer::RenderToJackPorts ( unsigned int subcycle ) | |||
{ | |||
for ( int port_index = 0; port_index < fNPorts; port_index++ ) | |||
memcpy ( fPortBuffer[port_index] + subcycle * fSubPeriodSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize ); | |||
@@ -257,24 +257,24 @@ namespace Jack | |||
// Utility ******************************************************************************************************* | |||
EXPORT size_t SetFramesPerPacket ( session_params_t* params ) | |||
EXPORT unsigned int SetFramesPerPacket ( session_params_t* params ) | |||
{ | |||
if ( !params->fSendAudioChannels && !params->fReturnAudioChannels ) | |||
return ( params->fFramesPerPacket = params->fPeriodSize ); | |||
size_t period = ( int ) powf ( 2.f, ( int ) log2 ( ( params->fMtu - sizeof ( packet_header_t ) ) | |||
unsigned int period = ( int ) powf ( 2.f, ( int ) log2 ( ( params->fMtu - sizeof ( packet_header_t ) ) | |||
/ ( max ( params->fReturnAudioChannels, params->fSendAudioChannels ) * sizeof ( sample_t ) ) ) ); | |||
( period > params->fPeriodSize ) ? params->fFramesPerPacket = params->fPeriodSize : params->fFramesPerPacket = period; | |||
return params->fFramesPerPacket; | |||
} | |||
EXPORT size_t GetNMidiPckt ( session_params_t* params, size_t data_size ) | |||
EXPORT unsigned int GetNMidiPckt ( session_params_t* params, unsigned int data_size ) | |||
{ | |||
//even if there is no midi data, jack need an empty buffer to know there is no event to read | |||
//99% of the cases : all data in one packet | |||
if ( data_size <= ( params->fMtu - sizeof ( packet_header_t ) ) ) | |||
return 1; | |||
//else, get the number of needed packets (simply slice the biiig buffer) | |||
size_t npckt = data_size / ( params->fMtu - sizeof ( packet_header_t ) ); | |||
unsigned int npckt = data_size / ( params->fMtu - sizeof ( packet_header_t ) ); | |||
if ( data_size % ( params->fMtu - sizeof ( packet_header_t ) ) ) | |||
return ++npckt; | |||
return npckt; | |||
@@ -295,7 +295,7 @@ namespace Jack | |||
// Packet ******************************************************************************************************* | |||
EXPORT bool IsNextPacket ( packet_header_t* previous, packet_header_t* next, size_t subcycles ) | |||
EXPORT bool IsNextPacket ( packet_header_t* previous, packet_header_t* next, unsigned int subcycles ) | |||
{ | |||
//ignore first cycle | |||
if ( previous->fCycle <= 1 ) | |||
@@ -38,16 +38,16 @@ namespace Jack | |||
int fPacketID; //indicates the packet type | |||
char fMasterNetName[256]; //master hostname (network) | |||
char fSlaveNetName[256]; //slave hostname (network) | |||
size_t fMtu; //connection mtu | |||
size_t fID; //slave's ID | |||
unsigned int fMtu; //connection mtu | |||
unsigned int fID; //slave's ID | |||
int fSendAudioChannels; //number of master->slave channels | |||
int fReturnAudioChannels; //number of slave->master channels | |||
int fSendMidiChannels; //number of master->slave midi channels | |||
int fReturnMidiChannels; //number of slave->master midi channels | |||
size_t fSampleRate; //session sample rate | |||
size_t fPeriodSize; //period size | |||
size_t fFramesPerPacket; //complete frames per packet | |||
size_t fBitdepth; //samples bitdepth (unused) | |||
unsigned int fSampleRate; //session sample rate | |||
unsigned int fPeriodSize; //period size | |||
unsigned int fFramesPerPacket; //complete frames per packet | |||
unsigned int fBitdepth; //samples bitdepth (unused) | |||
char fName[JACK_CLIENT_NAME_SIZE]; //slave's name | |||
}; | |||
@@ -90,12 +90,12 @@ namespace Jack | |||
char fPacketType[7]; //packet type ( 'headr' ) | |||
char fDataType; //a for audio, m for midi | |||
char fDataStream; //s for send, r for return | |||
size_t fID; //to identify the slave | |||
size_t fBitdepth; //bitdepth of the data samples | |||
size_t fMidiDataSize; //size of midi data (if packet is 'midi typed') in bytes | |||
size_t fNMidiPckt; //number of midi packets of the cycle | |||
size_t fCycle; //process cycle counter | |||
size_t fSubCycle; //midi/audio subcycle counter | |||
unsigned int fID; //to identify the slave | |||
unsigned int fBitdepth; //bitdepth of the data samples | |||
unsigned int fMidiDataSize; //size of midi data (if packet is 'midi typed') in bytes | |||
unsigned int fNMidiPckt; //number of midi packets of the cycle | |||
unsigned int fCycle; //process cycle counter | |||
unsigned int fSubCycle; //midi/audio subcycle counter | |||
char fIsLastPckt; //is it the last packet of a given cycle ('y' or 'n') | |||
char fFree[13]; //unused | |||
}; | |||
@@ -106,27 +106,27 @@ namespace Jack | |||
{ | |||
private: | |||
int fNPorts; | |||
size_t fMaxBufsize; | |||
unsigned int fMaxBufsize; | |||
int fMaxPcktSize; | |||
//data | |||
char* fBuffer; | |||
char* fNetBuffer; | |||
public: | |||
NetMidiBuffer ( session_params_t* params, size_t nports, char* net_buffer ); | |||
NetMidiBuffer ( session_params_t* params, unsigned int nports, char* net_buffer ); | |||
~NetMidiBuffer(); | |||
JackMidiBuffer** fPortBuffer; | |||
void Reset(); | |||
size_t GetSize(); | |||
unsigned int GetSize(); | |||
//utility | |||
void DisplayEvents(); | |||
//jack<->buffer | |||
int RenderFromJackPorts(); | |||
int RenderToJackPorts(); | |||
//network<->buffer | |||
int RenderFromNetwork ( size_t subcycle, size_t copy_size ); | |||
int RenderToNetwork ( size_t subcycle, size_t copy_size ); | |||
int RenderFromNetwork ( unsigned int subcycle, unsigned int copy_size ); | |||
int RenderToNetwork ( unsigned int subcycle, unsigned int copy_size ); | |||
}; | |||
// audio data ********************************************************************************* | |||
@@ -137,18 +137,18 @@ namespace Jack | |||
int fNPorts; | |||
jack_nframes_t fPeriodSize; | |||
jack_nframes_t fSubPeriodSize; | |||
size_t fSubPeriodBytesSize; | |||
unsigned int fSubPeriodBytesSize; | |||
char* fNetBuffer; | |||
public: | |||
NetAudioBuffer ( session_params_t* params, size_t nports, char* net_buffer ); | |||
NetAudioBuffer ( session_params_t* params, unsigned int nports, char* net_buffer ); | |||
~NetAudioBuffer(); | |||
sample_t** fPortBuffer; | |||
size_t GetSize(); | |||
unsigned int GetSize(); | |||
//jack<->buffer | |||
void RenderFromJackPorts ( size_t subcycle ); | |||
void RenderToJackPorts ( size_t subcycle ); | |||
void RenderFromJackPorts ( unsigned int subcycle ); | |||
void RenderToJackPorts ( unsigned int subcycle ); | |||
}; | |||
//utility ************************************************************************************* | |||
@@ -167,11 +167,11 @@ namespace Jack | |||
//set the packet type in a session parameters | |||
EXPORT int SetPacketType ( session_params_t* params, sync_packet_type_t packet_type ); | |||
//step of network initialization | |||
EXPORT size_t SetFramesPerPacket ( session_params_t* params ); | |||
EXPORT unsigned int SetFramesPerPacket ( session_params_t* params ); | |||
//get the midi packet number for a given cycle | |||
EXPORT size_t GetNMidiPckt ( session_params_t* params, size_t data_size ); | |||
EXPORT unsigned int GetNMidiPckt ( session_params_t* params, unsigned int data_size ); | |||
//set the recv timeout on a socket | |||
EXPORT int SetRxTimeout ( int* sockfd, session_params_t* params ); | |||
//check if 'next' packet is really the next after 'previous' | |||
EXPORT bool IsNextPacket ( packet_header_t* previous, packet_header_t* next, size_t subcycles ); | |||
EXPORT bool IsNextPacket ( packet_header_t* previous, packet_header_t* next, unsigned int subcycles ); | |||
} |