From 299bea3a5ff07ad3472dbc0e8a9e60865eaa2804 Mon Sep 17 00:00:00 2001 From: sletz Date: Tue, 19 Jul 2011 13:44:55 +0000 Subject: [PATCH 1/7] Remove compilation warnings. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4495 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 64 +++++++++++++++++++-------------------- common/JackFrameTimer.cpp | 2 +- common/JackNetAPI.cpp | 62 ++++++++++++++++++------------------- common/JackNetTool.cpp | 26 ++++++++-------- common/JackNetTool.h | 7 +++-- 5 files changed, 80 insertions(+), 81 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28973d3f..7d487a17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -78,12 +78,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 +96,7 @@ Chris Caudle 2011-06-09 Stephane Letz - * Correct NetJack2 connection handling + * Correct NetJack2 connection handling. 2011-05-27 Stephane Letz @@ -116,7 +116,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 +140,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 +238,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 +290,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 +337,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 +346,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 +388,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 +418,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 +426,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 +450,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 +496,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 +517,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 +598,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 +703,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 +918,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 +933,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 +942,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 +1059,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 +1132,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 +1159,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 +1185,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 +1195,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 +1224,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 +1265,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 +1455,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/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/JackNetTool.cpp b/common/JackNetTool.cpp index ad53f64e..11e77c99 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() diff --git a/common/JackNetTool.h b/common/JackNetTool.h index ac5b61b8..1fe94d91 100644 --- a/common/JackNetTool.h +++ b/common/JackNetTool.h @@ -366,7 +366,7 @@ namespace Jack fPortBuffer = 0; } - ~JackPortList() + virtual ~JackPortList() { delete [] fPortBuffer; } @@ -506,6 +506,9 @@ namespace Jack :JackPortList(params, nports) {} + virtual ~JackOptimizedPortList() + {} + int GetNumPackets() { // Count active ports @@ -554,8 +557,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); From 620e0b84d67ad19d7a9cbee2597123c49440f5bb Mon Sep 17 00:00:00 2001 From: sletz Date: Tue, 19 Jul 2011 15:24:36 +0000 Subject: [PATCH 2/7] A bit more explicit debug messages. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4496 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackControlAPI.cpp | 2 +- common/JackServerGlobals.cpp | 2 +- macosx/JackMachSemaphore.cpp | 14 +++++++------- posix/JackPosixSemaphore.cpp | 16 ++++++++-------- windows/JackWinNamedPipeServerChannel.cpp | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) 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/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 fd5a8eda..de2fd397 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(); @@ -479,7 +479,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(); From 0ce0e6403fb284abffd672ed829064dca0c5bdb9 Mon Sep 17 00:00:00 2001 From: sletz Date: Thu, 21 Jul 2011 13:54:18 +0000 Subject: [PATCH 3/7] Fix for 64/32 bits compilation. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4497 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackNetDriver.cpp | 2 +- common/JackNetManager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/JackNetDriver.cpp b/common/JackNetDriver.cpp index 38fe48e7..f8601f4b 100644 --- a/common/JackNetDriver.cpp +++ b/common/JackNetDriver.cpp @@ -576,7 +576,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 ((uintptr_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/JackNetManager.cpp b/common/JackNetManager.cpp index 7601acdd..4a4a8167 100644 --- a/common/JackNetManager.cpp +++ b/common/JackNetManager.cpp @@ -431,7 +431,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 ((uintptr_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], From 18c15616dd4541cdaca55888b9b8b3b214eee9c7 Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 22 Jul 2011 14:24:08 +0000 Subject: [PATCH 4/7] NetJack2: improve error reporting. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4498 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 4 ++++ common/JackAPI.cpp | 6 +++--- common/JackNetDriver.cpp | 7 ++++++- common/JackNetInterface.cpp | 10 +++++----- common/JackNetManager.cpp | 18 ++++++++++++++---- common/JackNetTool.cpp | 22 ++++++++++++++++------ common/JackNetTool.h | 31 ++++++++++++++++++++++++------- 7 files changed, 72 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d487a17..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. 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/JackNetDriver.cpp b/common/JackNetDriver.cpp index f8601f4b..46efba12 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(); diff --git a/common/JackNetInterface.cpp b/common/JackNetInterface.cpp index f379db27..45b9f507 100644 --- a/common/JackNetInterface.cpp +++ b/common/JackNetInterface.cpp @@ -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 4a4a8167..2d7aa5e9 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() @@ -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 11e77c99..36e78ef7 100644 --- a/common/JackNetTool.cpp +++ b/common/JackNetTool.cpp @@ -230,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) @@ -445,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); @@ -455,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 = 1; + } fLastSubCycle = sub_cycle; + return res; } int NetCeltAudioBuffer::RenderToNetwork(int sub_cycle, uint32_t& port_num) @@ -575,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); @@ -585,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 = -1; + } 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 1fe94d91..e339ae45 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; @@ -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 = -1; } + 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 = -1; } + fLastSubCycle = sub_cycle; + return res; } virtual int RenderToNetwork(char* net_buffer, int sub_cycle, uint32_t& port_num) @@ -535,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++) { @@ -567,8 +581,11 @@ namespace Jack if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); + res = -1; } + fLastSubCycle = sub_cycle; + return res; } } @@ -664,7 +681,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); @@ -721,7 +738,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); }; @@ -770,7 +787,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); }; From 0b4e9a2a2f0e8ead921eb6ff583319fc0d4db58e Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 22 Jul 2011 14:26:55 +0000 Subject: [PATCH 5/7] Correct warning. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4499 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackNetDriver.cpp | 2 +- common/JackNetManager.cpp | 2 +- common/JackNetTool.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/JackNetDriver.cpp b/common/JackNetDriver.cpp index 46efba12..2855fb17 100644 --- a/common/JackNetDriver.cpp +++ b/common/JackNetDriver.cpp @@ -581,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 ((uintptr_t)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/JackNetManager.cpp b/common/JackNetManager.cpp index 2d7aa5e9..a0c14de3 100644 --- a/common/JackNetManager.cpp +++ b/common/JackNetManager.cpp @@ -437,7 +437,7 @@ namespace Jack for (int audio_port_index = 0; audio_port_index < fParams.fSendAudioChannels; audio_port_index++) { #ifdef OPTIMIZED_PROTOCOL - if ((uintptr_t)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], diff --git a/common/JackNetTool.h b/common/JackNetTool.h index e339ae45..844ed0b8 100644 --- a/common/JackNetTool.h +++ b/common/JackNetTool.h @@ -585,8 +585,9 @@ namespace Jack } fLastSubCycle = sub_cycle; - return res; } + + return res; } virtual int RenderToNetwork(char* net_buffer,int sub_cycle, uint32_t& port_num) From 73de093ca97c1843110b7247a98d5d0e23c52e7c Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 22 Jul 2011 14:37:15 +0000 Subject: [PATCH 6/7] Correct error code. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4500 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackNetTool.cpp | 4 ++-- common/JackNetTool.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/JackNetTool.cpp b/common/JackNetTool.cpp index 36e78ef7..791af963 100644 --- a/common/JackNetTool.cpp +++ b/common/JackNetTool.cpp @@ -459,7 +459,7 @@ namespace Jack if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); - res = 1; + res = NET_PACKET_ERROR; } fLastSubCycle = sub_cycle; @@ -594,7 +594,7 @@ namespace Jack if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); - res = -1; + res = NET_PACKET_ERROR; } fLastSubCycle = sub_cycle; diff --git a/common/JackNetTool.h b/common/JackNetTool.h index 844ed0b8..e78b4ea5 100644 --- a/common/JackNetTool.h +++ b/common/JackNetTool.h @@ -439,7 +439,7 @@ namespace Jack } if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); - res = -1; + res = NET_PACKET_ERROR; } fLastSubCycle = sub_cycle; @@ -481,7 +481,7 @@ namespace Jack } if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); - res = -1; + res = NET_PACKET_ERROR; } fLastSubCycle = sub_cycle; @@ -581,7 +581,7 @@ namespace Jack if (sub_cycle != fLastSubCycle + 1) { jack_error("Packet(s) missing from... %d %d", fLastSubCycle, sub_cycle); - res = -1; + res = NET_PACKET_ERROR; } fLastSubCycle = sub_cycle; From bf94bee63310d77f4ac341701d0fa513132dc992 Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 22 Jul 2011 20:15:42 +0000 Subject: [PATCH 7/7] More robust ActivePortsFromNetwork. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4501 0c269be4-1314-0410-8aa9-9f06e86f4224 --- common/JackNetInterface.cpp | 2 +- common/JackNetTool.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/JackNetInterface.cpp b/common/JackNetInterface.cpp index 45b9f507..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; } diff --git a/common/JackNetTool.h b/common/JackNetTool.h index e78b4ea5..375aa376 100644 --- a/common/JackNetTool.h +++ b/common/JackNetTool.h @@ -637,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++; } }