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.

112 lines
2.7KB

  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, jack_options_t options, jack_status_t* status)
  55. {
  56. int result;
  57. JackLog("JackInternalClient::Open name = %s\n", name);
  58. strcpy(fClientControl->fName, name);
  59. // TODO
  60. // check client name
  61. // Require new client
  62. fChannel->ClientOpen(name, &fClientControl->fRefNum, &fEngineControl, &fGraphManager, this, &result);
  63. if (result < 0) {
  64. jack_error("Cannot open client name = %s", name);
  65. goto error;
  66. }
  67. SetupDriverSync(false);
  68. return 0;
  69. error:
  70. fChannel->Stop();
  71. fChannel->Close();
  72. return -1;
  73. }
  74. JackGraphManager* JackInternalClient::GetGraphManager() const
  75. {
  76. assert(fGraphManager);
  77. return fGraphManager;
  78. }
  79. JackEngineControl* JackInternalClient::GetEngineControl() const
  80. {
  81. assert(fEngineControl);
  82. return fEngineControl;
  83. }
  84. JackClientControl* JackInternalClient::GetClientControl() const
  85. {
  86. return fClientControl;
  87. }
  88. } // end of namespace