diff --git a/ChangeLog b/ChangeLog index 28973d3f..77a5edd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,10 @@ Chris Caudle Jackdmp changes log --------------------------- +2011-07-22 Stephane Letz + + * NetJack2: improve error reporting. + 2011-07-16 Stephane Letz * Error in JackActivationCount::Signal now uses jack_log instead of jack_error. @@ -78,12 +82,12 @@ Chris Caudle 2011-06-17 Stephane Letz - * NetJack2 : connection error handling. + * NetJack2: connection error handling. 2011-06-16 Stephane Letz * Changes in NetJack2 connection management: no more timeout, any transmission error considered as fatal. - * NetJack2 : timeout again... + * NetJack2: timeout again... 2011-06-11 Stephane Letz @@ -96,7 +100,7 @@ Chris Caudle 2011-06-09 Stephane Letz - * Correct NetJack2 connection handling + * Correct NetJack2 connection handling. 2011-05-27 Stephane Letz @@ -116,7 +120,7 @@ Chris Caudle 2011-05-02 Stephane Letz - * Merge branch 'switch-master-port-registration-notifications : correct driver port registration. + * Merge branch switch-master-port-registration-notifications: correct driver port registration. 2011-04-21 Stephane Letz @@ -140,7 +144,7 @@ Chris Caudle 2011-04-02 Stephane Letz - * Netdriver can now ask for in/out values from the master (in progress). + * NetDriver can now ask for in/out values from the master (in progress). * Correct drivers parameter settings. 2011-04-01 Stephane Letz @@ -238,7 +242,7 @@ Chris Caudle 2010-11-17 Stephane Letz - * ALSA backend : suspend/resume handling (jack1 r4075). + * ALSA backend: suspend/resume handling (jack1 r4075). * Correct dummy driver. 2010-11-05 Stephane Letz @@ -290,7 +294,7 @@ Chris Caudle 2010-06-13 Stephane Letz - * Fix JackPosixSemaphore::TimedWait : same behavior as JackPosixSemaphore::Wait regarding EINTR. + * Fix JackPosixSemaphore::TimedWait: same behavior as JackPosixSemaphore::Wait regarding EINTR. 2010-05-31 Stephane Letz @@ -337,7 +341,7 @@ Chris Caudle 2010-03-04 Stephane Letz - * Correct JackMachServerChannel::Execute : keep running even in error cases. + * Correct JackMachServerChannel::Execute: keep running even in error cases. * Raise JACK_PROTOCOL_VERSION number. 2010-03-03 Stephane Letz @@ -346,7 +350,7 @@ Chris Caudle 2010-03-02 Stephane Letz - * Improve JackCoreAudioDriver and JackCoreAudioAdapter : when no devices are described, takes default input and output and aggregate them. + * Improve JackCoreAudioDriver and JackCoreAudioAdapter: when no devices are described, takes default input and output and aggregate them. 2010-02-15 Stephane Letz @@ -388,7 +392,7 @@ Chris Caudle 2009-12-01 Stephane Letz - * Fix port_rename callback : now both old name and new name are given as parameters. + * Fix port_rename callback: now both old name and new name are given as parameters. 2009-11-30 Stephane Letz @@ -418,7 +422,7 @@ Chris Caudle 2009-11-17 Stephane Letz * In JackCoreAudio driver, clock drift compensation in aggregated devices working. - * In JackCoreAudio driver, clock drift compensation semantic changed a bit : when on, does not activate if not needed (same clock domain). + * In JackCoreAudio driver, clock drift compensation semantic changed a bit: when on, does not activate if not needed (same clock domain). 2009-11-16 Stephane Letz @@ -426,14 +430,14 @@ Chris Caudle 2009-11-14 Stephane Letz - * Sync with JACK1 : -r parameter now used for no-realtime, realtime (-R) is now default, usable backend given vie platform. + * Sync with JACK1: -r parameter now used for no-realtime, realtime (-R) is now default, usable backend given vie platform. 2009-11-13 Stephane Letz * Better memory allocation error checking in ringbuffer.c, weak import improvements. * Memory allocation error checking for jack_client_new and jack_client_open (server and client side). * Memory allocation error checking in server for RPC. - * Simplify server temporary mode : now use a JackTemporaryException. + * Simplify server temporary mode: now use a JackTemporaryException. * Lock/Unlock shared memory segments (to test...). 2009-11-12 Stephane Letz @@ -450,12 +454,12 @@ Chris Caudle 2009-11-09 Stephane Letz - * Correct JackGraphManager::GetBuffer for the "client loop with one connection" case : buffer must be copied. + * Correct JackGraphManager::GetBuffer for the "client loop with one connection" case: buffer must be copied. 2009-11-07 Stephane Letz * Fix AcquireRealTime and DropRealTime: now distinguish when called from another thread (AcquireRealTime/DropRealTime) and from the thread itself (AcquireSelfRealTime/DropSelfRealTime). - * Correct JackPosixThread::StartImp : thread priority setting now done in the RT case only. + * Correct JackPosixThread::StartImp: thread priority setting now done in the RT case only. 2009-11-06 Stephane Letz @@ -496,7 +500,7 @@ Chris Caudle 2009-10-25 Stephane Letz - * Improve aggregate device management in JackCoreAudioDriver : now a "private" device only and cleanup properly. + * Improve aggregate device management in JackCoreAudioDriver: now a "private" device only and cleanup properly. * Aggregate device code added to JackCoreAudioAdapter. 2009-10-23 Stephane Letz @@ -517,7 +521,7 @@ Chris Caudle 2009-10-17 Stephane Letz - * Correct server temporary mode : now set a global and quit after server/client message handling is finished. + * Correct server temporary mode: now set a global and quit after server/client message handling is finished. 2009-10-15 Stephane Letz @@ -598,12 +602,12 @@ Chris Caudle 2009-06-30 Stephane Letz - * Tim Bechmann patch : hammerfall, only release monitor thread, if it has been created. + * Tim Bechmann patch: hammerfall, only release monitor thread, if it has been created. 2009-06-19 Stephane Letz * Correct JackTransportEngine::MakeAllLocating, sync callback has to be called in this case also. - * NetJack2 code : better error checkout, method renaming. + * NetJack2 code: better error checkout, method renaming. 2009-06-17 Stephane Letz @@ -703,7 +707,7 @@ Chris Caudle 2009-03-11 Stephane Letz - * Client incorrect re-naming fixed : now done at socket level also. + * Client incorrect re-naming fixed: now done at socket level also. 2009-03-10 Stephane Letz @@ -918,7 +922,7 @@ Chris Caudle 2008-10-08 Stephane Letz - * Fix a SMP related bug introduced in rev 2957 : remove the __SMP__ flag and define LOCK for SMP in all cases. + * Fix a SMP related bug introduced in rev 2957: remove the __SMP__ flag and define LOCK for SMP in all cases. 2008-10-02 Stephane Letz @@ -933,7 +937,7 @@ Chris Caudle 2008-10-10 Stephane Letz - * Improve OSS backend : SNDCTL_DSP_SETFRAGMENT must be done before, use of AFMT_S16_LE kind of values. + * Improve OSS backend: SNDCTL_DSP_SETFRAGMENT must be done before, use of AFMT_S16_LE kind of values. 2008-10-09 Stephane Letz @@ -942,7 +946,7 @@ Chris Caudle 2008-10-08 Stephane Letz - * Fix a SMP related bug introduced in rev 2957 : remove the __SMP__ flag and define LOCK for SMP in all cases. + * Fix a SMP related bug introduced in rev 2957: remove the __SMP__ flag and define LOCK for SMP in all cases. 2008-10-03 Stephane Letz @@ -1059,7 +1063,7 @@ Chris Caudle 2008-07-08 Stephane Letz * Add jack_get_descriptor in internal clients API. - * Fix JackFreewheelDriver::Process() in case if client time-out : continue processing until a better recovery strategy is chosen. + * Fix JackFreewheelDriver::Process() in case if client time-out: continue processing until a better recovery strategy is chosen. 2008-07-08 Stephane Letz @@ -1132,7 +1136,7 @@ Chris Caudle 2008-06-02 Stephane Letz - * Tim Blechmann patch to remove unnecessary virtual methods : choice of the appropriate platform version is now done at compilation time. + * Tim Blechmann patch to remove unnecessary virtual methods: choice of the appropriate platform version is now done at compilation time. 2008-06-02 Stephane Letz @@ -1159,12 +1163,12 @@ Chris Caudle 2008-05-27 Stephane Letz - * Correct timing in drivers : frame time has to be incremented before Read. + * Correct timing in drivers: frame time has to be incremented before Read. 2008-05-26 Stephane Letz * Merge control branch. - * Cleanup example clients : use jack_client_open and install a proper 'quit' signal handler. + * Cleanup example clients: use jack_client_open and install a proper 'quit' signal handler. 2008-05-24 Stephane Letz @@ -1185,7 +1189,7 @@ Chris Caudle * Correct JackEngine::PortUnRegister, JackEngine::ClientCloseAux and JackEngine::ClientDeactivate to correctly send notifications. * New jack_get_client_pid API, implemented on server side. - * Better handling of graph state read functions : never wait when used in the real-time thread, current state is used. + * Better handling of graph state read functions: never wait when used in the real-time thread, current state is used. 2008-05-20 Stephane Letz @@ -1195,7 +1199,7 @@ Chris Caudle 2008-05-19 Stephane Letz * Use of placement new for dynamic port allocation is possibly not safe... so avoid that until a definitive answer is found. - * JackAudioDriver::ProcessAsync and JackAudioDriver::ProcessSync were broken at some point : 0 has to be returned in all cases. + * JackAudioDriver::ProcessAsync and JackAudioDriver::ProcessSync were broken at some point: 0 has to be returned in all cases. 2008-05-16 Stephane Letz @@ -1224,7 +1228,7 @@ Chris Caudle 2008-05-05 Stephane Letz - * Fix JackClient::Close : notification channel is stopped first to avoid receiving notifications while closing and Close is again a synchronous call. + * Fix JackClient::Close: notification channel is stopped first to avoid receiving notifications while closing and Close is again a synchronous call. * No more remaining client close in JackEngine::Close(). 2008-05-01 Stephane Letz @@ -1265,7 +1269,7 @@ Chris Caudle 2008-03-29 Stephane Letz * Correct a missing parameter in the usage message of jack_midiseq. - * Add a client counter in wrapper layer : library is unloaded only when all clients have been closed. + * Add a client counter in wrapper layer: library is unloaded only when all clients have been closed. 2008-03-28 Stephane Letz @@ -1455,7 +1459,7 @@ Chris Caudle 2008-01-03 Stephane Letz - * Dmitry Baikov MIDI patch : alsa_seqmidi and alsa_rammidi drivers. + * Dmitry Baikov MIDI patch: alsa_seqmidi and alsa_rammidi drivers. 2008-01-03 Stephane Letz diff --git a/common/JackAPI.cpp b/common/JackAPI.cpp index 097226ac..b05704c4 100644 --- a/common/JackAPI.cpp +++ b/common/JackAPI.cpp @@ -1993,7 +1993,7 @@ LIB_EXPORT int jack_set_session_callback(jack_client_t* ext_client, JackSessionC } } -LIB_EXPORT jack_session_command_t *jack_session_notify(jack_client_t* ext_client, const char* target, jack_session_event_type_t ev_type, const char* path) +LIB_EXPORT jack_session_command_t* jack_session_notify(jack_client_t* ext_client, const char* target, jack_session_event_type_t ev_type, const char* path) { #ifdef __CLIENTDEBUG__ JackGlobals::CheckContext("jack_session_notify"); @@ -2039,7 +2039,7 @@ LIB_EXPORT void jack_session_event_free(jack_session_event_t* ev) } } -LIB_EXPORT char *jack_get_uuid_for_client_name(jack_client_t* ext_client, const char* client_name) +LIB_EXPORT char* jack_get_uuid_for_client_name(jack_client_t* ext_client, const char* client_name) { #ifdef __CLIENTDEBUG__ JackGlobals::CheckContext("jack_get_uuid_for_client_name"); @@ -2054,7 +2054,7 @@ LIB_EXPORT char *jack_get_uuid_for_client_name(jack_client_t* ext_client, const } } -LIB_EXPORT char *jack_get_client_name_by_uuid(jack_client_t* ext_client, const char* client_uuid) +LIB_EXPORT char* jack_get_client_name_by_uuid(jack_client_t* ext_client, const char* client_uuid) { #ifdef __CLIENTDEBUG__ JackGlobals::CheckContext("jack_get_client_name_by_uuid"); diff --git a/common/JackControlAPI.cpp b/common/JackControlAPI.cpp index ec8660c9..2329ce80 100644 --- a/common/JackControlAPI.cpp +++ b/common/JackControlAPI.cpp @@ -1203,7 +1203,7 @@ LIB_EXPORT bool jackctl_server_unload_internal( { int status; if (server_ptr->engine != NULL && internal->refnum > 0) { - // Client object is internally kept in JackEngine, and will be desallocated in InternalClientUnload + // Client object is internally kept in JackEngine, and will be deallocated in InternalClientUnload return ((server_ptr->engine->GetEngine()->InternalClientUnload(internal->refnum, &status)) == 0); } else { return false; diff --git a/common/JackFrameTimer.cpp b/common/JackFrameTimer.cpp index bd6d9b53..180de970 100644 --- a/common/JackFrameTimer.cpp +++ b/common/JackFrameTimer.cpp @@ -13,7 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License -along with this program; if not, write to the Free Software +along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ diff --git a/common/JackNetAPI.cpp b/common/JackNetAPI.cpp index 8ecb7869..9be49aa0 100644 --- a/common/JackNetAPI.cpp +++ b/common/JackNetAPI.cpp @@ -298,70 +298,66 @@ struct JackNetExtMaster : public JackNetMasterInterface { void AllocPorts() { - int port_index; - - // Set buffers + // Set buffers if (fParams.fSendAudioChannels > 0) { fAudioCaptureBuffer = new float*[fParams.fSendAudioChannels]; - for (port_index = 0; port_index < fParams.fSendAudioChannels; port_index++) { - fAudioCaptureBuffer[port_index] = new float[fParams.fPeriodSize]; - fNetAudioCaptureBuffer->SetBuffer(port_index, fAudioCaptureBuffer[port_index]); + for (int audio_port_index = 0; audio_port_index < fParams.fSendAudioChannels; audio_port_index++) { + fAudioCaptureBuffer[audio_port_index] = new float[fParams.fPeriodSize]; + fNetAudioCaptureBuffer->SetBuffer(audio_port_index, fAudioCaptureBuffer[audio_port_index]); } } if (fParams.fSendMidiChannels > 0) { fMidiCaptureBuffer = new JackMidiBuffer*[fParams.fSendMidiChannels]; - for (port_index = 0; port_index < fParams.fSendMidiChannels; port_index++) { - fMidiCaptureBuffer[port_index] = (JackMidiBuffer*)new float[fParams.fPeriodSize]; - fNetMidiCaptureBuffer->SetBuffer(port_index, fMidiCaptureBuffer[port_index]); + for (int midi_port_index = 0; midi_port_index < fParams.fSendMidiChannels; midi_port_index++) { + fMidiCaptureBuffer[midi_port_index] = (JackMidiBuffer*)new float[fParams.fPeriodSize]; + fNetMidiCaptureBuffer->SetBuffer(midi_port_index, fMidiCaptureBuffer[midi_port_index]); } } if (fParams.fReturnAudioChannels > 0) { fAudioPlaybackBuffer = new float*[fParams.fReturnAudioChannels]; - for (port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++) { - fAudioPlaybackBuffer[port_index] = new float[fParams.fPeriodSize]; - fNetAudioPlaybackBuffer->SetBuffer(port_index, fAudioPlaybackBuffer[port_index]); + for (int audio_port_index = 0; audio_port_index < fParams.fReturnAudioChannels; audio_port_index++) { + fAudioPlaybackBuffer[audio_port_index] = new float[fParams.fPeriodSize]; + fNetAudioPlaybackBuffer->SetBuffer(audio_port_index, fAudioPlaybackBuffer[audio_port_index]); } } if (fParams.fReturnMidiChannels > 0) { fMidiPlaybackBuffer = new JackMidiBuffer*[fParams.fReturnMidiChannels]; - for (port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++) { - fMidiPlaybackBuffer[port_index] = (JackMidiBuffer*)new float[fParams.fPeriodSize]; - fNetMidiPlaybackBuffer->SetBuffer(port_index, fMidiPlaybackBuffer[port_index]); + for (int midi_port_index = 0; midi_port_index < fParams.fReturnMidiChannels; midi_port_index++) { + fMidiPlaybackBuffer[midi_port_index] = (JackMidiBuffer*)new float[fParams.fPeriodSize]; + fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, fMidiPlaybackBuffer[midi_port_index]); } } } void FreePorts() { - int port_index; - if (fAudioPlaybackBuffer) { - for (port_index = 0; port_index < fParams.fSendAudioChannels; port_index++) - delete[] fAudioPlaybackBuffer[port_index]; + for (int audio_port_index = 0; audio_port_index < fParams.fSendAudioChannels; audio_port_index++) + delete[] fAudioPlaybackBuffer[audio_port_index]; delete[] fAudioPlaybackBuffer; fAudioPlaybackBuffer = NULL; } if (fMidiPlaybackBuffer) { - for (port_index = 0; port_index < fParams.fSendMidiChannels; port_index++) - delete[] (fMidiPlaybackBuffer[port_index]); + for (int midi_port_index = 0; midi_port_index < fParams.fSendMidiChannels; midi_port_index++) + delete[] (fMidiPlaybackBuffer[midi_port_index]); delete[] fMidiPlaybackBuffer; fMidiPlaybackBuffer = NULL; } if (fAudioCaptureBuffer) { - for (port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++) - delete[] fAudioCaptureBuffer[port_index]; + for (int audio_port_index = 0; audio_port_index < fParams.fReturnAudioChannels; audio_port_index++) + delete[] fAudioCaptureBuffer[audio_port_index]; delete[] fAudioCaptureBuffer; fAudioCaptureBuffer = NULL; } if (fMidiCaptureBuffer) { - for (port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++) - delete[] fMidiCaptureBuffer[port_index]; + for (int midi_port_index = 0; midi_port_index < fParams.fReturnMidiChannels; midi_port_index++) + delete[] fMidiCaptureBuffer[midi_port_index]; delete[] fMidiCaptureBuffer; fMidiCaptureBuffer = NULL; } @@ -372,12 +368,12 @@ struct JackNetExtMaster : public JackNetMasterInterface { try { assert(audio_input == fParams.fReturnAudioChannels); - for (int port_index = 0; port_index < audio_input; port_index++) { - fNetAudioPlaybackBuffer->SetBuffer(port_index, audio_input_buffer[port_index]); + for (int audio_port_index = 0; audio_port_index < audio_input; audio_port_index++) { + fNetAudioPlaybackBuffer->SetBuffer(audio_port_index, audio_input_buffer[audio_port_index]); } - for (int port_index = 0; port_index < midi_input; port_index++) { - fNetMidiPlaybackBuffer->SetBuffer(port_index, ((JackMidiBuffer**)midi_input_buffer)[port_index]); + for (int midi_port_index = 0; midi_port_index < midi_input; midi_port_index++) { + fNetMidiPlaybackBuffer->SetBuffer(midi_port_index, ((JackMidiBuffer**)midi_input_buffer)[midi_port_index]); } if (SyncRecv() == SOCKET_ERROR) @@ -397,12 +393,12 @@ struct JackNetExtMaster : public JackNetMasterInterface { try { assert(audio_output == fParams.fSendAudioChannels); - for (int port_index = 0; port_index < audio_output; port_index++) { - fNetAudioCaptureBuffer->SetBuffer(port_index, audio_output_buffer[port_index]); + for (int audio_port_index = 0; audio_port_index < audio_output; audio_port_index++) { + fNetAudioCaptureBuffer->SetBuffer(audio_port_index, audio_output_buffer[audio_port_index]); } - for (int port_index = 0; port_index < midi_output; port_index++) { - fNetMidiCaptureBuffer->SetBuffer(port_index, ((JackMidiBuffer**)midi_output_buffer)[port_index]); + for (int midi_port_index = 0; midi_port_index < midi_output; midi_port_index++) { + fNetMidiCaptureBuffer->SetBuffer(midi_port_index, ((JackMidiBuffer**)midi_output_buffer)[midi_port_index]); } EncodeSyncPacket(); diff --git a/common/JackNetDriver.cpp b/common/JackNetDriver.cpp index 38fe48e7..2855fb17 100644 --- a/common/JackNetDriver.cpp +++ b/common/JackNetDriver.cpp @@ -554,8 +554,13 @@ namespace Jack fNetTimeMon->Add(((float)(GetMicroSeconds() - fRcvSyncUst) / (float)fEngineControl->fPeriodUsecs) * 100.f); #endif //audio, midi or sync if driver is late - if (DataRecv() == SOCKET_ERROR) + int res = DataRecv(); + if (res == SOCKET_ERROR) { return SOCKET_ERROR; + } else if (res == NET_PACKET_ERROR) { + jack_time_t cur_time = GetMicroSeconds(); + NotifyXRun(cur_time, float(cur_time - fBeginDateUst)); // Better this value than nothing... + } //take the time at the beginning of the cycle JackDriver::CycleTakeBeginTime(); @@ -576,7 +581,7 @@ namespace Jack for (int audio_port_index = 0; audio_port_index < fPlaybackChannels; audio_port_index++) { #ifdef OPTIMIZED_PROTOCOL // Port is connected on other side... - if ((long)fNetAudioPlaybackBuffer->GetBuffer(audio_port_index) == -1) { + if ((intptr_t)fNetAudioPlaybackBuffer->GetBuffer(audio_port_index) == -1) { fNetAudioPlaybackBuffer->SetBuffer(audio_port_index, GetOutputBuffer(audio_port_index, true)); } else { fNetAudioPlaybackBuffer->SetBuffer(audio_port_index, NULL); diff --git a/common/JackNetInterface.cpp b/common/JackNetInterface.cpp index f379db27..d8562a05 100644 --- a/common/JackNetInterface.cpp +++ b/common/JackNetInterface.cpp @@ -477,7 +477,7 @@ namespace Jack int rx_bytes = Recv(fParams.fMtu, MSG_PEEK); if ((rx_bytes == 0) || (rx_bytes == SOCKET_ERROR)) { - // O bytes considered an error (lost connection) + // 0 bytes considered an error (lost connection) return SOCKET_ERROR; } @@ -581,7 +581,7 @@ namespace Jack fRxHeader.fSubCycle = rx_head->fSubCycle; fRxHeader.fIsLastPckt = rx_head->fIsLastPckt; fRxHeader.fActivePorts = rx_head->fActivePorts; - fNetAudioPlaybackBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts); + rx_bytes = fNetAudioPlaybackBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts); // Last audio packet is received, so finish rendering... if (fRxHeader.fIsLastPckt) fNetAudioPlaybackBuffer->RenderToJackPorts(); @@ -591,7 +591,7 @@ namespace Jack jack_info("NetMaster : overloaded, skipping receive from '%s'", fParams.fName); // TODO : finish midi and audio rendering ? fNetAudioPlaybackBuffer->RenderToJackPorts(); - return 0; + return NET_PACKET_ERROR; } } } @@ -978,7 +978,7 @@ namespace Jack fRxHeader.fSubCycle = rx_head->fSubCycle; fRxHeader.fIsLastPckt = rx_head->fIsLastPckt; fRxHeader.fActivePorts = rx_head->fActivePorts; - fNetAudioCaptureBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts); + rx_bytes = fNetAudioCaptureBuffer->RenderFromNetwork(rx_head->fCycle, rx_head->fSubCycle, rx_bytes - HEADER_SIZE, fRxHeader.fActivePorts); // Last audio packet is received, so finish rendering... if (fRxHeader.fIsLastPckt) fNetAudioCaptureBuffer->RenderToJackPorts(); @@ -988,13 +988,13 @@ namespace Jack jack_info("NetSlave : overloaded, skipping receive"); // TODO : finish midi and audio rendering ? fNetAudioCaptureBuffer->RenderToJackPorts(); - return 0; + return NET_PACKET_ERROR; } } } fRxHeader.fCycle = rx_head->fCycle; - return 0; + return rx_bytes; } int JackNetSlaveInterface::SyncSend() diff --git a/common/JackNetManager.cpp b/common/JackNetManager.cpp index 7601acdd..a0c14de3 100644 --- a/common/JackNetManager.cpp +++ b/common/JackNetManager.cpp @@ -19,6 +19,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackNetManager.h" #include "JackArgParser.h" #include "JackTime.h" +#include "JackServerGlobals.h" +#include "JackLockedEngine.h" using namespace std; @@ -407,7 +409,11 @@ namespace Jack //process----------------------------------------------------------------------------- int JackNetMaster::SetProcess(jack_nframes_t nframes, void* arg) { - return static_cast ( arg )->Process(); + try { + return static_cast(arg)->Process(); + } catch (JackNetException& e) { + return 0; + } } int JackNetMaster::Process() @@ -431,7 +437,7 @@ namespace Jack for (int audio_port_index = 0; audio_port_index < fParams.fSendAudioChannels; audio_port_index++) { #ifdef OPTIMIZED_PROTOCOL - if ((long)fNetAudioCaptureBuffer->GetBuffer(audio_port_index) == -1) { + if ((intptr_t)fNetAudioCaptureBuffer->GetBuffer(audio_port_index) == -1) { // Port is connected on other side... fNetAudioCaptureBuffer->SetBuffer(audio_port_index, static_cast(jack_port_get_buffer_nulled(fAudioCapturePorts[audio_port_index], @@ -441,8 +447,8 @@ namespace Jack } #else fNetAudioCaptureBuffer->SetBuffer(audio_port_index, - static_cast(jack_port_get_buffer(fAudioCapturePorts[audio_port_index], - fParams.fPeriodSize))); + static_cast(jack_port_get_buffer(fAudioCapturePorts[audio_port_index], + fParams.fPeriodSize))); #endif // TODO } @@ -523,8 +529,12 @@ namespace Jack //receive data res = DataRecv(); - if ((res == 0) || (res == SOCKET_ERROR)) + if ((res == 0) || (res == SOCKET_ERROR)) { return res; + } else if (res == NET_PACKET_ERROR) { + // Well not a real XRun, but... + JackServerGlobals::fInstance->GetEngine()->NotifyXRun(GetMicroSeconds(), 0); + } /* switch (DataRecv()) { diff --git a/common/JackNetTool.cpp b/common/JackNetTool.cpp index ad53f64e..791af963 100644 --- a/common/JackNetTool.cpp +++ b/common/JackNetTool.cpp @@ -25,23 +25,25 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. class HardwareClock { -public: - HardwareClock(); + public: - void Reset(); - void Update(); + HardwareClock(); - float GetDeltaTime() const; - double GetTime() const; + void Reset(); + void Update(); -private: - double m_clockToSeconds; + float GetDeltaTime() const; + double GetTime() const; - uint64_t m_startAbsTime; - uint64_t m_lastAbsTime; + private: - double m_time; - float m_deltaTime; + double m_clockToSeconds; + + uint64_t m_startAbsTime; + uint64_t m_lastAbsTime; + + double m_time; + float m_deltaTime; }; HardwareClock::HardwareClock() @@ -228,9 +230,9 @@ namespace Jack } //network<->buffer - void NetFloatAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) + int NetFloatAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) { - fPortBuffer.RenderFromNetwork(fNetBuffer, cycle, sub_cycle, copy_size, port_num); + return fPortBuffer.RenderFromNetwork(fNetBuffer, cycle, sub_cycle, copy_size, port_num); } int NetFloatAudioBuffer::RenderToNetwork(int sub_cycle, uint32_t& port_num) @@ -443,8 +445,10 @@ namespace Jack } //network<->buffer - void NetCeltAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) + int NetCeltAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) { + int res = 0; + if (sub_cycle == fNumPackets - 1) { for (int port_index = 0; port_index < fNPorts; port_index++) memcpy(fCompressedBuffer[port_index] + sub_cycle * fSubPeriodBytesSize, fNetBuffer + port_index * fLastSubPeriodBytesSize, fLastSubPeriodBytesSize); @@ -453,10 +457,13 @@ namespace Jack memcpy(fCompressedBuffer[port_index] + sub_cycle * fSubPeriodBytesSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize); } - if (sub_cycle != fLastSubCycle + 1) + if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); + res = NET_PACKET_ERROR; + } fLastSubCycle = sub_cycle; + return res; } int NetCeltAudioBuffer::RenderToNetwork(int sub_cycle, uint32_t& port_num) @@ -573,8 +580,10 @@ namespace Jack } //network<->buffer - void NetIntAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) + int NetIntAudioBuffer::RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) { + int res = 0; + if (sub_cycle == fNumPackets - 1) { for (int port_index = 0; port_index < fNPorts; port_index++) memcpy(fIntBuffer[port_index] + sub_cycle * fSubPeriodSize, fNetBuffer + port_index * fLastSubPeriodBytesSize, fLastSubPeriodBytesSize); @@ -583,10 +592,13 @@ namespace Jack memcpy(fIntBuffer[port_index] + sub_cycle * fSubPeriodSize, fNetBuffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize); } - if (sub_cycle != fLastSubCycle + 1) + if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); + res = NET_PACKET_ERROR; + } fLastSubCycle = sub_cycle; + return res; } int NetIntAudioBuffer::RenderToNetwork(int sub_cycle, uint32_t& port_num) diff --git a/common/JackNetTool.h b/common/JackNetTool.h index ac5b61b8..375aa376 100644 --- a/common/JackNetTool.h +++ b/common/JackNetTool.h @@ -42,6 +42,8 @@ using namespace std; #define MASTER_PROTOCOL 4 #define SLAVE_PROTOCOL 4 +#define NET_PACKET_ERROR -2 + #define OPTIMIZED_PROTOCOL namespace Jack @@ -288,7 +290,7 @@ namespace Jack virtual void RenderToJackPorts() = 0; //network<->buffer - virtual void RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) = 0; + virtual int RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) = 0; virtual void ActivePortsFromNetwork(char* net_buffer, uint32_t port_num) {} virtual int RenderToNetwork(int sub_cycle, uint32_t& port_num) = 0; @@ -366,7 +368,7 @@ namespace Jack fPortBuffer = 0; } - ~JackPortList() + virtual ~JackPortList() { delete [] fPortBuffer; } @@ -424,8 +426,10 @@ namespace Jack {} //network<->buffer - virtual void RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) + virtual int RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) { + int res = 0; + for (int port_index = 0; port_index < fNPorts; port_index++) { float* src = (float*)(net_buffer + port_index * fSubPeriodBytesSize); float* dst = (float*)(fPortBuffer[port_index] + sub_cycle * fSubPeriodSize); @@ -435,8 +439,11 @@ namespace Jack } if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); + res = NET_PACKET_ERROR; } + fLastSubCycle = sub_cycle; + return res; } virtual int RenderToNetwork(char* net_buffer, int sub_cycle, uint32_t& port_num) @@ -465,15 +472,20 @@ namespace Jack } //network<->buffer - virtual void RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) + virtual int RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) { + int res = 0; + for (int port_index = 0; port_index < fNPorts; port_index++) { memcpy(fPortBuffer[port_index] + sub_cycle * fSubPeriodSize, net_buffer + port_index * fSubPeriodBytesSize, fSubPeriodBytesSize); } if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); + res = NET_PACKET_ERROR; } + fLastSubCycle = sub_cycle; + return res; } virtual int RenderToNetwork(char* net_buffer, int sub_cycle, uint32_t& port_num) @@ -506,6 +518,9 @@ namespace Jack :JackPortList(params, nports) {} + virtual ~JackOptimizedPortList() + {} + int GetNumPackets() { // Count active ports @@ -532,8 +547,10 @@ namespace Jack #else //network<->buffer - virtual void RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) + virtual int RenderFromNetwork(char* net_buffer, int cycle, int sub_cycle, size_t copy_size, uint32_t port_num) { + int res = 0; + // Cleanup all JACK ports at the beginning of the cycle if (sub_cycle == 0) { for (int port_index = 0; port_index < fNPorts; port_index++) { @@ -554,8 +571,6 @@ namespace Jack } sub_period_bytes_size = sub_period_size * sizeof(sample_t) + sizeof(uint32_t); // The port number in coded on 4 bytes - - for (uint32_t port_index = 0; port_index < port_num; port_index++) { // Only copy to active ports : read the active port number then audio data int* active_port_address = (int*)(net_buffer + port_index * sub_period_bytes_size); @@ -566,9 +581,13 @@ namespace Jack if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); + res = NET_PACKET_ERROR; } + fLastSubCycle = sub_cycle; } + + return res; } virtual int RenderToNetwork(char* net_buffer,int sub_cycle, uint32_t& port_num) @@ -618,7 +637,11 @@ namespace Jack for (uint port_index = 0; port_index < port_num; port_index++) { // Use -1 when port is actually connected on other side - fPortBuffer[*active_port_address] = (sample_t*)-1; + if (*active_port_address >= 0 && *active_port_address < fNPorts) { + fPortBuffer[*active_port_address] = (sample_t*)-1; + } else { + jack_error("ActivePortsFromNetwork: incorrect port = %d", *active_port_address); + } active_port_address++; } } @@ -663,7 +686,7 @@ namespace Jack sample_t* GetBuffer(int index); //network<->buffer - void RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num); + int RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num); void ActivePortsFromNetwork(char* net_buffer, uint32_t port_num); int RenderToNetwork(int sub_cycle, uint32_t& ort_num); @@ -720,7 +743,7 @@ namespace Jack void RenderToJackPorts(); //network<->buffer - void RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num); + int RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num); int RenderToNetwork(int sub_cycle, uint32_t& port_num); }; @@ -769,7 +792,7 @@ namespace Jack void RenderToJackPorts(); //network<->buffer - void RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num); + int RenderFromNetwork(int cycle, int sub_cycle, size_t copy_size, uint32_t port_num); int RenderToNetwork(int sub_cycle, uint32_t& port_num); }; diff --git a/common/JackServerGlobals.cpp b/common/JackServerGlobals.cpp index 00127fa6..04496f5c 100644 --- a/common/JackServerGlobals.cpp +++ b/common/JackServerGlobals.cpp @@ -84,7 +84,7 @@ void JackServerGlobals::Delete() int status; int refnum = (*it2).second; if (refnum > 0) { - // Client object is internally kept in JackEngine, and will be desallocated in InternalClientUnload + // Client object is internally kept in JackEngine, and will be deallocated in InternalClientUnload fInstance->GetEngine()->InternalClientUnload(refnum, &status); } } diff --git a/macosx/JackMachSemaphore.cpp b/macosx/JackMachSemaphore.cpp index f4b129c8..8d00b7e6 100644 --- a/macosx/JackMachSemaphore.cpp +++ b/macosx/JackMachSemaphore.cpp @@ -12,7 +12,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License -along with this program; if not, write to the Free Software +along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -38,7 +38,7 @@ void JackMachSemaphore::BuildName(const char* client_name, const char* server_na bool JackMachSemaphore::Signal() { if (!fSemaphore) { - jack_error("JackMachSemaphore::Signal name = %s already desallocated!!", fName); + jack_error("JackMachSemaphore::Signal name = %s already deallocated!!", fName); return false; } @@ -55,13 +55,13 @@ bool JackMachSemaphore::Signal() bool JackMachSemaphore::SignalAll() { if (!fSemaphore) { - jack_error("JackMachSemaphore::SignalAll name = %s already desallocated!!", fName); + jack_error("JackMachSemaphore::SignalAll name = %s already deallocated!!", fName); return false; } if (fFlush) return true; - + kern_return_t res; // When signaled several times, do not accumulate signals... if ((res = semaphore_signal_all(fSemaphore)) != KERN_SUCCESS) { @@ -73,7 +73,7 @@ bool JackMachSemaphore::SignalAll() bool JackMachSemaphore::Wait() { if (!fSemaphore) { - jack_error("JackMachSemaphore::Wait name = %s already desallocated!!", fName); + jack_error("JackMachSemaphore::Wait name = %s already deallocated!!", fName); return false; } @@ -87,10 +87,10 @@ bool JackMachSemaphore::Wait() bool JackMachSemaphore::TimedWait(long usec) { if (!fSemaphore) { - jack_error("JackMachSemaphore::TimedWait name = %s already desallocated!!", fName); + jack_error("JackMachSemaphore::TimedWait name = %s already deallocated!!", fName); return false; } - + kern_return_t res; mach_timespec time; time.tv_sec = usec / 1000000; diff --git a/posix/JackPosixSemaphore.cpp b/posix/JackPosixSemaphore.cpp index d151c5a4..0be9fdb5 100644 --- a/posix/JackPosixSemaphore.cpp +++ b/posix/JackPosixSemaphore.cpp @@ -40,7 +40,7 @@ bool JackPosixSemaphore::Signal() int res; if (!fSemaphore) { - jack_error("JackPosixSemaphore::Signal name = %s already desallocated!!", fName); + jack_error("JackPosixSemaphore::Signal name = %s already deallocated!!", fName); return false; } @@ -58,7 +58,7 @@ bool JackPosixSemaphore::SignalAll() int res; if (!fSemaphore) { - jack_error("JackPosixSemaphore::SignalAll name = %s already desallocated!!", fName); + jack_error("JackPosixSemaphore::SignalAll name = %s already deallocated!!", fName); return false; } @@ -77,7 +77,7 @@ bool JackPosixSemaphore::Wait() int res; if (!fSemaphore) { - jack_error("JackPosixSemaphore::Wait name = %s already desallocated!!", fName); + jack_error("JackPosixSemaphore::Wait name = %s already deallocated!!", fName); return false; } @@ -102,14 +102,14 @@ bool JackPosixSemaphore::Wait() #if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) // glibc feature test -bool JackPosixSemaphore::TimedWait(long usec) +bool JackPosixSemaphore::TimedWait(long usec) { int res; struct timeval now; timespec time; if (!fSemaphore) { - jack_error("JackPosixSemaphore::TimedWait name = %s already desallocated!!", fName); + jack_error("JackPosixSemaphore::TimedWait name = %s already deallocated!!", fName); return false; } gettimeofday(&now, 0); @@ -155,7 +155,7 @@ bool JackPosixSemaphore::Allocate(const char* name, const char* server_name, int bool JackPosixSemaphore::ConnectInput(const char* name, const char* server_name) { BuildName(name, server_name, fName); - jack_log("JackPosixSemaphore::Connect %s", fName); + jack_log("JackPosixSemaphore::Connect name = %s", fName); // Temporary... if (fSemaphore) { @@ -187,7 +187,7 @@ bool JackPosixSemaphore::ConnectOutput(const char* name, const char* server_name bool JackPosixSemaphore::Disconnect() { if (fSemaphore) { - jack_log("JackPosixSemaphore::Disconnect %s", fName); + jack_log("JackPosixSemaphore::Disconnect name = %s", fName); if (sem_close(fSemaphore) != 0) { jack_error("Disconnect: can't disconnect named semaphore name = %s err = %s", fName, strerror(errno)); return false; @@ -204,7 +204,7 @@ bool JackPosixSemaphore::Disconnect() void JackPosixSemaphore::Destroy() { if (fSemaphore != NULL) { - jack_log("JackPosixSemaphore::Destroy"); + jack_log("JackPosixSemaphore::Destroy name = %s", fName); sem_unlink(fName); if (sem_close(fSemaphore) != 0) { jack_error("Destroy: can't destroy semaphore name = %s err = %s", fName, strerror(errno)); diff --git a/windows/JackWinNamedPipeServerChannel.cpp b/windows/JackWinNamedPipeServerChannel.cpp index 8b3bbdc5..a60c826a 100644 --- a/windows/JackWinNamedPipeServerChannel.cpp +++ b/windows/JackWinNamedPipeServerChannel.cpp @@ -71,7 +71,7 @@ void JackClientPipeThread::Close() // Close /* TODO : solve WIN32 thread Kill issue This would hang.. since Close will be followed by a delete, - all ressources will be desallocated at the end. + all ressources will be deallocated at the end. */ fThread.Kill(); @@ -478,7 +478,7 @@ void JackWinNamedPipeServerChannel::Close() { /* TODO : solve WIN32 thread Kill issue This would hang the server... since we are quitting it, its not really problematic, - all ressources will be desallocated at the end. + all ressources will be deallocated at the end. fRequestListenPipe.Close(); fThread.Stop();