Audio plugin host https://kx.studio/carla
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.

149 lines
4.1KB

  1. /*
  2. * Carla JACK API for external applications
  3. * Copyright (C) 2016-2022 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "libjack.hpp"
  18. CARLA_BACKEND_USE_NAMESPACE
  19. // --------------------------------------------------------------------------------------------------------------------
  20. CARLA_PLUGIN_EXPORT
  21. int jack_engine_takeover_timebase(jack_client_t* client)
  22. {
  23. carla_debug("%s(%p)", __FUNCTION__, client);
  24. return ENOSYS;
  25. // unused
  26. (void)client;
  27. }
  28. // --------------------------------------------------------------------------------------------------------------------
  29. CARLA_PLUGIN_EXPORT
  30. int jack_release_timebase(jack_client_t* client)
  31. {
  32. carla_debug("%s(%p)", __FUNCTION__, client);
  33. return 0;
  34. // unused
  35. (void)client;
  36. }
  37. CARLA_PLUGIN_EXPORT
  38. int jack_set_sync_callback(jack_client_t* client, JackSyncCallback callback, void* arg)
  39. {
  40. carla_debug("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
  41. JackClientState* const jclient = (JackClientState*)client;
  42. CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 1);
  43. const CarlaMutexLocker cms(jclient->mutex);
  44. jclient->syncCb = callback;
  45. jclient->syncCbPtr = arg;
  46. return 0;
  47. }
  48. CARLA_PLUGIN_EXPORT
  49. int jack_set_sync_timeout(jack_client_t* client, jack_time_t timeout)
  50. {
  51. carla_stderr2("%s(%p, " P_UINT64 ")", __FUNCTION__, client, timeout);
  52. return 0;
  53. }
  54. CARLA_PLUGIN_EXPORT
  55. int jack_set_timebase_callback(jack_client_t* client, int conditional, JackTimebaseCallback callback, void* arg)
  56. {
  57. carla_debug("%s(%p, %i, %p, %p)", __FUNCTION__, client, conditional, callback, arg);
  58. return conditional ? EBUSY : 0;
  59. // unused
  60. (void)client;
  61. (void)callback;
  62. (void)arg;
  63. }
  64. CARLA_PLUGIN_EXPORT
  65. int jack_transport_locate(jack_client_t* client, jack_nframes_t frame)
  66. {
  67. carla_stderr2("%s(%p, %u)", __FUNCTION__, client, frame);
  68. return ENOSYS;
  69. }
  70. CARLA_PLUGIN_EXPORT
  71. jack_transport_state_t jack_transport_query(const jack_client_t* client, jack_position_t* pos)
  72. {
  73. if (const JackClientState* const jclient = (const JackClientState*)client)
  74. {
  75. const JackServerState& jserver(jclient->server);
  76. if (pos != nullptr)
  77. std::memcpy(pos, &jserver.position, sizeof(jack_position_t));
  78. return jserver.playing ? JackTransportRolling : JackTransportStopped;
  79. }
  80. if (pos != nullptr)
  81. std::memset(pos, 0, sizeof(jack_position_t));
  82. return JackTransportStopped;
  83. }
  84. CARLA_PLUGIN_EXPORT
  85. jack_nframes_t jack_get_current_transport_frame(const jack_client_t* client)
  86. {
  87. if (const JackClientState* const jclient = (const JackClientState*)client)
  88. return jclient->server.position.frame;
  89. return 0;
  90. }
  91. CARLA_PLUGIN_EXPORT
  92. int jack_transport_reposition(jack_client_t* client, const jack_position_t* pos)
  93. {
  94. carla_stderr2("%s(%p, %p)", __FUNCTION__, client, pos);
  95. return ENOSYS;
  96. }
  97. CARLA_PLUGIN_EXPORT
  98. void jack_transport_start(jack_client_t* client)
  99. {
  100. carla_stderr2("%s(%p)", __FUNCTION__, client);
  101. }
  102. CARLA_PLUGIN_EXPORT
  103. void jack_transport_stop(jack_client_t* client)
  104. {
  105. carla_stderr2("%s(%p)", __FUNCTION__, client);
  106. }
  107. // --------------------------------------------------------------------------------------------------------------------
  108. CARLA_PLUGIN_EXPORT
  109. void jack_get_transport_info(jack_client_t* client, void* tinfo)
  110. {
  111. carla_stderr2("%s(%p, %p)", __FUNCTION__, client, tinfo);
  112. }
  113. CARLA_PLUGIN_EXPORT
  114. void jack_set_transport_info(jack_client_t* client, void* tinfo)
  115. {
  116. carla_stderr2("%s(%p, %p)", __FUNCTION__, client, tinfo);
  117. }
  118. // --------------------------------------------------------------------------------------------------------------------