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.

136 lines
3.7KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2008 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. #ifndef __JackInternalClient__
  17. #define __JackInternalClient__
  18. #include "JackClient.h"
  19. namespace Jack
  20. {
  21. struct JackEngineControl;
  22. class JackClientChannelInterface;
  23. /*!
  24. \brief Internal clients in the server.
  25. */
  26. class JackInternalClient : public JackClient
  27. {
  28. private:
  29. JackClientControl* fClientControl; /*! Client control */
  30. public:
  31. JackInternalClient(JackServer* server, JackSynchro** table);
  32. virtual ~JackInternalClient();
  33. int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status);
  34. JackGraphManager* GetGraphManager() const;
  35. JackEngineControl* GetEngineControl() const;
  36. JackClientControl* GetClientControl() const;
  37. static JackGraphManager* fGraphManager; /*! Shared memory Port manager */
  38. static JackEngineControl* fEngineControl; /*! Shared engine cotrol */
  39. };
  40. /*!
  41. \brief Loadable internal clients in the server.
  42. */
  43. #ifdef WIN32
  44. #include <windows.h>
  45. #define HANDLE HINSTANCE
  46. #define LoadJackModule(name) LoadLibrary((name));
  47. #define UnloadJackModule(handle) FreeLibrary((handle));
  48. #define GetJackProc(handle, name) GetProcAddress((handle), (name));
  49. static void PrintLoadError(const char* so_name)
  50. {
  51. // Retrieve the system error message for the last-error code
  52. LPVOID lpMsgBuf;
  53. LPVOID lpDisplayBuf;
  54. DWORD dw = GetLastError();
  55. FormatMessage(
  56. FORMAT_MESSAGE_ALLOCATE_BUFFER |
  57. FORMAT_MESSAGE_FROM_SYSTEM |
  58. FORMAT_MESSAGE_IGNORE_INSERTS,
  59. NULL,
  60. dw,
  61. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  62. (LPTSTR) &lpMsgBuf,
  63. 0, NULL );
  64. // Display the error message and exit the process
  65. lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
  66. (lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)so_name) + 40) * sizeof(TCHAR));
  67. _snprintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR),
  68. TEXT("error loading %s err = %s"), so_name, lpMsgBuf);
  69. jack_error((LPCTSTR)lpDisplayBuf);
  70. LocalFree(lpMsgBuf);
  71. LocalFree(lpDisplayBuf);
  72. }
  73. #else
  74. #include <dlfcn.h>
  75. #define HANDLE void*
  76. #define LoadJackModule(name) dlopen((name), RTLD_NOW | RTLD_LOCAL);
  77. #define UnloadJackModule(handle) dlclose((handle));
  78. #define GetJackProc(handle, name) dlsym((handle), (name));
  79. #define PrintLoadError(so_name) jack_log("error loading %s err = %s", so_name, dlerror());
  80. #endif
  81. typedef int (*InitializeCallback)(jack_client_t*, const char*);
  82. typedef void (*FinishCallback)(void *);
  83. class JackLoadableInternalClient : public JackInternalClient
  84. {
  85. private:
  86. HANDLE fHandle;
  87. InitializeCallback fInitialize;
  88. FinishCallback fFinish;
  89. char fObjectData[JACK_LOAD_INIT_LIMIT];
  90. public:
  91. JackLoadableInternalClient(JackServer* server, JackSynchro** table, const char* so_name, const char* object_data);
  92. virtual ~JackLoadableInternalClient();
  93. int Open(const char* server_name, const char* name, jack_options_t options, jack_status_t* status);
  94. };
  95. } // end of namespace
  96. #endif