From baacb28baa5f4532b29e326e14e3f5b52aa3f07b Mon Sep 17 00:00:00 2001 From: sletz Date: Mon, 30 Jan 2012 21:41:39 +0000 Subject: [PATCH] Cleanup. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4756 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackNetAPI.cpp | 20 +++++++++++++------- common/JackNetInterface.cpp | 9 ++++++--- macosx/Jackdmp.xcodeproj/project.pbxproj | 6 ------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/common/JackNetAPI.cpp b/common/JackNetAPI.cpp index 730b2186..2def7a78 100644 --- a/common/JackNetAPI.cpp +++ b/common/JackNetAPI.cpp @@ -496,11 +496,13 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf int Open(jack_master_t* result) { + // Check CELT encoder parameters if ((fParams.fSampleEncoder == JackCeltEncoder) && (fParams.fKBps == 0)) { jack_error("CELT encoder with 0 for kps..."); return -1; } + // Check latency if (fParams.fNetworkLatency > NETWORK_MAX_LATENCY) { jack_error("Error : network latency is limited to %d", NETWORK_MAX_LATENCY); return -1; @@ -552,7 +554,7 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf return -1; } - // Finish connection... + // Finish connection if (!JackNetSlaveInterface::InitRendering()) { jack_error("Starting network fails..."); return -1; @@ -615,29 +617,33 @@ struct JackNetExtSlave : public JackNetSlaveInterface, public JackRunnableInterf void FreePorts() { if (fAudioCaptureBuffer) { - for (int audio_port_index = 0; audio_port_index < fParams.fSendAudioChannels; audio_port_index++) + for (int audio_port_index = 0; audio_port_index < fParams.fSendAudioChannels; audio_port_index++) { delete[] fAudioCaptureBuffer[audio_port_index]; + } delete[] fAudioCaptureBuffer; fAudioCaptureBuffer = NULL; } if (fMidiCaptureBuffer) { - for (int midi_port_index = 0; midi_port_index < fParams.fSendMidiChannels; midi_port_index++) + for (int midi_port_index = 0; midi_port_index < fParams.fSendMidiChannels; midi_port_index++) { delete[] (fMidiCaptureBuffer[midi_port_index]); + } delete[] fMidiCaptureBuffer; fMidiCaptureBuffer = NULL; } if (fAudioPlaybackBuffer) { - for (int audio_port_index = 0; audio_port_index < fParams.fReturnAudioChannels; audio_port_index++) + for (int audio_port_index = 0; audio_port_index < fParams.fReturnAudioChannels; audio_port_index++) { delete[] fAudioPlaybackBuffer[audio_port_index]; + } delete[] fAudioPlaybackBuffer; fAudioPlaybackBuffer = NULL; } if (fMidiPlaybackBuffer) { - for (int midi_port_index = 0; midi_port_index < fParams.fReturnMidiChannels; midi_port_index++) + for (int midi_port_index = 0; midi_port_index < fParams.fReturnMidiChannels; midi_port_index++) { delete[] fMidiPlaybackBuffer[midi_port_index]; + } delete[] fMidiPlaybackBuffer; fMidiPlaybackBuffer = NULL; } @@ -995,8 +1001,8 @@ LIB_EXPORT int jack_adapter_pull_and_push(jack_adapter_t* adapter, float** input static void jack_format_and_log(int level, const char *prefix, const char *fmt, va_list ap) { - const char* netjack_log = getenv("JACK_NETJACK_LOG"); - bool is_netjack_log = (netjack_log) ? atoi(netjack_log) : 0; + static const char* netjack_log = getenv("JACK_NETJACK_LOG"); + static bool is_netjack_log = (netjack_log) ? atoi(netjack_log) : 0; if (is_netjack_log) { char buffer[300]; diff --git a/common/JackNetInterface.cpp b/common/JackNetInterface.cpp index b541c50b..4d386869 100644 --- a/common/JackNetInterface.cpp +++ b/common/JackNetInterface.cpp @@ -199,6 +199,7 @@ namespace Jack fRxHeader.fCycle = rx_head->fCycle; fRxHeader.fIsLastPckt = rx_head->fIsLastPckt; buffer->RenderFromNetwork(rx_head->fSubCycle, rx_bytes - HEADER_SIZE); + // Last midi packet is received, so finish rendering... if (++recvd_midi_pckt == rx_head->fNumPacket) { buffer->RenderToJackPorts(); @@ -214,6 +215,7 @@ namespace Jack fRxHeader.fIsLastPckt = rx_head->fIsLastPckt; fRxHeader.fActivePorts = rx_head->fActivePorts; rx_bytes = buffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, fRxHeader.fActivePorts); + // Last audio packet is received, so finish rendering... if (fRxHeader.fIsLastPckt) { buffer->RenderToJackPorts(); @@ -223,7 +225,6 @@ namespace Jack int JackNetInterface::FinishRecv(NetAudioBuffer* buffer) { - // TODO : finish midi and audio rendering ? buffer->RenderToJackPorts(); return NET_PACKET_ERROR; } @@ -656,8 +657,9 @@ namespace Jack // then tell the master we are ready jack_info("Initializing connection with %s...", fParams.fMasterNetName); status = SendStartToMaster(); - if (status == NET_ERROR) + if (status == NET_ERROR) { return false; + } } while (status != NET_ROLLING); @@ -704,8 +706,9 @@ namespace Jack session_params_t net_params; memset(&net_params, 0, sizeof(session_params_t)); SessionParamsHToN(&fParams, &net_params); - if (fSocket.SendTo(&net_params, sizeof(session_params_t), 0, fMulticastIP) == SOCKET_ERROR) + if (fSocket.SendTo(&net_params, sizeof(session_params_t), 0, fMulticastIP) == SOCKET_ERROR) { jack_error("Error in data send : %s", StrError(NET_ERROR_CODE)); + } // filter incoming packets : don't exit while no error is detected memset(&net_params, 0, sizeof(session_params_t)); diff --git a/macosx/Jackdmp.xcodeproj/project.pbxproj b/macosx/Jackdmp.xcodeproj/project.pbxproj index 4b1865c8..06cd89cc 100644 --- a/macosx/Jackdmp.xcodeproj/project.pbxproj +++ b/macosx/Jackdmp.xcodeproj/project.pbxproj @@ -1743,9 +1743,6 @@ 4B370A21133DD7E300237B68 /* JackCoreMidiVirtualInputPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JackCoreMidiVirtualInputPort.h; path = ../../coremidi/JackCoreMidiVirtualInputPort.h; sourceTree = BUILT_PRODUCTS_DIR; }; 4B370A22133DD7E300237B68 /* JackCoreMidiVirtualOutputPort.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JackCoreMidiVirtualOutputPort.cpp; path = ../../coremidi/JackCoreMidiVirtualOutputPort.cpp; sourceTree = BUILT_PRODUCTS_DIR; }; 4B370A23133DD7E300237B68 /* JackCoreMidiVirtualOutputPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JackCoreMidiVirtualOutputPort.h; path = ../../coremidi/JackCoreMidiVirtualOutputPort.h; sourceTree = BUILT_PRODUCTS_DIR; }; - 4B37C20306DF1FBE0016E567 /* CALatencyLog.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CALatencyLog.cpp; path = /Developer/Examples/CoreAudio/PublicUtility/CALatencyLog.cpp; sourceTree = ""; }; - 4B37C20406DF1FBE0016E567 /* CALatencyLog.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CALatencyLog.h; path = /Developer/Examples/CoreAudio/PublicUtility/CALatencyLog.h; sourceTree = ""; }; - 4B37C20906DF1FE20016E567 /* latency.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = latency.c; path = /Developer/Examples/CoreAudio/PublicUtility/latency.c; sourceTree = ""; }; 4B38115F1326878E00C61B14 /* jack_latent_client */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jack_latent_client; sourceTree = BUILT_PRODUCTS_DIR; }; 4B3811971326884E00C61B14 /* jack_latent_client */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jack_latent_client; sourceTree = BUILT_PRODUCTS_DIR; }; 4B3811FA13269C8300C61B14 /* latent_client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = latent_client.c; path = "../example-clients/latent_client.c"; sourceTree = SOURCE_ROOT; }; @@ -3049,9 +3046,6 @@ 4B37C20006DF1F900016E567 /* Latency */ = { isa = PBXGroup; children = ( - 4B37C20906DF1FE20016E567 /* latency.c */, - 4B37C20306DF1FBE0016E567 /* CALatencyLog.cpp */, - 4B37C20406DF1FBE0016E567 /* CALatencyLog.h */, ); name = Latency; sourceTree = "";