jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.5KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2006 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include "JackInternalClient.h"
  17. #include "JackEngine.h"
  18. #include "JackServer.h"
  19. #include "JackGraphManager.h"
  20. #include "JackEngineControl.h"
  21. #include "JackClientControl.h"
  22. #include "JackInternalClientChannel.h"
  23. #include <assert.h>
  24. namespace Jack
  25. {
  26. JackGraphManager* JackInternalClient::fGraphManager = NULL;
  27. JackEngineControl* JackInternalClient::fEngineControl = NULL;
  28. // Used for external C API (JackAPI.cpp)
  29. JackGraphManager* GetGraphManager()
  30. {
  31. return JackServer::fInstance->GetGraphManager();
  32. }
  33. JackEngineControl* GetEngineControl()
  34. {
  35. return JackServer::fInstance->GetEngineControl();
  36. }
  37. JackSynchro** GetSynchroTable()
  38. {
  39. return JackServer::fInstance->GetSynchroTable();
  40. }
  41. JackInternalClient::JackInternalClient(JackServer* server, JackSynchro** table): JackClient(table)
  42. {
  43. fClientControl = new JackClientControl();
  44. fChannel = new JackInternalClientChannel(server);
  45. }
  46. JackInternalClient::~JackInternalClient()
  47. {
  48. delete fClientControl;
  49. delete fChannel;
  50. }
  51. int JackInternalClient::Open(const char* name)
  52. {
  53. int result;
  54. JackLog("JackInternalClient::Open name = %s\n", name);
  55. strcpy(fClientControl->fName, name);
  56. // Require new client
  57. fChannel->ClientNew(name, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result);
  58. if (result < 0) {
  59. jack_error("Cannot open client name = %s", name);
  60. goto error;
  61. }
  62. SetupDriverSync(false);
  63. return 0;
  64. error:
  65. fChannel->Stop();
  66. fChannel->Close();
  67. return -1;
  68. }
  69. JackGraphManager* JackInternalClient::GetGraphManager() const
  70. {
  71. assert(fGraphManager);
  72. return fGraphManager;
  73. }
  74. JackEngineControl* JackInternalClient::GetEngineControl() const
  75. {
  76. assert(fEngineControl);
  77. return fEngineControl;
  78. }
  79. JackClientControl* JackInternalClient::GetClientControl() const
  80. {
  81. return fClientControl;
  82. }
  83. } // end of namespace