From 319a95c629b3faa522669dbbae3620d3ec0bb927 Mon Sep 17 00:00:00 2001 From: sletz Date: Wed, 25 Feb 2009 08:31:30 +0000 Subject: [PATCH] Fix JackNetDriver::Close method. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3347 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 4 ++++ common/JackNetDriver.cpp | 35 ++++++++++++++++++--------------- common/JackNetDriver.h | 6 ++---- common/JackWaitThreadedDriver.h | 2 +- 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe9fc6f5..2e42e82d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,10 @@ Michael Voigt --------------------------- Jackdmp changes log --------------------------- + +2009-02-25 Stephane Letz + + * Fix JackNetDriver::Close method. 2009-02-23 Stephane Letz diff --git a/common/JackNetDriver.cpp b/common/JackNetDriver.cpp index 5b17afb4..c1b9d30d 100644 --- a/common/JackNetDriver.cpp +++ b/common/JackNetDriver.cpp @@ -91,14 +91,15 @@ namespace Jack } } -#ifdef JACK_MONITOR int JackNetDriver::Close() { +#ifdef JACK_MONITOR if ( fNetTimeMon ) fNetTimeMon->Save(); +#endif + FreeAll(); return JackDriver::Close(); } -#endif // Attach and Detach are defined as empty methods: port allocation is done when driver actually start (that is in Init) int JackNetDriver::Attach() @@ -122,8 +123,10 @@ namespace Jack jack_log ( "JackNetDriver::Init()" ); //new loading, but existing socket, restart the driver - if ( fSocket.IsSocket() ) - Restart(); + if (fSocket.IsSocket()) { + jack_info( "Restarting driver..." ); + FreeAll(); + } //set the parameters to send fParams.fSendAudioChannels = fCaptureChannels; @@ -206,28 +209,28 @@ namespace Jack return true; } - void JackNetDriver::Restart() + void JackNetDriver::FreeAll() { - jack_log ( "JackNetDriver::Restart" ); - - jack_info ( "Restarting driver..." ); + FreePorts(); + delete[] fTxBuffer; - fTxBuffer = NULL; delete[] fRxBuffer; - fRxBuffer = NULL; delete fNetAudioCaptureBuffer; - fNetAudioCaptureBuffer = NULL; delete fNetAudioPlaybackBuffer; - fNetAudioPlaybackBuffer = NULL; delete fNetMidiCaptureBuffer; - fNetMidiCaptureBuffer = NULL; delete fNetMidiPlaybackBuffer; - fNetMidiPlaybackBuffer = NULL; - FreePorts(); delete[] fMidiCapturePortList; - fMidiCapturePortList = NULL; delete[] fMidiPlaybackPortList; + + fTxBuffer = NULL; + fRxBuffer = NULL; + fNetAudioCaptureBuffer = NULL; + fNetAudioPlaybackBuffer = NULL; + fNetMidiCaptureBuffer = NULL; + fNetMidiPlaybackBuffer = NULL; + fMidiCapturePortList = NULL; fMidiPlaybackPortList = NULL; + #ifdef JACK_MONITOR delete fNetTimeMon; fNetTimeMon = NULL; diff --git a/common/JackNetDriver.h b/common/JackNetDriver.h index 9aced551..af432084 100644 --- a/common/JackNetDriver.h +++ b/common/JackNetDriver.h @@ -51,7 +51,8 @@ namespace Jack #endif bool Init(); - void Restart(); + void FreeAll(); + int AllocPorts(); int FreePorts(); @@ -71,10 +72,7 @@ namespace Jack int Open ( jack_nframes_t frames_per_cycle, jack_nframes_t rate, bool capturing, bool playing, int inchannels, int outchannels, bool monitor, const char* capture_driver_name, const char* playback_driver_name, jack_nframes_t capture_latency, jack_nframes_t playback_latency ); - -#ifdef JACK_MONITOR int Close(); -#endif int Attach(); int Detach(); diff --git a/common/JackWaitThreadedDriver.h b/common/JackWaitThreadedDriver.h index 93dc3536..876b6551 100644 --- a/common/JackWaitThreadedDriver.h +++ b/common/JackWaitThreadedDriver.h @@ -31,7 +31,7 @@ namespace Jack \brief To be used as a wrapper of JackNetDriver. The idea is to behave as the "dummy" driver, until the network connection is really started and processing starts. -The Execute method will call the ProcessNull() methods until the decorated driver Init method returns. +The Execute method will call the ProcessNull method until the decorated driver Init method returns. A helper JackDriverStarter thread is used for that purpose. */