Commit 7099ca56 authored by sletz's avatar sletz
Browse files

Cleanup.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4513 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 9126d936
......@@ -127,7 +127,6 @@ extern "C"
unsigned long buffer_size);
LIB_EXPORT int jack_port_unregister(jack_client_t *, jack_port_t *);
LIB_EXPORT void * jack_port_get_buffer(jack_port_t *, jack_nframes_t);
LIB_EXPORT void * jack_port_get_buffer_nulled(jack_port_t *, jack_nframes_t);
LIB_EXPORT const char* jack_port_name(const jack_port_t *port);
LIB_EXPORT const char* jack_port_short_name(const jack_port_t *port);
LIB_EXPORT int jack_port_flags(const jack_port_t *port);
......@@ -350,22 +349,6 @@ LIB_EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
}
}
LIB_EXPORT void* jack_port_get_buffer_nulled(jack_port_t* port, jack_nframes_t frames)
{
#ifdef __CLIENTDEBUG__
JackGlobals::CheckContext("jack_port_get_buffer_nulled");
#endif
uintptr_t port_aux = (uintptr_t)port;
jack_port_id_t myport = (jack_port_id_t)port_aux;
if (!CheckPort(myport)) {
jack_error("jack_port_get_buffer_nulled called with an incorrect port %ld", myport);
return NULL;
} else {
JackGraphManager* manager = GetGraphManager();
return (manager ? manager->GetBuffer(myport, frames, true) : NULL);
}
}
LIB_EXPORT const char* jack_port_name(const jack_port_t* port)
{
#ifdef __CLIENTDEBUG__
......
......@@ -42,9 +42,12 @@ namespace Jack
// Always clear output
for (int i = 0; i < adapter->fAudioAdapter->GetInputs(); i++) {
#ifdef OPTIMIZED_PROTOCOL
inputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer_nulled(adapter->fCapturePortList[i], frames);
if (inputBuffer[i])
inputBuffer[i] = (jack_port_connected(adapter->fCapturePortList[i]) > 0)
? (jack_default_audio_sample_t*)(adapter->fCapturePortList[i], frames)
: NULL;
if (inputBuffer[i]) {
memset(inputBuffer[i], 0, frames * sizeof(jack_default_audio_sample_t));
}
#else
inputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer(adapter->fCapturePortList[i], frames);
memset(inputBuffer[i], 0, frames * sizeof(jack_default_audio_sample_t));
......@@ -53,7 +56,9 @@ namespace Jack
for (int i = 0; i < adapter->fAudioAdapter->GetOutputs(); i++) {
#ifdef OPTIMIZED_PROTOCOL
outputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer_nulled(adapter->fPlaybackPortList[i], frames);
outputBuffer[i] = (jack_port_connected(fAudioCapturePorts[audio_port_index] > 0)
? (jack_default_audio_sample_t*)jack_port_get_buffer(adapter->fPlaybackPortList[i], frames)
: NULL;
#else
outputBuffer[i] = (jack_default_audio_sample_t*)jack_port_get_buffer(adapter->fPlaybackPortList[i], frames);
#endif
......
......@@ -41,6 +41,7 @@ namespace Jack
GetHostName(fParams.fName, JACK_CLIENT_NAME_SIZE);
fSocket.GetName(fParams.fSlaveNetName);
fParams.fMtu = DEFAULT_MTU;
// Desactivated for now...
fParams.fTransportSync = 0;
int send_audio = -1;
int return_audio = -1;
......
......@@ -640,7 +640,8 @@ namespace Jack
char net_name[JACK_CLIENT_NAME_SIZE + 1];
int udp_port;
int mtu = DEFAULT_MTU;
uint transport_sync = 1;
// Desactivated for now...
uint transport_sync = 0;
jack_nframes_t period_size = 128;
jack_nframes_t sample_rate = 48000;
int audio_capture_ports = -1;
......
......@@ -487,10 +487,12 @@ namespace Jack
fTxHeader.fIsLastPckt = (fParams.fSendMidiChannels == 0 && fParams.fSendAudioChannels == 0) ? 1 : 0;
fTxHeader.fPacketSize = fParams.fMtu;
/*
// Write active ports list
if (fNetAudioPlaybackBuffer) {
fNetAudioPlaybackBuffer->ActivePortsToNetwork(fTxData, fTxHeader.fActivePorts);
}
*/
memcpy(fTxBuffer, &fTxHeader, HEADER_SIZE);
// PacketHeaderDisplay(&fTxHeader);
......@@ -507,7 +509,10 @@ namespace Jack
int JackNetMasterInterface::SyncRecv()
{
int rx_bytes = 0;
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);
/*
int rx_bytes = Recv(fParams.fMtu, MSG_PEEK);
if ((rx_bytes == 0) || (rx_bytes == SOCKET_ERROR)) {
......@@ -515,12 +520,27 @@ namespace Jack
return SOCKET_ERROR;
}
fCycleOffset = fTxHeader.fCycle - rx_head->fCycle;
*/
// receive sync (launch the cycle)
do {
rx_bytes = Recv(fParams.fMtu, MSG_PEEK);
// connection issue, send will detect it, so don't skip the cycle (return 0)
if (rx_bytes == SOCKET_ERROR) {
return SOCKET_ERROR;
}
}
while ((strcmp(rx_head->fPacketType, "header") != 0) && (rx_head->fDataType != 's'));
fCycleOffset = fTxHeader.fCycle - rx_head->fCycle;
/*
// Read active ports list
if (fNetAudioCaptureBuffer) {
fNetAudioCaptureBuffer->ActivePortsFromNetwork(fRxData, rx_head->fActivePorts);
}
*/
if (fCycleOffset < fMaxCycleOffset) {
jack_info("Synching with latency = %d", fCycleOffset);
......@@ -577,14 +597,22 @@ namespace Jack
// then, first step : transport
if (fParams.fTransportSync) {
// desactivated...
// EncodeTransportData();
EncodeTransportData();
TransportDataHToN(&fSendTransportData, &fSendTransportData);
// copy to TxBuffer
memcpy(fTxData, &fSendTransportData, sizeof(net_transport_data_t));
}
// then others (freewheel etc.)
// ...
// Transport not used for now...
// Write active ports list
if (fNetAudioPlaybackBuffer) {
fNetAudioPlaybackBuffer->ActivePortsToNetwork(fTxData, fTxHeader.fActivePorts);
} else {
fTxHeader.fActivePorts = 0;
}
}
void JackNetMasterInterface::DecodeSyncPacket()
......@@ -595,11 +623,19 @@ namespace Jack
// copy received transport data to transport data structure
memcpy(&fReturnTransportData, fRxData, sizeof(net_transport_data_t));
TransportDataNToH(&fReturnTransportData, &fReturnTransportData);
// desactivated...
// DecodeTransportData();
DecodeTransportData();
}
// then others
// ...
// Transport not used for now...
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);
// Read active ports list
if (fNetAudioCaptureBuffer) {
fNetAudioCaptureBuffer->ActivePortsFromNetwork(fRxData, rx_head->fActivePorts);
}
}
// JackNetSlaveInterface ************************************************************************************************
......@@ -917,10 +953,12 @@ namespace Jack
}
while ((strcmp(rx_head->fPacketType, "header") != 0) && (rx_head->fDataType != 's'));
/*
// Read active ports list
if (fNetAudioPlaybackBuffer) {
fNetAudioPlaybackBuffer->ActivePortsFromNetwork(fRxData, rx_head->fActivePorts);
}
*/
fRxHeader.fIsLastPckt = rx_head->fIsLastPckt;
return rx_bytes;
......@@ -977,10 +1015,12 @@ namespace Jack
fTxHeader.fIsLastPckt = (fParams.fReturnMidiChannels == 0 && fParams.fReturnAudioChannels == 0) ? 1 : 0;
fTxHeader.fPacketSize = fParams.fMtu;
/*
// Write active ports list
if (fNetAudioCaptureBuffer) {
fNetAudioCaptureBuffer->ActivePortsToNetwork(fTxData, fTxHeader.fActivePorts);
}
*/
memcpy(fTxBuffer, &fTxHeader, HEADER_SIZE);
// PacketHeaderDisplay(&fTxHeader);
......@@ -1001,16 +1041,25 @@ namespace Jack
// This method contains every step of sync packet informations coding
// first of all, reset sync packet
memset(fTxData, 0, PACKET_AVAILABLE_SIZE(&fParams));
// then first step : transport
if (fParams.fTransportSync) {
// desactivated...
// EncodeTransportData();
EncodeTransportData();
TransportDataHToN(&fReturnTransportData, &fReturnTransportData);
// copy to TxBuffer
memcpy(fTxData, &fReturnTransportData, sizeof(net_transport_data_t));
}
// then others
// ...
// Transport is not used for now...
// Write active ports list
if (fNetAudioCaptureBuffer) {
fNetAudioCaptureBuffer->ActivePortsToNetwork(fTxData, fTxHeader.fActivePorts);
} else {
fTxHeader.fActivePorts = 0;
}
}
void JackNetSlaveInterface::DecodeSyncPacket()
......@@ -1021,11 +1070,20 @@ namespace Jack
// copy received transport data to transport data structure
memcpy(&fSendTransportData, fRxData, sizeof(net_transport_data_t));
TransportDataNToH(&fSendTransportData, &fSendTransportData);
// desactivated...
// DecodeTransportData();
DecodeTransportData();
}
// then others
// ...
// Transport not used for now...
packet_header_t* rx_head = reinterpret_cast<packet_header_t*>(fRxBuffer);
// Read active ports list
if (fNetAudioPlaybackBuffer) {
fNetAudioPlaybackBuffer->ActivePortsFromNetwork(fRxData, rx_head->fActivePorts);
}
}
}
......@@ -26,15 +26,16 @@ namespace Jack
{
#define DEFAULT_MULTICAST_IP "225.3.19.154"
#define DEFAULT_PORT 19000
#define DEFAULT_MTU 1500
#define DEFAULT_PORT 19000
#define DEFAULT_MTU 1500
#define SLAVE_SETUP_RETRY 5
#define SLAVE_SETUP_RETRY 5
#define MASTER_INIT_TIMEOUT 1000000 // in usec
#define SLAVE_INIT_TIMEOUT 1000000 // in usec
#define MANAGER_INIT_TIMEOUT 2000000 // in usec
#define MASTER_INIT_TIMEOUT 1000000 // in usec
#define SLAVE_INIT_TIMEOUT 1000000 // in usec
#define NETWORK_MAX_LATENCY 20
#define NETWORK_MAX_LATENCY 20
/**
\Brief This class describes the basic Net Interface, used by both master and slave
......
This diff is collapsed.
......@@ -72,13 +72,13 @@ namespace Jack
void DecodeTransportData();
int Process();
void TimebaseCallback ( jack_position_t* pos );
void TimebaseCallback(jack_position_t* pos);
void ConnectPorts();
public:
JackNetMaster ( JackNetSocket& socket, session_params_t& params, const char* multicast_ip);
~JackNetMaster ();
JackNetMaster(JackNetSocket& socket, session_params_t& params, const char* multicast_ip);
~JackNetMaster();
bool IsSlaveReadyToRoll();
};
......@@ -96,8 +96,8 @@ namespace Jack
private:
static int SetSyncCallback ( jack_transport_state_t state, jack_position_t* pos, void* arg );
static void* NetManagerThread ( void* arg );
static int SetSyncCallback(jack_transport_state_t state, jack_position_t* pos, void* arg);
static void* NetManagerThread(void* arg);
jack_client_t* fManagerClient;
const char* fManagerName;
......@@ -110,18 +110,18 @@ namespace Jack
bool fAutoConnect;
void Run();
JackNetMaster* InitMaster ( session_params_t& params );
master_list_it_t FindMaster ( uint32_t client_id );
int KillMaster ( session_params_t* params );
void SetSlaveName ( session_params_t& params );
JackNetMaster* InitMaster(session_params_t& params);
master_list_it_t FindMaster(uint32_t client_id);
int KillMaster(session_params_t* params);
void SetSlaveName(session_params_t& params);
int SyncCallback ( jack_transport_state_t state, jack_position_t* pos );
int SyncCallback(jack_transport_state_t state, jack_position_t* pos);
int CountIO(int flags);
public:
JackNetMasterManager ( jack_client_t* jack_client, const JSList* params);
JackNetMasterManager(jack_client_t* jack_client, const JSList* params);
~JackNetMasterManager();
};
}
......
......@@ -390,8 +390,9 @@ namespace Jack
void Copy(sample_t** buffers)
{
for (int port_index = 0; port_index < fNPorts; port_index++)
for (int port_index = 0; port_index < fNPorts; port_index++) {
memcpy(buffers[port_index], fPortBuffer[port_index], fPeriodSize * sizeof(float));
}
}
// needed syze in bytes for an entire cycle
......
......@@ -735,7 +735,6 @@ int jack_port_unregister (jack_client_t *, jack_port_t *) JACK_OPTIONAL_WEAK_EXP
* Port buffers have to be retrieved in each callback for proper functionning.
*/
void * jack_port_get_buffer (jack_port_t *, jack_nframes_t) JACK_OPTIONAL_WEAK_EXPORT;
void * jack_port_get_buffer_nulled(jack_port_t* port, jack_nframes_t frames) JACK_OPTIONAL_WEAK_EXPORT;
/**
* @return the full name of the jack_port_t (including the @a
......
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