From d6b65585bf30c493c4eaf52547f4bcc484e881a5 Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 10 Jun 2011 12:48:51 +0000 Subject: [PATCH] SaveConnections/RestoreConnections in NetDriver. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4453 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 32 ++++++++++++++++++++++ common/JackNetDriver.cpp | 58 ++++++++++++++++++++++++++++++++++++++++ common/JackNetDriver.h | 9 +++++-- 3 files changed, 97 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec1260f9..3a33e237 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,38 @@ Chris Caudle Jackdmp changes log --------------------------- +2011-06-10 Stephane Letz + + * SaveConnections/RestoreConnections in NetDriver. + +2011-06-09 Stephane Letz + + * Correct NetJack2 connection handling + +2011-05-27 Stephane Letz + + * Correct rd_acquire in dbus code. + +2011-05-16 Stephane Letz + + * Correct OSX real-time thread setup. + +2011-05-11 Stephane Letz + + * Correct MIDI in NetJack2. + +2011-05-05 Stephane Letz + + * Libjacknet in progress. + +2011-05-02 Stephane Letz + + * Merge branch 'switch-master-port-registration-notifications : correct driver port registration. + +2011-04-21 Stephane Letz + + * CELT code for NetJack2. + 2011-04-20 Stephane Letz * Add XRun detection in PortAudio driver. diff --git a/common/JackNetDriver.cpp b/common/JackNetDriver.cpp index 8b3753d9..cdde0abb 100644 --- a/common/JackNetDriver.cpp +++ b/common/JackNetDriver.cpp @@ -121,6 +121,7 @@ namespace Jack bool JackNetDriver::Initialize() { jack_log("JackNetDriver::Initialize()"); + SaveConnections(); FreePorts(); //new loading, but existing socket, restart the driver @@ -223,6 +224,8 @@ namespace Jack //transport engine parametering fEngineControl->fTransport.SetNetworkSync(fParams.fTransportSync); + + RestoreConnections(); return true; } @@ -405,6 +408,61 @@ namespace Jack return 0; } + void JackNetDriver::SaveConnections() + { + const char** connections; + fConnections.clear(); + + for (int i = 0; i < fCaptureChannels; ++i) { + if (fCapturePortList[i] && (connections = fGraphManager->GetConnections(fCapturePortList[i])) != 0) { + for (int j = 0; connections[j]; j++) { + fConnections.push_back(make_pair(fGraphManager->GetPort(fCapturePortList[i])->GetName(), connections[j])); + jack_info("Save connection: %s %s", fGraphManager->GetPort(fCapturePortList[i])->GetName(), connections[j]); + } + free(connections); + } + } + + for (int i = 0; i < fPlaybackChannels; ++i) { + if (fPlaybackPortList[i] && (connections = fGraphManager->GetConnections(fPlaybackPortList[i])) != 0) { + for (int j = 0; connections[j]; j++) { + fConnections.push_back(make_pair(connections[j], fGraphManager->GetPort(fPlaybackPortList[i])->GetName())); + jack_info("Save connection: %s %s", connections[j], fGraphManager->GetPort(fPlaybackPortList[i])->GetName()); + } + free(connections); + } + } + + for (int i = 0; i < fParams.fSendMidiChannels; ++i) { + if (fCapturePortList[i] && (connections = fGraphManager->GetConnections(fMidiCapturePortList[i])) != 0) { + for (int j = 0; connections[j]; j++) { + fConnections.push_back(make_pair(fGraphManager->GetPort(fMidiCapturePortList[i])->GetName(), connections[j])); + } + free(connections); + } + } + + for (int i = 0; i < fParams.fReturnMidiChannels; ++i) { + if (fPlaybackPortList[i] && (connections = fGraphManager->GetConnections(fMidiPlaybackPortList[i])) != 0) { + for (int j = 0; connections[j]; j++) { + fConnections.push_back(make_pair(connections[j], fGraphManager->GetPort(fMidiPlaybackPortList[i])->GetName())); + } + free(connections); + } + } + } + + void JackNetDriver::RestoreConnections() + { + list >::const_iterator it; + + for (it = fConnections.begin(); it != fConnections.end(); it++) { + pair connection = *it; + jack_info("Restore connection: %s %s", connection.first.c_str(), connection.second.c_str()); + fEngine->PortConnect(fClientControl.fRefNum, connection.first.c_str(), connection.second.c_str()); + } + } + JackMidiBuffer* JackNetDriver::GetMidiInputBuffer(int port_index) { return static_cast(fGraphManager->GetBuffer(fMidiCapturePortList[port_index], fEngineControl->fBufferSize)); diff --git a/common/JackNetDriver.h b/common/JackNetDriver.h index 2cb75843..f70039ac 100644 --- a/common/JackNetDriver.h +++ b/common/JackNetDriver.h @@ -47,6 +47,8 @@ namespace Jack int fLastTransportState; int fLastTimebaseMaster; + std::list > fConnections; // Connections list + //monitoring #ifdef JACK_MONITOR JackGnuPlotMonitor* fNetTimeMon; @@ -63,8 +65,11 @@ namespace Jack void EncodeTransportData(); void DecodeTransportData(); - JackMidiBuffer* GetMidiInputBuffer ( int port_index ); - JackMidiBuffer* GetMidiOutputBuffer ( int port_index ); + JackMidiBuffer* GetMidiInputBuffer(int port_index); + JackMidiBuffer* GetMidiOutputBuffer(int port_index); + + void SaveConnections(); + void RestoreConnections(); public: