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.

109 lines
2.6KB

  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. #ifdef WIN32
  17. #pragma warning (disable : 4786)
  18. #endif
  19. #include "JackInternalClient.h"
  20. #include "JackEngine.h"
  21. #include "JackServer.h"
  22. #include "JackGraphManager.h"
  23. #include "JackEngineControl.h"
  24. #include "JackClientControl.h"
  25. #include "JackInternalClientChannel.h"
  26. #include <assert.h>
  27. namespace Jack
  28. {
  29. JackGraphManager* JackInternalClient::fGraphManager = NULL;
  30. JackEngineControl* JackInternalClient::fEngineControl = NULL;
  31. // Used for external C API (JackAPI.cpp)
  32. JackGraphManager* GetGraphManager()
  33. {
  34. return JackServer::fInstance->GetGraphManager();
  35. }
  36. JackEngineControl* GetEngineControl()
  37. {
  38. return JackServer::fInstance->GetEngineControl();
  39. }
  40. JackSynchro** GetSynchroTable()
  41. {
  42. return JackServer::fInstance->GetSynchroTable();
  43. }
  44. JackInternalClient::JackInternalClient(JackServer* server, JackSynchro** table): JackClient(table)
  45. {
  46. fClientControl = new JackClientControl();
  47. fChannel = new JackInternalClientChannel(server);
  48. }
  49. JackInternalClient::~JackInternalClient()
  50. {
  51. delete fClientControl;
  52. delete fChannel;
  53. }
  54. int JackInternalClient::Open(const char* name)
  55. {
  56. int result;
  57. JackLog("JackInternalClient::Open name = %s\n", name);
  58. strcpy(fClientControl->fName, name);
  59. // Require new client
  60. fChannel->ClientNew(name, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result);
  61. if (result < 0) {
  62. jack_error("Cannot open client name = %s", name);
  63. goto error;
  64. }
  65. SetupDriverSync(false);
  66. return 0;
  67. error:
  68. fChannel->Stop();
  69. fChannel->Close();
  70. return -1;
  71. }
  72. JackGraphManager* JackInternalClient::GetGraphManager() const
  73. {
  74. assert(fGraphManager);
  75. return fGraphManager;
  76. }
  77. JackEngineControl* JackInternalClient::GetEngineControl() const
  78. {
  79. assert(fEngineControl);
  80. return fEngineControl;
  81. }
  82. JackClientControl* JackInternalClient::GetClientControl() const
  83. {
  84. return fClientControl;
  85. }
  86. } // end of namespace