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.

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