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.

114 lines
3.6KB

  1. /*
  2. * Carla JACK API for external applications
  3. * Copyright (C) 2016-2017 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. // need to include this first
  18. #include "libjack.hpp"
  19. CARLA_BACKEND_USE_NAMESPACE
  20. // --------------------------------------------------------------------------------------------------------------------
  21. int jack_set_latency_callback(jack_client_t* client, JackLatencyCallback callback, void* arg)
  22. {
  23. carla_stderr2("%s(%p, %p, %p)", __FUNCTION__, client, callback, arg);
  24. return 0;
  25. }
  26. // --------------------------------------------------------------------------------------------------------------------
  27. //void jack_port_set_latency (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  28. // --------------------------------------------------------------------------------------------------------------------
  29. CARLA_EXPORT
  30. void jack_port_get_latency_range(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t* range)
  31. {
  32. range->min = range->max = 0;
  33. }
  34. //void jack_port_set_latency_range (jack_port_t *port, jack_latency_callback_mode_t mode, jack_latency_range_t *range) JACK_WEAK_EXPORT;
  35. // --------------------------------------------------------------------------------------------------------------------
  36. CARLA_EXPORT
  37. int jack_recompute_total_latencies(jack_client_t* client)
  38. {
  39. carla_stderr2("%s(%p)", __FUNCTION__, client);
  40. return 0;
  41. }
  42. CARLA_EXPORT
  43. jack_nframes_t jack_port_get_latency(jack_port_t* port)
  44. {
  45. JackPortState* const jport = (JackPortState*)port;
  46. CARLA_SAFE_ASSERT_RETURN(jport != nullptr, 0);
  47. if (jport->isMidi || ! jport->isSystem)
  48. return 0;
  49. // TODO
  50. const uint32_t bufferSize = 128;
  51. const uint32_t latencyMultiplier = 3;
  52. if (jport->flags & JackPortIsInput)
  53. return bufferSize*latencyMultiplier;
  54. if (jport->flags & JackPortIsOutput)
  55. return bufferSize;
  56. return 0;
  57. }
  58. CARLA_EXPORT
  59. jack_nframes_t jack_port_get_total_latency(jack_client_t* client, jack_port_t* port)
  60. {
  61. JackClientState* const jclient = (JackClientState*)client;
  62. CARLA_SAFE_ASSERT_RETURN(jclient != nullptr, 1);
  63. JackPortState* const jport = (JackPortState*)port;
  64. CARLA_SAFE_ASSERT_RETURN(jport != nullptr, 0);
  65. if (jport->isMidi)
  66. return 0;
  67. // TODO
  68. const uint32_t bufferSize = jclient->server.bufferSize;
  69. const uint32_t latencyMultiplier = 3;
  70. if (jport->isSystem)
  71. {
  72. if (jport->flags & JackPortIsInput)
  73. return bufferSize*latencyMultiplier;
  74. if (jport->flags & JackPortIsOutput)
  75. return bufferSize;
  76. }
  77. else
  78. {
  79. if (jport->flags & JackPortIsInput)
  80. return bufferSize;
  81. if (jport->flags & JackPortIsOutput)
  82. return bufferSize*latencyMultiplier;
  83. }
  84. return 0;
  85. }
  86. // --------------------------------------------------------------------------------------------------------------------
  87. //int jack_recompute_total_latency (jack_client_t*, jack_port_t* port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT;
  88. // --------------------------------------------------------------------------------------------------------------------