git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2509 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
| @@ -35,12 +35,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| namespace Jack | namespace Jack | ||||
| { | { | ||||
| JackNetDriver::JackNetDriver ( const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, | 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, int port, int midi_input_ports, int midi_output_ports, const char* net_name ) | |||||
| : JackAudioDriver ( name, alias, engine, table ) | : JackAudioDriver ( name, alias, engine, table ) | ||||
| { | { | ||||
| fMulticastIP = new char[strlen ( ip ) + 1]; | fMulticastIP = new char[strlen ( ip ) + 1]; | ||||
| strcpy ( fMulticastIP, ip ); | strcpy ( fMulticastIP, ip ); | ||||
| fPort = port; | |||||
| fUDPPort = port; | |||||
| fParams.fSendMidiChannels = midi_input_ports; | fParams.fSendMidiChannels = midi_input_ports; | ||||
| fParams.fReturnMidiChannels = midi_output_ports; | fParams.fReturnMidiChannels = midi_output_ports; | ||||
| strcpy ( fParams.fName, net_name ); | strcpy ( fParams.fName, net_name ); | ||||
| @@ -150,13 +150,13 @@ namespace Jack | |||||
| //set the multicast address | //set the multicast address | ||||
| mcast_addr.sin_family = AF_INET; | mcast_addr.sin_family = AF_INET; | ||||
| mcast_addr.sin_port = htons ( fPort ); | |||||
| mcast_addr.sin_port = htons ( fUDPPort ); | |||||
| inet_aton ( fMulticastIP, &mcast_addr.sin_addr ); | inet_aton ( fMulticastIP, &mcast_addr.sin_addr ); | ||||
| memset ( &mcast_addr.sin_zero, 0, 8 ); | memset ( &mcast_addr.sin_zero, 0, 8 ); | ||||
| //set the listening address | //set the listening address | ||||
| listen_addr.sin_family = AF_INET; | listen_addr.sin_family = AF_INET; | ||||
| listen_addr.sin_port = htons ( fPort ); | |||||
| listen_addr.sin_port = htons ( fUDPPort ); | |||||
| listen_addr.sin_addr.s_addr = htonl ( INADDR_ANY ); | listen_addr.sin_addr.s_addr = htonl ( INADDR_ANY ); | ||||
| memset ( &listen_addr.sin_zero, 0, 8 ); | memset ( &listen_addr.sin_zero, 0, 8 ); | ||||
| @@ -394,9 +394,9 @@ namespace Jack | |||||
| fGraphManager->ReleasePort ( fClientControl->fRefNum, fCapturePortList[port_index] ); | fGraphManager->ReleasePort ( fClientControl->fRefNum, fCapturePortList[port_index] ); | ||||
| for ( int port_index = 0; port_index < fPlaybackChannels; port_index++ ) | for ( int port_index = 0; port_index < fPlaybackChannels; port_index++ ) | ||||
| fGraphManager->ReleasePort ( fClientControl->fRefNum, fPlaybackPortList[port_index] ); | fGraphManager->ReleasePort ( fClientControl->fRefNum, fPlaybackPortList[port_index] ); | ||||
| for ( int port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| for ( uint port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| fGraphManager->ReleasePort ( fClientControl->fRefNum, fMidiCapturePortList[port_index] ); | fGraphManager->ReleasePort ( fClientControl->fRefNum, fMidiCapturePortList[port_index] ); | ||||
| for ( int port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| for ( uint port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| fGraphManager->ReleasePort ( fClientControl->fRefNum, fMidiPlaybackPortList[port_index] ); | fGraphManager->ReleasePort ( fClientControl->fRefNum, fMidiPlaybackPortList[port_index] ); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -456,12 +456,12 @@ namespace Jack | |||||
| int JackNetDriver::Read() | int JackNetDriver::Read() | ||||
| { | { | ||||
| int rx_bytes; | int rx_bytes; | ||||
| size_t recvd_midi_pckt = 0; | |||||
| uint recvd_midi_pckt = 0; | |||||
| packet_header_t* rx_head = reinterpret_cast<packet_header_t*> ( fRxBuffer ); | packet_header_t* rx_head = reinterpret_cast<packet_header_t*> ( fRxBuffer ); | ||||
| fRxHeader.fIsLastPckt = 'n'; | fRxHeader.fIsLastPckt = 'n'; | ||||
| //buffers | //buffers | ||||
| for ( int port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| for ( uint port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| fNetMidiCaptureBuffer->fPortBuffer[port_index] = GetMidiInputBuffer ( port_index ); | fNetMidiCaptureBuffer->fPortBuffer[port_index] = GetMidiInputBuffer ( port_index ); | ||||
| for ( int port_index = 0; port_index < fCaptureChannels; port_index++ ) | for ( int port_index = 0; port_index < fCaptureChannels; port_index++ ) | ||||
| fNetAudioCaptureBuffer->fPortBuffer[port_index] = GetInputBuffer ( port_index ); | fNetAudioCaptureBuffer->fPortBuffer[port_index] = GetInputBuffer ( port_index ); | ||||
| @@ -525,7 +525,7 @@ namespace Jack | |||||
| fTxHeader.fIsLastPckt = 'n'; | fTxHeader.fIsLastPckt = 'n'; | ||||
| //buffers | //buffers | ||||
| for ( int port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| for ( uint port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| fNetMidiPlaybackBuffer->fPortBuffer[port_index] = GetMidiOutputBuffer ( port_index ); | fNetMidiPlaybackBuffer->fPortBuffer[port_index] = GetMidiOutputBuffer ( port_index ); | ||||
| for ( int port_index = 0; port_index < fPlaybackChannels; port_index++ ) | for ( int port_index = 0; port_index < fPlaybackChannels; port_index++ ) | ||||
| fNetAudioPlaybackBuffer->fPortBuffer[port_index] = GetOutputBuffer ( port_index ); | fNetAudioPlaybackBuffer->fPortBuffer[port_index] = GetOutputBuffer ( port_index ); | ||||
| @@ -536,7 +536,7 @@ namespace Jack | |||||
| fTxHeader.fDataType = 'm'; | fTxHeader.fDataType = 'm'; | ||||
| fTxHeader.fMidiDataSize = fNetMidiPlaybackBuffer->RenderFromJackPorts(); | fTxHeader.fMidiDataSize = fNetMidiPlaybackBuffer->RenderFromJackPorts(); | ||||
| fTxHeader.fNMidiPckt = GetNMidiPckt ( &fParams, fTxHeader.fMidiDataSize ); | fTxHeader.fNMidiPckt = GetNMidiPckt ( &fParams, fTxHeader.fMidiDataSize ); | ||||
| for ( size_t subproc = 0; subproc < fTxHeader.fNMidiPckt; subproc++ ) | |||||
| for ( uint subproc = 0; subproc < fTxHeader.fNMidiPckt; subproc++ ) | |||||
| { | { | ||||
| fTxHeader.fSubCycle = subproc; | fTxHeader.fSubCycle = subproc; | ||||
| if ( ( subproc == ( fTxHeader.fNMidiPckt - 1 ) ) && !fParams.fReturnAudioChannels ) | if ( ( subproc == ( fTxHeader.fNMidiPckt - 1 ) ) && !fParams.fReturnAudioChannels ) | ||||
| @@ -551,7 +551,7 @@ namespace Jack | |||||
| if ( fParams.fReturnAudioChannels ) | if ( fParams.fReturnAudioChannels ) | ||||
| { | { | ||||
| fTxHeader.fDataType = 'a'; | fTxHeader.fDataType = 'a'; | ||||
| for ( size_t subproc = 0; subproc < fNSubProcess; subproc++ ) | |||||
| for ( uint subproc = 0; subproc < fNSubProcess; subproc++ ) | |||||
| { | { | ||||
| fTxHeader.fSubCycle = subproc; | fTxHeader.fSubCycle = subproc; | ||||
| if ( subproc == ( fNSubProcess - 1 ) ) | if ( subproc == ( fNSubProcess - 1 ) ) | ||||
| @@ -577,7 +577,7 @@ namespace Jack | |||||
| desc->nparams = 7; | desc->nparams = 7; | ||||
| desc->params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) ); | desc->params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) ); | ||||
| size_t i = 0; | |||||
| int i = 0; | |||||
| strcpy ( desc->params[i].name, "multicast_ip" ); | strcpy ( desc->params[i].name, "multicast_ip" ); | ||||
| desc->params[i].character = 'a'; | desc->params[i].character = 'a'; | ||||
| desc->params[i].type = JackDriverParamString; | desc->params[i].type = JackDriverParamString; | ||||
| @@ -588,8 +588,8 @@ namespace Jack | |||||
| i++; | i++; | ||||
| strcpy ( desc->params[i].name, "udp_net_port" ); | strcpy ( desc->params[i].name, "udp_net_port" ); | ||||
| desc->params[i].character = 'p'; | desc->params[i].character = 'p'; | ||||
| desc->params[i].type = JackDriverParamUInt; | |||||
| desc->params[i].value.ui = 19000U; | |||||
| desc->params[i].type = JackDriverParamInt; | |||||
| desc->params[i].value.i = 19000; | |||||
| strcpy ( desc->params[i].short_desc, "UDP port" ); | strcpy ( desc->params[i].short_desc, "UDP port" ); | ||||
| strcpy ( desc->params[i].long_desc, desc->params[i].short_desc ); | strcpy ( desc->params[i].long_desc, desc->params[i].short_desc ); | ||||
| @@ -604,7 +604,7 @@ namespace Jack | |||||
| i++; | i++; | ||||
| strcpy ( desc->params[i].name, "output_ports" ); | strcpy ( desc->params[i].name, "output_ports" ); | ||||
| desc->params[i].character = 'P'; | desc->params[i].character = 'P'; | ||||
| desc->params[i].type = JackDriverParamUInt; | |||||
| desc->params[i].type = JackDriverParamInt; | |||||
| desc->params[i].value.i = 2; | desc->params[i].value.i = 2; | ||||
| strcpy ( desc->params[i].short_desc, "Number of audio output ports" ); | strcpy ( desc->params[i].short_desc, "Number of audio output ports" ); | ||||
| strcpy ( desc->params[i].long_desc, desc->params[i].short_desc ); | strcpy ( desc->params[i].long_desc, desc->params[i].short_desc ); | ||||
| @@ -641,7 +641,7 @@ namespace Jack | |||||
| const char* multicast_ip = DEFAULT_MULTICAST_IP; | const char* multicast_ip = DEFAULT_MULTICAST_IP; | ||||
| char name[JACK_CLIENT_NAME_SIZE]; | char name[JACK_CLIENT_NAME_SIZE]; | ||||
| gethostname ( name, JACK_CLIENT_NAME_SIZE ); | gethostname ( name, JACK_CLIENT_NAME_SIZE ); | ||||
| jack_nframes_t udp_port = DEFAULT_PORT; | |||||
| int udp_port = DEFAULT_PORT; | |||||
| jack_nframes_t period_size = 128; | jack_nframes_t period_size = 128; | ||||
| jack_nframes_t sample_rate = 48000; | jack_nframes_t sample_rate = 48000; | ||||
| int audio_capture_ports = 2; | int audio_capture_ports = 2; | ||||
| @@ -32,10 +32,10 @@ namespace Jack | |||||
| private: | private: | ||||
| session_params_t fParams; | session_params_t fParams; | ||||
| char* fMulticastIP; | char* fMulticastIP; | ||||
| size_t fPort; | |||||
| int fUDPPort; | |||||
| int fSockfd; | int fSockfd; | ||||
| struct sockaddr_in fMasterAddr; | struct sockaddr_in fMasterAddr; | ||||
| size_t fNSubProcess; | |||||
| uint fNSubProcess; | |||||
| jack_port_id_t* fMidiCapturePortList; | jack_port_id_t* fMidiCapturePortList; | ||||
| jack_port_id_t* fMidiPlaybackPortList; | jack_port_id_t* fMidiPlaybackPortList; | ||||
| @@ -72,7 +72,7 @@ namespace Jack | |||||
| public: | public: | ||||
| JackNetDriver ( const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table, | 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, int port, int midi_input_ports, int midi_output_ports, const char* master_name ); | |||||
| ~JackNetDriver(); | ~JackNetDriver(); | ||||
| int Open ( jack_nframes_t frames_per_cycle, jack_nframes_t rate, bool capturing, bool playing, | int Open ( jack_nframes_t frames_per_cycle, jack_nframes_t rate, bool capturing, bool playing, | ||||
| @@ -48,17 +48,17 @@ namespace Jack | |||||
| //jack audio ports | //jack audio ports | ||||
| fAudioCapturePorts = new jack_port_t* [fParams.fSendAudioChannels]; | fAudioCapturePorts = new jack_port_t* [fParams.fSendAudioChannels]; | ||||
| for ( int port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ ) | |||||
| for ( uint port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ ) | |||||
| fAudioCapturePorts[port_index] = NULL; | fAudioCapturePorts[port_index] = NULL; | ||||
| fAudioPlaybackPorts = new jack_port_t* [fParams.fReturnAudioChannels]; | fAudioPlaybackPorts = new jack_port_t* [fParams.fReturnAudioChannels]; | ||||
| for ( int port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ ) | |||||
| for ( uint port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ ) | |||||
| fAudioPlaybackPorts[port_index] = NULL; | fAudioPlaybackPorts[port_index] = NULL; | ||||
| //jack midi ports | //jack midi ports | ||||
| fMidiCapturePorts = new jack_port_t* [fParams.fSendMidiChannels]; | fMidiCapturePorts = new jack_port_t* [fParams.fSendMidiChannels]; | ||||
| for ( int port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| for ( uint port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| fMidiCapturePorts[port_index] = NULL; | fMidiCapturePorts[port_index] = NULL; | ||||
| fMidiPlaybackPorts = new jack_port_t* [fParams.fReturnMidiChannels]; | fMidiPlaybackPorts = new jack_port_t* [fParams.fReturnMidiChannels]; | ||||
| for ( int port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| for ( uint port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| fMidiPlaybackPorts[port_index] = NULL; | fMidiPlaybackPorts[port_index] = NULL; | ||||
| //TX header init | //TX header init | ||||
| @@ -190,7 +190,7 @@ namespace Jack | |||||
| jack_set_process_callback ( fJackClient, SetProcess, this ); | jack_set_process_callback ( fJackClient, SetProcess, this ); | ||||
| //port registering | //port registering | ||||
| int i; | |||||
| uint i; | |||||
| char name[24]; | char name[24]; | ||||
| //audio | //audio | ||||
| for ( i = 0; i < fParams.fSendAudioChannels; i++ ) | for ( i = 0; i < fParams.fSendAudioChannels; i++ ) | ||||
| @@ -242,16 +242,17 @@ namespace Jack | |||||
| void JackNetMaster::FreePorts() | void JackNetMaster::FreePorts() | ||||
| { | { | ||||
| jack_log ( "JackNetMaster::FreePorts, ID %u", fParams.fID ); | jack_log ( "JackNetMaster::FreePorts, ID %u", fParams.fID ); | ||||
| for ( int port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ ) | |||||
| uint port_index; | |||||
| for ( port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ ) | |||||
| if ( fAudioCapturePorts[port_index] ) | if ( fAudioCapturePorts[port_index] ) | ||||
| jack_port_unregister ( fJackClient, fAudioCapturePorts[port_index] ); | jack_port_unregister ( fJackClient, fAudioCapturePorts[port_index] ); | ||||
| for ( int port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ ) | |||||
| for ( port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ ) | |||||
| if ( fAudioPlaybackPorts[port_index] ) | if ( fAudioPlaybackPorts[port_index] ) | ||||
| jack_port_unregister ( fJackClient, fAudioPlaybackPorts[port_index] ); | jack_port_unregister ( fJackClient, fAudioPlaybackPorts[port_index] ); | ||||
| for ( int port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| for ( port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| if ( fMidiCapturePorts[port_index] ) | if ( fMidiCapturePorts[port_index] ) | ||||
| jack_port_unregister ( fJackClient, fMidiCapturePorts[port_index] ); | jack_port_unregister ( fJackClient, fMidiCapturePorts[port_index] ); | ||||
| for ( int port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| for ( port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| if ( fMidiPlaybackPorts[port_index] ) | if ( fMidiPlaybackPorts[port_index] ) | ||||
| jack_port_unregister ( fJackClient, fMidiPlaybackPorts[port_index] ); | jack_port_unregister ( fJackClient, fMidiPlaybackPorts[port_index] ); | ||||
| } | } | ||||
| @@ -340,16 +341,17 @@ namespace Jack | |||||
| packet_header_t* rx_head = reinterpret_cast<packet_header_t*> ( fRxBuffer ); | packet_header_t* rx_head = reinterpret_cast<packet_header_t*> ( fRxBuffer ); | ||||
| //buffers | //buffers | ||||
| for ( int port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| uint port_index; | |||||
| for ( port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ ) | |||||
| fNetMidiCaptureBuffer->fPortBuffer[port_index] = | fNetMidiCaptureBuffer->fPortBuffer[port_index] = | ||||
| static_cast<JackMidiBuffer*> ( jack_port_get_buffer ( fMidiCapturePorts[port_index], fParams.fPeriodSize ) ); | static_cast<JackMidiBuffer*> ( jack_port_get_buffer ( fMidiCapturePorts[port_index], fParams.fPeriodSize ) ); | ||||
| for ( int port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ ) | |||||
| for ( port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ ) | |||||
| fNetAudioCaptureBuffer->fPortBuffer[port_index] = | fNetAudioCaptureBuffer->fPortBuffer[port_index] = | ||||
| static_cast<sample_t*> ( jack_port_get_buffer ( fAudioCapturePorts[port_index], fParams.fPeriodSize ) ); | static_cast<sample_t*> ( jack_port_get_buffer ( fAudioCapturePorts[port_index], fParams.fPeriodSize ) ); | ||||
| for ( int port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| for ( port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ ) | |||||
| fNetMidiPlaybackBuffer->fPortBuffer[port_index] = | fNetMidiPlaybackBuffer->fPortBuffer[port_index] = | ||||
| static_cast<JackMidiBuffer*> ( jack_port_get_buffer ( fMidiPlaybackPorts[port_index], fParams.fPeriodSize ) ); | static_cast<JackMidiBuffer*> ( jack_port_get_buffer ( fMidiPlaybackPorts[port_index], fParams.fPeriodSize ) ); | ||||
| for ( int port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ ) | |||||
| for ( port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ ) | |||||
| fNetAudioPlaybackBuffer->fPortBuffer[port_index] = | fNetAudioPlaybackBuffer->fPortBuffer[port_index] = | ||||
| static_cast<sample_t*> ( jack_port_get_buffer ( fAudioPlaybackPorts[port_index], fParams.fPeriodSize ) ); | static_cast<sample_t*> ( jack_port_get_buffer ( fAudioPlaybackPorts[port_index], fParams.fPeriodSize ) ); | ||||
| @@ -368,7 +370,7 @@ namespace Jack | |||||
| fTxHeader.fDataType = 'm'; | fTxHeader.fDataType = 'm'; | ||||
| fTxHeader.fMidiDataSize = fNetMidiCaptureBuffer->RenderFromJackPorts(); | fTxHeader.fMidiDataSize = fNetMidiCaptureBuffer->RenderFromJackPorts(); | ||||
| fTxHeader.fNMidiPckt = GetNMidiPckt ( &fParams, fTxHeader.fMidiDataSize ); | fTxHeader.fNMidiPckt = GetNMidiPckt ( &fParams, fTxHeader.fMidiDataSize ); | ||||
| for ( size_t subproc = 0; subproc < fTxHeader.fNMidiPckt; subproc++ ) | |||||
| for ( uint subproc = 0; subproc < fTxHeader.fNMidiPckt; subproc++ ) | |||||
| { | { | ||||
| fTxHeader.fSubCycle = subproc; | fTxHeader.fSubCycle = subproc; | ||||
| if ( ( subproc == ( fTxHeader.fNMidiPckt - 1 ) ) && !fParams.fSendAudioChannels ) | if ( ( subproc == ( fTxHeader.fNMidiPckt - 1 ) ) && !fParams.fSendAudioChannels ) | ||||
| @@ -385,7 +387,7 @@ namespace Jack | |||||
| if ( fParams.fSendAudioChannels ) | if ( fParams.fSendAudioChannels ) | ||||
| { | { | ||||
| fTxHeader.fDataType = 'a'; | fTxHeader.fDataType = 'a'; | ||||
| for ( size_t subproc = 0; subproc < fNSubProcess; subproc++ ) | |||||
| for ( uint subproc = 0; subproc < fNSubProcess; subproc++ ) | |||||
| { | { | ||||
| fTxHeader.fSubCycle = subproc; | fTxHeader.fSubCycle = subproc; | ||||
| if ( subproc == ( fNSubProcess - 1 ) ) | if ( subproc == ( fNSubProcess - 1 ) ) | ||||
| @@ -444,7 +446,7 @@ namespace Jack | |||||
| fManagerClient = client; | fManagerClient = client; | ||||
| fManagerName = jack_get_client_name ( fManagerClient ); | fManagerName = jack_get_client_name ( fManagerClient ); | ||||
| fMCastIP = DEFAULT_MULTICAST_IP; | fMCastIP = DEFAULT_MULTICAST_IP; | ||||
| fPort = DEFAULT_PORT; | |||||
| fUDPPort = DEFAULT_PORT; | |||||
| fGlobalID = 0; | fGlobalID = 0; | ||||
| fRunning = true; | fRunning = true; | ||||
| @@ -479,7 +481,7 @@ namespace Jack | |||||
| struct timeval timeout; | struct timeval timeout; | ||||
| timeout.tv_sec = 2; | timeout.tv_sec = 2; | ||||
| timeout.tv_usec = 0; | timeout.tv_usec = 0; | ||||
| size_t attempt = 0; | |||||
| int attempt = 0; | |||||
| //network | //network | ||||
| int mcast_sockfd; | int mcast_sockfd; | ||||
| @@ -501,7 +503,7 @@ namespace Jack | |||||
| //set the multicast address | //set the multicast address | ||||
| mcast_addr.sin_family = AF_INET; | mcast_addr.sin_family = AF_INET; | ||||
| mcast_addr.sin_port = htons ( fPort ); | |||||
| mcast_addr.sin_port = htons ( fUDPPort ); | |||||
| if ( inet_aton ( fMCastIP, &mcast_addr.sin_addr ) < 0 ) | if ( inet_aton ( fMCastIP, &mcast_addr.sin_addr ) < 0 ) | ||||
| { | { | ||||
| jack_error ( "Cant set multicast address : %s", strerror ( errno ) ); | jack_error ( "Cant set multicast address : %s", strerror ( errno ) ); | ||||
| @@ -617,7 +619,7 @@ namespace Jack | |||||
| sprintf ( params.fName, "%s-%u", params.fName, params.fID ); | sprintf ( params.fName, "%s-%u", params.fName, params.fID ); | ||||
| } | } | ||||
| master_list_it_t JackNetMasterManager::FindMaster ( size_t id ) | |||||
| master_list_it_t JackNetMasterManager::FindMaster ( uint32_t id ) | |||||
| { | { | ||||
| jack_log ( "JackNetMasterManager::FindMaster, ID %u.", id ); | jack_log ( "JackNetMasterManager::FindMaster, ID %u.", id ); | ||||
| master_list_it_t it; | master_list_it_t it; | ||||
| @@ -41,8 +41,8 @@ namespace Jack | |||||
| struct sockaddr_in fAddr; | struct sockaddr_in fAddr; | ||||
| struct sockaddr_in fMcastAddr; | struct sockaddr_in fMcastAddr; | ||||
| int fSockfd; | int fSockfd; | ||||
| size_t fNSubProcess; | |||||
| size_t fNetJumpCnt; | |||||
| uint fNSubProcess; | |||||
| int fNetJumpCnt; | |||||
| bool fRunning; | bool fRunning; | ||||
| jack_client_t* fJackClient; | jack_client_t* fJackClient; | ||||
| @@ -93,15 +93,15 @@ namespace Jack | |||||
| jack_client_t* fManagerClient; | jack_client_t* fManagerClient; | ||||
| const char* fManagerName; | const char* fManagerName; | ||||
| const char* fMCastIP; | const char* fMCastIP; | ||||
| int fUDPPort; | |||||
| pthread_t fManagerThread; | pthread_t fManagerThread; | ||||
| master_list_t fMasterList; | master_list_t fMasterList; | ||||
| size_t fGlobalID; | |||||
| uint32_t fGlobalID; | |||||
| bool fRunning; | bool fRunning; | ||||
| size_t fPort; | |||||
| void Run(); | void Run(); | ||||
| JackNetMaster* MasterInit ( session_params_t& params, struct sockaddr_in& address, struct sockaddr_in& mcast_addr ); | 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 ( uint32_t client_id ); | |||||
| void KillMaster ( session_params_t* params ); | void KillMaster ( session_params_t* params ); | ||||
| void SetSlaveName ( session_params_t& params ); | void SetSlaveName ( session_params_t& params ); | ||||
| int Process(); | int Process(); | ||||
| @@ -35,7 +35,7 @@ namespace Jack | |||||
| { | { | ||||
| for ( int port_index = 0; port_index < fNPorts; port_index++ ) | for ( int port_index = 0; port_index < fNPorts; port_index++ ) | ||||
| { | { | ||||
| for ( size_t event = 0; event < fPortBuffer[port_index]->event_count; event++ ) | |||||
| for ( uint event = 0; event < fPortBuffer[port_index]->event_count; event++ ) | |||||
| if ( fPortBuffer[port_index]->IsValid() ) | if ( fPortBuffer[port_index]->IsValid() ) | ||||
| jack_info ( "port %d : midi event %u/%u -> time : %u, size : %u", | jack_info ( "port %d : midi event %u/%u -> time : %u, size : %u", | ||||
| port_index + 1, event + 1, fPortBuffer[port_index]->event_count, | port_index + 1, event + 1, fPortBuffer[port_index]->event_count, | ||||
| @@ -46,7 +46,7 @@ namespace Jack | |||||
| int NetMidiBuffer::RenderFromJackPorts() | int NetMidiBuffer::RenderFromJackPorts() | ||||
| { | { | ||||
| int pos = 0; | int pos = 0; | ||||
| int copy_size; | |||||
| size_t copy_size; | |||||
| for ( int port_index = 0; port_index < fNPorts; port_index++ ) | for ( int port_index = 0; port_index < fNPorts; port_index++ ) | ||||
| { | { | ||||
| copy_size = sizeof ( JackMidiBuffer ) + fPortBuffer[port_index]->event_count * sizeof ( JackMidiEvent ); | copy_size = sizeof ( JackMidiBuffer ) + fPortBuffer[port_index]->event_count * sizeof ( JackMidiEvent ); | ||||
| @@ -75,13 +75,13 @@ namespace Jack | |||||
| return pos; | return pos; | ||||
| } | } | ||||
| int NetMidiBuffer::RenderFromNetwork ( size_t subcycle, size_t copy_size ) | |||||
| int NetMidiBuffer::RenderFromNetwork ( int subcycle, size_t copy_size ) | |||||
| { | { | ||||
| memcpy ( fBuffer + subcycle * fMaxPcktSize, fNetBuffer, copy_size ); | memcpy ( fBuffer + subcycle * fMaxPcktSize, fNetBuffer, copy_size ); | ||||
| return copy_size; | return copy_size; | ||||
| } | } | ||||
| int NetMidiBuffer::RenderToNetwork ( size_t subcycle, size_t total_size ) | |||||
| int NetMidiBuffer::RenderToNetwork ( int subcycle, size_t total_size ) | |||||
| { | { | ||||
| int size = total_size - subcycle * fMaxPcktSize; | int size = total_size - subcycle * fMaxPcktSize; | ||||
| int copy_size = ( size <= fMaxPcktSize ) ? size : fMaxPcktSize; | int copy_size = ( size <= fMaxPcktSize ) ? size : fMaxPcktSize; | ||||
| @@ -113,13 +113,13 @@ namespace Jack | |||||
| return fNPorts * fSubPeriodBytesSize; | return fNPorts * fSubPeriodBytesSize; | ||||
| } | } | ||||
| void NetAudioBuffer::RenderFromJackPorts ( size_t subcycle ) | |||||
| void NetAudioBuffer::RenderFromJackPorts ( int subcycle ) | |||||
| { | { | ||||
| for ( int port_index = 0; port_index < fNPorts; port_index++ ) | for ( int port_index = 0; port_index < fNPorts; port_index++ ) | ||||
| memcpy ( fNetBuffer + port_index * fSubPeriodBytesSize, fPortBuffer[port_index] + subcycle * fSubPeriodSize, fSubPeriodBytesSize ); | memcpy ( fNetBuffer + port_index * fSubPeriodBytesSize, fPortBuffer[port_index] + subcycle * fSubPeriodSize, fSubPeriodBytesSize ); | ||||
| } | } | ||||
| void NetAudioBuffer::RenderToJackPorts ( size_t subcycle ) | |||||
| void NetAudioBuffer::RenderToJackPorts ( int subcycle ) | |||||
| { | { | ||||
| for ( int port_index = 0; port_index < fNPorts; port_index++ ) | for ( int port_index = 0; port_index < fNPorts; port_index++ ) | ||||
| memcpy ( fPortBuffer[port_index] + subcycle * fSubPeriodSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize ); | memcpy ( fPortBuffer[port_index] + subcycle * fSubPeriodSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize ); | ||||
| @@ -257,7 +257,7 @@ namespace Jack | |||||
| // Utility ******************************************************************************************************* | // Utility ******************************************************************************************************* | ||||
| EXPORT size_t SetFramesPerPacket ( session_params_t* params ) | |||||
| EXPORT jack_nframes_t SetFramesPerPacket ( session_params_t* params ) | |||||
| { | { | ||||
| if ( !params->fSendAudioChannels && !params->fReturnAudioChannels ) | if ( !params->fSendAudioChannels && !params->fReturnAudioChannels ) | ||||
| return ( params->fFramesPerPacket = params->fPeriodSize ); | return ( params->fFramesPerPacket = params->fPeriodSize ); | ||||
| @@ -267,14 +267,14 @@ namespace Jack | |||||
| return params->fFramesPerPacket; | return params->fFramesPerPacket; | ||||
| } | } | ||||
| EXPORT size_t GetNMidiPckt ( session_params_t* params, size_t data_size ) | |||||
| EXPORT int GetNMidiPckt ( session_params_t* params, size_t data_size ) | |||||
| { | { | ||||
| //even if there is no midi data, jack need an empty buffer to know there is no event to read | //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 | //99% of the cases : all data in one packet | ||||
| if ( data_size <= ( params->fMtu - sizeof ( packet_header_t ) ) ) | if ( data_size <= ( params->fMtu - sizeof ( packet_header_t ) ) ) | ||||
| return 1; | return 1; | ||||
| //else, get the number of needed packets (simply slice the biiig buffer) | //else, get the number of needed packets (simply slice the biiig buffer) | ||||
| size_t npckt = data_size / ( params->fMtu - sizeof ( packet_header_t ) ); | |||||
| int npckt = data_size / ( params->fMtu - sizeof ( packet_header_t ) ); | |||||
| if ( data_size % ( params->fMtu - sizeof ( packet_header_t ) ) ) | if ( data_size % ( params->fMtu - sizeof ( packet_header_t ) ) ) | ||||
| return ++npckt; | return ++npckt; | ||||
| return npckt; | return npckt; | ||||
| @@ -295,7 +295,7 @@ namespace Jack | |||||
| // Packet ******************************************************************************************************* | // 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, uint subcycles ) | |||||
| { | { | ||||
| //ignore first cycle | //ignore first cycle | ||||
| if ( previous->fCycle <= 1 ) | if ( previous->fCycle <= 1 ) | ||||
| @@ -34,15 +34,15 @@ namespace Jack | |||||
| { | { | ||||
| char fPacketType[7]; //packet type ('param') | char fPacketType[7]; //packet type ('param') | ||||
| char fProtocolVersion; //version | char fProtocolVersion; //version | ||||
| int32_t fPacketID; //indicates the packet type | |||||
| uint32_t fPacketID; //indicates the packet type | |||||
| char fMasterNetName[256]; //master hostname (network) | char fMasterNetName[256]; //master hostname (network) | ||||
| char fSlaveNetName[256]; //slave hostname (network) | char fSlaveNetName[256]; //slave hostname (network) | ||||
| uint32_t fMtu; //connection mtu | uint32_t fMtu; //connection mtu | ||||
| uint32_t fID; //slave's ID | uint32_t fID; //slave's ID | ||||
| int32_t fSendAudioChannels; //number of master->slave channels | |||||
| int32_t fReturnAudioChannels; //number of slave->master channels | |||||
| int32_t fSendMidiChannels; //number of master->slave midi channels | |||||
| int32_t fReturnMidiChannels; //number of slave->master midi channels | |||||
| uint32_t fSendAudioChannels; //number of master->slave channels | |||||
| uint32_t fReturnAudioChannels; //number of slave->master channels | |||||
| uint32_t fSendMidiChannels; //number of master->slave midi channels | |||||
| uint32_t fReturnMidiChannels; //number of slave->master midi channels | |||||
| uint32_t fSampleRate; //session sample rate | uint32_t fSampleRate; //session sample rate | ||||
| uint32_t fPeriodSize; //period size | uint32_t fPeriodSize; //period size | ||||
| uint32_t fFramesPerPacket; //complete frames per packet | uint32_t fFramesPerPacket; //complete frames per packet | ||||
| @@ -124,8 +124,8 @@ namespace Jack | |||||
| int RenderFromJackPorts(); | int RenderFromJackPorts(); | ||||
| int RenderToJackPorts(); | int RenderToJackPorts(); | ||||
| //network<->buffer | //network<->buffer | ||||
| int RenderFromNetwork ( size_t subcycle, size_t copy_size ); | |||||
| int RenderToNetwork ( size_t subcycle, size_t copy_size ); | |||||
| int RenderFromNetwork ( int subcycle, size_t copy_size ); | |||||
| int RenderToNetwork ( int subcycle, size_t total_size ); | |||||
| }; | }; | ||||
| // audio data ********************************************************************************* | // audio data ********************************************************************************* | ||||
| @@ -146,8 +146,8 @@ namespace Jack | |||||
| size_t GetSize(); | size_t GetSize(); | ||||
| //jack<->buffer | //jack<->buffer | ||||
| void RenderFromJackPorts ( size_t subcycle ); | |||||
| void RenderToJackPorts ( size_t subcycle ); | |||||
| void RenderFromJackPorts ( int subcycle ); | |||||
| void RenderToJackPorts ( int subcycle ); | |||||
| }; | }; | ||||
| //utility ************************************************************************************* | //utility ************************************************************************************* | ||||
| @@ -166,11 +166,11 @@ namespace Jack | |||||
| //set the packet type in a session parameters | //set the packet type in a session parameters | ||||
| EXPORT int SetPacketType ( session_params_t* params, sync_packet_type_t packet_type ); | EXPORT int SetPacketType ( session_params_t* params, sync_packet_type_t packet_type ); | ||||
| //step of network initialization | //step of network initialization | ||||
| EXPORT size_t SetFramesPerPacket ( session_params_t* params ); | |||||
| EXPORT jack_nframes_t SetFramesPerPacket ( session_params_t* params ); | |||||
| //get the midi packet number for a given cycle | //get the midi packet number for a given cycle | ||||
| EXPORT size_t GetNMidiPckt ( session_params_t* params, size_t data_size ); | |||||
| EXPORT int GetNMidiPckt ( session_params_t* params, size_t data_size ); | |||||
| //set the recv timeout on a socket | //set the recv timeout on a socket | ||||
| EXPORT int SetRxTimeout ( int* sockfd, session_params_t* params ); | EXPORT int SetRxTimeout ( int* sockfd, session_params_t* params ); | ||||
| //check if 'next' packet is really the next after 'previous' | //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, int subcycles ); | |||||
| } | } | ||||