Dmitry Baikov jackmp-time patch: add jack_get_time, jack_time_to_frames, jack_frames_...
[jack2.git] / common / JackInternalClient.cpp
blob194b3e885517446897a6478d1ebf9263d34f5269
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2006 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifdef WIN32
22 #pragma warning (disable : 4786)
23 #endif
25 #include "JackInternalClient.h"
26 #include "JackEngine.h"
27 #include "JackServer.h"
28 #include "JackGraphManager.h"
29 #include "JackEngineControl.h"
30 #include "JackClientControl.h"
31 #include "JackInternalClientChannel.h"
32 #include <assert.h>
34 namespace Jack
37 JackGraphManager* JackInternalClient::fGraphManager = NULL;
38 JackEngineControl* JackInternalClient::fEngineControl = NULL;
40 // Used for external C API (JackAPI.cpp)
41 JackGraphManager* GetGraphManager()
43 return JackServer::fInstance->GetGraphManager();
46 JackEngineControl* GetEngineControl()
48 return JackServer::fInstance->GetEngineControl();
51 JackSynchro** GetSynchroTable()
53 return JackServer::fInstance->GetSynchroTable();
56 JackInternalClient::JackInternalClient(JackServer* server, JackSynchro** table): JackClient(table)
58 fClientControl = new JackClientControl();
59 fChannel = new JackInternalClientChannel(server);
62 JackInternalClient::~JackInternalClient()
64 delete fClientControl;
65 delete fChannel;
68 int JackInternalClient::Open(const char* name)
70 int result;
71 JackLog("JackInternalClient::Open name = %s\n", name);
72 strcpy(fClientControl->fName, name);
74 // Require new client
75 fChannel->ClientOpen(name, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result);
76 if (result < 0) {
77 jack_error("Cannot open client name = %s", name);
78 goto error;
81 SetupDriverSync(false);
82 return 0;
84 error:
85 fChannel->Stop();
86 fChannel->Close();
87 return -1;
90 JackGraphManager* JackInternalClient::GetGraphManager() const
92 assert(fGraphManager);
93 return fGraphManager;
96 JackEngineControl* JackInternalClient::GetEngineControl() const
98 assert(fEngineControl);
99 return fEngineControl;
102 JackClientControl* JackInternalClient::GetClientControl() const
104 return fClientControl;
107 } // end of namespace