git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1490 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.64
| @@ -135,7 +135,8 @@ class JackNotifyChannelInterface | |||
| virtual void ClientNotify(int refnum, const char* name, int notify, int sync, int value, int* result) | |||
| {} | |||
| typedef enum { | |||
| /* | |||
| enum NotificationType { | |||
| kAddClient = 0, | |||
| kRemoveClient = 1, | |||
| kActivateClient = 2, | |||
| @@ -147,9 +148,10 @@ class JackNotifyChannelInterface | |||
| kPortRegistrationOn = 8, | |||
| kPortRegistrationOff = 9, | |||
| kZombifyClient = 10, | |||
| kDeadClient = 11 | |||
| } NotificationType; | |||
| kDeadClient = 11, | |||
| kMaxType | |||
| }; | |||
| */ | |||
| }; | |||
| /*! | |||
| @@ -129,15 +129,15 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||
| // Done all time: redirected on subclass implementation JackLibClient and JackInternalClient | |||
| switch (notify) { | |||
| case JackNotifyChannelInterface::kAddClient: | |||
| case kAddClient: | |||
| res = ClientNotifyImp(refnum, name, notify, sync, value); | |||
| break; | |||
| case JackNotifyChannelInterface::kRemoveClient: | |||
| case kRemoveClient: | |||
| res = ClientNotifyImp(refnum, name, notify, sync, value); | |||
| break; | |||
| case JackNotifyChannelInterface::kActivateClient: | |||
| case kActivateClient: | |||
| JackLog("JackClient::kActivateClient name = %s ref = %ld \n", name, refnum); | |||
| Init(); | |||
| break; | |||
| @@ -151,31 +151,31 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||
| switch (notify) { | |||
| case JackNotifyChannelInterface::kAddClient: | |||
| case kAddClient: | |||
| JackLog("JackClient::kAddClient fName = %s name = %s\n", GetClientControl()->fName, name); | |||
| if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) // Don't call the callback for the registering client itself | |||
| fClientRegistration(name, 1, fClientRegistrationArg); | |||
| break; | |||
| case JackNotifyChannelInterface::kRemoveClient: | |||
| case kRemoveClient: | |||
| JackLog("JackClient::kRemoveClient fName = %s name = %s\n", GetClientControl()->fName, name); | |||
| if (fClientRegistration && strcmp(GetClientControl()->fName, name) != 0) // Don't call the callback for the registering client itself | |||
| fClientRegistration(name, 0, fClientRegistrationArg); | |||
| break; | |||
| case JackNotifyChannelInterface::kBufferSizeCallback: | |||
| case kBufferSizeCallback: | |||
| JackLog("JackClient::kBufferSizeCallback buffer_size = %ld\n", value); | |||
| if (fBufferSize) | |||
| res = fBufferSize(value, fBufferSizeArg); | |||
| break; | |||
| case JackNotifyChannelInterface::kGraphOrderCallback: | |||
| case kGraphOrderCallback: | |||
| JackLog("JackClient::kGraphOrderCallback\n"); | |||
| if (fGraphOrder) | |||
| res = fGraphOrder(fGraphOrderArg); | |||
| break; | |||
| case JackNotifyChannelInterface::kStartFreewheel: | |||
| case kStartFreewheel: | |||
| JackLog("JackClient::kStartFreewheel\n"); | |||
| SetupDriverSync(true); | |||
| fThread->DropRealTime(); | |||
| @@ -183,7 +183,7 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||
| fFreewheel(1, fFreewheelArg); | |||
| break; | |||
| case JackNotifyChannelInterface::kStopFreewheel: | |||
| case kStopFreewheel: | |||
| JackLog("JackClient::kStopFreewheel\n"); | |||
| SetupDriverSync(false); | |||
| if (fFreewheel) | |||
| @@ -191,25 +191,25 @@ int JackClient::ClientNotify(int refnum, const char* name, int notify, int sync, | |||
| fThread->AcquireRealTime(); | |||
| break; | |||
| case JackNotifyChannelInterface::kPortRegistrationOn: | |||
| case kPortRegistrationOn: | |||
| JackLog("JackClient::kPortRegistrationOn port_index = %ld\n", value); | |||
| if (fPortRegistration) | |||
| fPortRegistration(value, 1, fPortRegistrationArg); | |||
| break; | |||
| case JackNotifyChannelInterface::kPortRegistrationOff: | |||
| case kPortRegistrationOff: | |||
| JackLog("JackClient::kPortRegistrationOff port_index = %ld \n", value); | |||
| if (fPortRegistration) | |||
| fPortRegistration(value, 0, fPortRegistrationArg); | |||
| break; | |||
| case JackNotifyChannelInterface::kXRunCallback: | |||
| case kXRunCallback: | |||
| JackLog("JackClient::kXRunCallback\n"); | |||
| if (fXrun) | |||
| res = fXrun(fXrunArg); | |||
| break; | |||
| case JackNotifyChannelInterface::kZombifyClient: | |||
| case kZombifyClient: | |||
| JackLog("JackClient::kZombifyClient name = %s ref = %ld \n", name, refnum); | |||
| ShutDown(); | |||
| break; | |||
| @@ -24,6 +24,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| #include "JackShmMem.h" | |||
| #include "JackPort.h" | |||
| #include "JackSynchro.h" | |||
| #include "JackNotification.h" | |||
| #include "transport_types.h" | |||
| namespace Jack | |||
| @@ -36,6 +38,7 @@ namespace Jack | |||
| struct JackClientControl : public JackShmMem | |||
| { | |||
| char fName[JACK_CLIENT_NAME_SIZE + 1]; | |||
| bool fCallback[kMaxNotification]; | |||
| volatile jack_transport_state_t fTransportState; | |||
| int fRefNum; | |||
| bool fZombie; | |||
| @@ -59,6 +62,8 @@ struct JackClientControl : public JackShmMem | |||
| void Init(const char* name, int refnum) | |||
| { | |||
| strcpy(fName, name); | |||
| for (int i = 0; i < kMaxNotification; i++) | |||
| fCallback[i] = false; | |||
| fRefNum = refnum; | |||
| fTransportState = JackTransportStopped; | |||
| fZombie = false; | |||
| @@ -19,7 +19,7 @@ | |||
| #define PRINTDEBUG | |||
| #define VERSION "0.63" | |||
| #define VERSION "0.64" | |||
| #define FORK_SERVER 1 | |||
| @@ -113,7 +113,7 @@ void JackEngine::ProcessNext(jack_time_t callback_usecs) | |||
| { | |||
| fLastSwitchUsecs = callback_usecs; | |||
| if (fGraphManager->RunNextGraph()) // True if the graph actually switched to a new state | |||
| fChannel->ClientNotify(ALL_CLIENTS, JackNotifyChannelInterface::kGraphOrderCallback, 0); | |||
| fChannel->ClientNotify(ALL_CLIENTS, kGraphOrderCallback, 0); | |||
| fSignal->SignalAll(); // Signal for threads waiting for next cycle | |||
| } | |||
| @@ -176,12 +176,12 @@ 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, JackNotifyChannelInterface::kXRunCallback, 0); // Notify all clients | |||
| 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, JackNotifyChannelInterface::kXRunCallback, 0); // Notify all clients | |||
| fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0); // Notify all clients | |||
| } | |||
| } | |||
| } | |||
| @@ -230,14 +230,14 @@ void JackEngine::RemoveZombifiedClients(jack_time_t current_time) | |||
| fGraphManager->DirectDisconnect(FREEWHEEL_DRIVER_REFNUM, i); | |||
| fGraphManager->DirectDisconnect(i, FREEWHEEL_DRIVER_REFNUM); | |||
| fGraphManager->DisconnectAllPorts(i); | |||
| fChannel->ClientNotify(i, JackNotifyChannelInterface::kZombifyClient, 0); // Signal engine | |||
| fChannel->ClientNotify(i, kZombifyClient, 0); // Signal engine | |||
| } | |||
| } | |||
| } | |||
| void JackEngine::ZombifyClient(int refnum) | |||
| { | |||
| NotifyClient(refnum, JackNotifyChannelInterface::kZombifyClient, false, 0); | |||
| NotifyClient(refnum, kZombifyClient, false, 0); | |||
| } | |||
| //--------------- | |||
| @@ -272,11 +272,11 @@ int JackEngine::NotifyAddClient(JackClientInterface* new_client, const char* nam | |||
| for (int i = 0; i < CLIENT_NUM; i++) { | |||
| JackClientInterface* old_client = fClientTable[i]; | |||
| if (old_client) { | |||
| if (old_client->ClientNotify(refnum, name, JackNotifyChannelInterface::kAddClient, true, 0) < 0) { | |||
| if (old_client->ClientNotify(refnum, name, kAddClient, true, 0) < 0) { | |||
| jack_error("NotifyAddClient old_client fails name = %s", old_client->GetClientControl()->fName); | |||
| return -1; | |||
| } | |||
| if (new_client->ClientNotify(i, old_client->GetClientControl()->fName, JackNotifyChannelInterface::kAddClient, true, 0) < 0) { | |||
| if (new_client->ClientNotify(i, old_client->GetClientControl()->fName, kAddClient, true, 0) < 0) { | |||
| jack_error("NotifyAddClient new_client fails name = %s", name); | |||
| return -1; | |||
| } | |||
| @@ -292,7 +292,7 @@ void JackEngine::NotifyRemoveClient(const char* name, int refnum) | |||
| for (int i = 0; i < CLIENT_NUM; i++) { | |||
| JackClientInterface* client = fClientTable[i]; | |||
| if (client) { | |||
| client->ClientNotify(refnum, name, JackNotifyChannelInterface::kRemoveClient, true, 0); | |||
| client->ClientNotify(refnum, name, kRemoveClient, true, 0); | |||
| } | |||
| } | |||
| } | |||
| @@ -302,42 +302,42 @@ void JackEngine::NotifyXRun(jack_time_t callback_usecs) | |||
| { | |||
| // Use the audio thread => request thread communication channel | |||
| fEngineControl->ResetFrameTime(callback_usecs); | |||
| fChannel->ClientNotify(ALL_CLIENTS, JackNotifyChannelInterface::kXRunCallback, 0); | |||
| fChannel->ClientNotify(ALL_CLIENTS, kXRunCallback, 0); | |||
| } | |||
| void JackEngine::NotifyXRun(int refnum) | |||
| { | |||
| if (refnum == ALL_CLIENTS) { | |||
| NotifyClients(JackNotifyChannelInterface::kXRunCallback, false, 0); | |||
| NotifyClients(kXRunCallback, false, 0); | |||
| } else { | |||
| NotifyClient(refnum, JackNotifyChannelInterface::kXRunCallback, false, 0); | |||
| NotifyClient(refnum, kXRunCallback, false, 0); | |||
| } | |||
| } | |||
| void JackEngine::NotifyGraphReorder() | |||
| { | |||
| NotifyClients(JackNotifyChannelInterface::kGraphOrderCallback, false, 0); | |||
| NotifyClients(kGraphOrderCallback, false, 0); | |||
| } | |||
| void JackEngine::NotifyBufferSize(jack_nframes_t nframes) | |||
| { | |||
| NotifyClients(JackNotifyChannelInterface::kBufferSizeCallback, true, nframes); | |||
| NotifyClients(kBufferSizeCallback, true, nframes); | |||
| } | |||
| void JackEngine::NotifyFreewheel(bool onoff) | |||
| { | |||
| fEngineControl->fRealTime = !onoff; | |||
| NotifyClients((onoff ? JackNotifyChannelInterface::kStartFreewheel : JackNotifyChannelInterface::kStopFreewheel), true, 0); | |||
| NotifyClients((onoff ? kStartFreewheel : kStopFreewheel), true, 0); | |||
| } | |||
| void JackEngine::NotifyPortRegistation(jack_port_id_t port_index, bool onoff) | |||
| { | |||
| NotifyClients((onoff ? JackNotifyChannelInterface::kPortRegistrationOn : JackNotifyChannelInterface::kPortRegistrationOff), false, port_index); | |||
| NotifyClients((onoff ? kPortRegistrationOn : kPortRegistrationOff), false, port_index); | |||
| } | |||
| void JackEngine::NotifyActivate(int refnum) | |||
| { | |||
| NotifyClient(refnum, JackNotifyChannelInterface::kActivateClient, true, 0); | |||
| NotifyClient(refnum, kActivateClient, true, 0); | |||
| } | |||
| //------------------- | |||
| @@ -133,13 +133,13 @@ int JackLibClient::ClientNotifyImp(int refnum, const char* name, int notify, int | |||
| // Done all time | |||
| switch (notify) { | |||
| case JackNotifyChannelInterface::kAddClient: | |||
| case kAddClient: | |||
| JackLog("JackClient::AddClient name = %s, ref = %ld \n", name, refnum); | |||
| // the synchro must be usable in I/O mode when several clients live in the same process | |||
| res = fSynchroTable[refnum]->Connect(name) ? 0 : -1; | |||
| break; | |||
| case JackNotifyChannelInterface::kRemoveClient: | |||
| case kRemoveClient: | |||
| JackLog("JackClient::RemoveClient name = %s, ref = %ld \n", name, refnum); | |||
| if (strcmp(GetClientControl()->fName, name) != 0) | |||
| res = fSynchroTable[refnum]->Disconnect() ? 0 : -1; | |||
| @@ -0,0 +1,43 @@ | |||
| /* | |||
| Copyright (C) 2007 Grame | |||
| This program is free software; you can redistribute it and/or modify | |||
| it under the terms of the GNU General Public License as published by | |||
| the Free Software Foundation; either version 2 of the License, or | |||
| (at your option) any later version. | |||
| This program is distributed in the hope that it will be useful, | |||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
| GNU General Public License for more details. | |||
| You should have received a copy of the GNU General Public License | |||
| along with this program; if not, write to the Free Software | |||
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| */ | |||
| #ifndef __JackNotification__ | |||
| #define __JackNotification__ | |||
| namespace Jack | |||
| { | |||
| enum NotificationType { | |||
| kAddClient = 0, | |||
| kRemoveClient = 1, | |||
| kActivateClient = 2, | |||
| kXRunCallback = 3, | |||
| kGraphOrderCallback = 4, | |||
| kBufferSizeCallback = 5, | |||
| kStartFreewheel = 6, | |||
| kStopFreewheel = 7, | |||
| kPortRegistrationOn = 8, | |||
| kPortRegistrationOff = 9, | |||
| kZombifyClient = 10, | |||
| kDeadClient = 11, | |||
| kMaxNotification | |||
| }; | |||
| } // end of namespace | |||
| #endif | |||
| @@ -255,19 +255,19 @@ void JackServer::Notify(int refnum, int notify, int value) | |||
| { | |||
| switch (notify) { | |||
| case JackNotifyChannelInterface::kGraphOrderCallback: | |||
| case kGraphOrderCallback: | |||
| fEngine->NotifyGraphReorder(); | |||
| break; | |||
| case JackNotifyChannelInterface::kXRunCallback: | |||
| case kXRunCallback: | |||
| fEngine->NotifyXRun(refnum); | |||
| break; | |||
| case JackNotifyChannelInterface::kZombifyClient: | |||
| case kZombifyClient: | |||
| fEngine->ZombifyClient(refnum); | |||
| break; | |||
| case JackNotifyChannelInterface::kDeadClient: | |||
| case kDeadClient: | |||
| JackLog("JackServer: kDeadClient ref = %ld\n", refnum); | |||
| if (fEngine->ClientDeactivate(refnum) < 0) | |||
| jack_error("JackServer: DeadClient ref = %ld cannot be removed from the graph !!", refnum); | |||
| @@ -23,6 +23,7 @@ Copyright (C) 2004-2006 Grame | |||
| #include "JackEngine.h" | |||
| #include "JackGlobals.h" | |||
| #include "JackClient.h" | |||
| #include "JackNotification.h" | |||
| #include <assert.h> | |||
| using namespace std; | |||
| @@ -125,7 +126,7 @@ void JackSocketServerChannel::KillClient(int fd) | |||
| if (refnum == -1) { // Should never happen... correspond to a client that started the socket but never opened... | |||
| jack_error("Client not opened"); | |||
| } else { | |||
| fServer->Notify(refnum, JackNotifyChannelInterface::kDeadClient, 0); | |||
| fServer->Notify(refnum, kDeadClient, 0); | |||
| } | |||
| fSocketTable.erase(fd); | |||