From cc80ecb685f8ed4bd9e9d8031b897ef77899fc8d Mon Sep 17 00:00:00 2001 From: sletz Date: Fri, 26 Oct 2007 14:44:59 +0000 Subject: [PATCH] Cleanup old zombification code. git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1664 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 1 + common/JackClient.cpp | 6 +-- common/JackClientControl.h | 2 - common/JackEngine.cpp | 59 +----------------------- common/JackEngine.h | 9 +--- common/JackNotification.h | 3 +- common/JackServer.cpp | 4 -- macosx/Jackdmp.xcodeproj/project.pbxproj | 10 +++- tests/jack_test.cpp | 2 +- 9 files changed, 16 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ef40f11..ae12c763 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ Tom Szilagyi 2007-10-26 Stephane Letz * Add midiseq and midisine examples. + * Cleanup old zombification code. 2007-10-25 Stephane Letz diff --git a/common/JackClient.cpp b/common/JackClient.cpp index 99c90c53..9ab42884 100644 --- a/common/JackClient.cpp +++ b/common/JackClient.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "JackEngineControl.h" #include "JackGlobals.h" #include "JackChannel.h" -#include "JackTransportEngine.h" +#include "JackTransportEngine.h" #include "driver_interface.h" #include #include @@ -210,10 +210,6 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, res = fXrun(fXrunArg); break; - case kZombifyClient: - JackLog("JackClient::kZombifyClient name = %s ref = %ld \n", name, refnum); - ShutDown(); - break; } } diff --git a/common/JackClientControl.h b/common/JackClientControl.h index 3ad14f0f..e4be0727 100644 --- a/common/JackClientControl.h +++ b/common/JackClientControl.h @@ -40,7 +40,6 @@ struct JackClientControl : public JackShmMem bool fCallback[kMaxNotification]; volatile jack_transport_state_t fTransportState; int fRefNum; - bool fZombie; bool fActive; JackClientControl(const char* name, int refnum) @@ -69,7 +68,6 @@ struct JackClientControl : public JackShmMem fCallback[kActivateClient] = true; fRefNum = refnum; fTransportState = JackTransportStopped; - fZombie = false; fActive = false; } diff --git a/common/JackEngine.cpp b/common/JackEngine.cpp index 912d6495..7bf80291 100644 --- a/common/JackEngine.cpp +++ b/common/JackEngine.cpp @@ -160,8 +160,7 @@ bool JackEngine::Process(jack_time_t callback_usecs) JackLog("Process: graph not finished!\n"); if (callback_usecs > fLastSwitchUsecs + fEngineControl->fTimeOutUsecs) { JackLog("Process: switch to next state delta = %ld\n", long(callback_usecs - fLastSwitchUsecs)); - //RemoveZombifiedClients(callback_usecs); TODO - ProcessNext(callback_usecs); + ProcessNext(callback_usecs); res = true; } else { JackLog("Process: waiting to switch delta = %ld\n", long(callback_usecs - fLastSwitchUsecs)); @@ -192,71 +191,17 @@ void JackEngine::CheckXRun(jack_time_t callback_usecs) // REVOIR les conditions if (status != NotTriggered && status != Finished) { jack_error("JackEngine::XRun: client = %s was not run: state = %ld", client->GetClientControl()->fName, status); - //fChannel->ClientNotify(i, kXRunCallback, 0); // Notify the failing client fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients } + if (status == Finished && (long)(finished_date - callback_usecs) > 0) { jack_error("JackEngine::XRun: client %s finished after current callback", client->GetClientControl()->fName); - //fChannel->ClientNotify(i, kXRunCallback, 0); // Notify the failing client fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients } } } } -//--------------- -// Zombification -//--------------- - -bool JackEngine::IsZombie(JackClientInterface* client, jack_time_t current_time) -{ - return ((current_time - fGraphManager->GetClientTiming(client->GetClientControl()->fRefNum)->fFinishedAt) > 2 * fEngineControl->fTimeOutUsecs); // A VERIFIER -} - -// TODO : check what happens with looped sub-graph.... -void JackEngine::GetZombifiedClients(bool zombi_clients[CLIENT_NUM], jack_time_t current_time) -{ - for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) { - JackClientInterface* client1 = fClientTable[i]; - if (client1 && IsZombie(client1, current_time)) { - JackLog("JackEngine::GetZombifiedClients: %s\n", client1->GetClientControl()->fName); - zombi_clients[i] = true; // Assume client is dead - // If another dead client is connected to the scanned one, then the scanned one is not the first of the dead subgraph - for (int j = REAL_REFNUM; j < CLIENT_NUM; j++) { - JackClientInterface* client2 = fClientTable[j]; - if (client2 && IsZombie(client2, current_time) && fGraphManager->IsDirectConnection(j, i)) { - zombi_clients[i] = false; - break; - } - } - } else { - zombi_clients[i] = false; - } - } -} - -void JackEngine::RemoveZombifiedClients(jack_time_t current_time) -{ - bool zombi_clients[CLIENT_NUM]; - GetZombifiedClients(zombi_clients, current_time); - - for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) { - if (zombi_clients[i] && !fClientTable[i]->GetClientControl()->fZombie) { - fClientTable[i]->GetClientControl()->fZombie = true; - JackLog("RemoveZombifiedCients: name = %s\n", fClientTable[i]->GetClientControl()->fName); - fGraphManager->DirectDisconnect(FREEWHEEL_DRIVER_REFNUM, i); - fGraphManager->DirectDisconnect(i, FREEWHEEL_DRIVER_REFNUM); - fGraphManager->DisconnectAllPorts(i); - fChannel->ClientNotify(i, kZombifyClient, 0); // Signal engine - } - } -} - -void JackEngine::ZombifyClient(int refnum) -{ - NotifyClient(refnum, kZombifyClient, false, 0); -} - //--------------- // Notifications //--------------- diff --git a/common/JackEngine.h b/common/JackEngine.h index b55eddc7..ac7900b8 100644 --- a/common/JackEngine.h +++ b/common/JackEngine.h @@ -55,11 +55,7 @@ class JackEngine int NotifyAddClient(JackClientInterface* new_client, const char* name, int refnum); void NotifyRemoveClient(const char* name, int refnum); - - bool IsZombie(JackClientInterface* client, jack_time_t current_time); - void RemoveZombifiedClients(jack_time_t current_time); - void GetZombifiedClients(bool clients[CLIENT_NUM], jack_time_t current_time); - + void ProcessNext(jack_time_t callback_usecs); void ProcessCurrent(jack_time_t callback_usecs); @@ -109,8 +105,7 @@ class JackEngine // Graph bool Process(jack_time_t callback_usecs); - void ZombifyClient(int refnum); - + // Notifications void NotifyClient(int refnum, int event, int sync, int value); void NotifyClients(int event, int sync, int value); diff --git a/common/JackNotification.h b/common/JackNotification.h index 850418f2..40261e5b 100644 --- a/common/JackNotification.h +++ b/common/JackNotification.h @@ -33,8 +33,7 @@ namespace Jack kStopFreewheelCallback = 7, kPortRegistrationOnCallback = 8, kPortRegistrationOffCallback = 9, - kZombifyClient = 10, - kDeadClient = 11, + kDeadClient = 10, kMaxNotification }; diff --git a/common/JackServer.cpp b/common/JackServer.cpp index 1a116cf7..88b52560 100644 --- a/common/JackServer.cpp +++ b/common/JackServer.cpp @@ -287,10 +287,6 @@ void JackServer::Notify(int refnum, int notify, int value) fEngine->NotifyXRun(refnum); break; - case kZombifyClient: - fEngine->ZombifyClient(refnum); - break; - case kDeadClient: JackLog("JackServer: kDeadClient ref = %ld\n", refnum); if (fEngine->ClientDeactivate(refnum) < 0) diff --git a/macosx/Jackdmp.xcodeproj/project.pbxproj b/macosx/Jackdmp.xcodeproj/project.pbxproj index 8af2349c..706d2043 100644 --- a/macosx/Jackdmp.xcodeproj/project.pbxproj +++ b/macosx/Jackdmp.xcodeproj/project.pbxproj @@ -312,14 +312,14 @@ isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; proxyType = 1; - remoteGlobalIDString = 4B5A1BB10CD1CB9E0005BF74 /* jack_midiseq */; + remoteGlobalIDString = 4B5A1BB10CD1CB9E0005BF74; remoteInfo = jack_midiseq; }; 4B5A1BE10CD1CD730005BF74 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; proxyType = 1; - remoteGlobalIDString = 4B5A1BD00CD1CCE10005BF74 /* jack_midisine */; + remoteGlobalIDString = 4B5A1BD00CD1CCE10005BF74; remoteInfo = jack_midisine; }; 4B699DB3097D421700A18468 /* PBXContainerItemProxy */ = { @@ -520,6 +520,9 @@ 4B5A1BBD0CD1CC110005BF74 /* midiseq.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = midiseq.c; path = "../example-clients/midiseq.c"; sourceTree = SOURCE_ROOT; }; 4B5A1BDA0CD1CCE10005BF74 /* jack_midisine */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jack_midisine; sourceTree = BUILT_PRODUCTS_DIR; }; 4B5A1BDC0CD1CD420005BF74 /* midisine.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = midisine.c; path = "../example-clients/midisine.c"; sourceTree = SOURCE_ROOT; }; + 4B5A1D3C0CD1F4990005BF74 /* FadeConnect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = FadeConnect.cpp; path = "../example-clients/FadeConnect.cpp"; sourceTree = SOURCE_ROOT; }; + 4B5A1D3D0CD1F4990005BF74 /* FadeConnect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FadeConnect.h; path = "../example-clients/FadeConnect.h"; sourceTree = SOURCE_ROOT; }; + 4B5A1D700CD1F63F0005BF74 /* fade_connect.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = fade_connect.cpp; path = "../example-clients/fade_connect.cpp"; sourceTree = SOURCE_ROOT; }; 4B60CE480AAABA31004956AA /* connect.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = connect.c; path = "../example-clients/connect.c"; sourceTree = SOURCE_ROOT; }; 4B66A8580934964500A89560 /* JackConstants.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = JackConstants.h; path = ../common/JackConstants.h; sourceTree = SOURCE_ROOT; }; 4B699BB1097D421600A18468 /* jackdmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jackdmp; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -959,6 +962,9 @@ 4B03383E0797E19900686131 /* Simple clients */ = { isa = PBXGroup; children = ( + 4B5A1D700CD1F63F0005BF74 /* fade_connect.cpp */, + 4B5A1D3C0CD1F4990005BF74 /* FadeConnect.cpp */, + 4B5A1D3D0CD1F4990005BF74 /* FadeConnect.h */, 4B5A1BDC0CD1CD420005BF74 /* midisine.c */, 4B5A1BBD0CD1CC110005BF74 /* midiseq.c */, 4BA692D60CBE4CC600EAD520 /* ipunload.c */, diff --git a/tests/jack_test.cpp b/tests/jack_test.cpp index 60e6a007..98bfa4d6 100644 --- a/tests/jack_test.cpp +++ b/tests/jack_test.cpp @@ -480,7 +480,7 @@ int main (int argc, char *argv[]) const char *options = "kRnqvt:"; float ratio; // for speed calculation in freewheel mode jack_options_t jack_options = JackNullOption; - struct option long_options[] = { + struct option long_options[] = { {"realtime", 0, 0, 'R'}, {"non-realtime", 0, 0, 'n'}, {"time", 0, 0, 't'},