KXStudio Website https://kx.studio/
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.

106 lines
3.1KB

  1. /*
  2. LV2 realtime safe memory pool extension definition
  3. This work is in public domain.
  4. This file is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY; without even the implied warranty of
  6. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  7. If you have questions, contact Filipe Coelho (aka falkTX) <falktx@falktx.com>
  8. or ask in #lad channel, FreeNode IRC network.
  9. */
  10. /**
  11. * @file lv2_rtmempool.h
  12. * C header for the LV2 rtmempool extension <http://kxstudio.sf.net/ns/lv2ext/rtmempool>.
  13. *
  14. */
  15. #ifndef LV2_RTMEMPOOL_H
  16. #define LV2_RTMEMPOOL_H
  17. #define LV2_RTSAFE_MEMORY_POOL_URI "http://kxstudio.sf.net/ns/lv2ext/rtmempool"
  18. #define LV2_RTSAFE_MEMORY_POOL_PREFIX LV2_RTSAFE_MEMORY_POOL_URI "#"
  19. #define LV2_RTSAFE_MEMORY_POOL__Pool LV2_RTSAFE_MEMORY_POOL_URI "Pool"
  20. /** max size of memory pool name, in chars, including terminating zero char */
  21. #define LV2_RTSAFE_MEMORY_POOL_NAME_MAX 128
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #else
  25. #include <stdbool.h>
  26. #endif
  27. /**
  28. * Opaque data to host data for LV2_RtMemPool_Pool.
  29. */
  30. typedef void* LV2_RtMemPool_Handle;
  31. /**
  32. * On instantiation, host must supply LV2_RTSAFE_MEMORY_POOL__Pool feature.
  33. * LV2_Feature::data must be pointer to LV2_RtMemPool_Pool.
  34. */
  35. typedef struct _LV2_RtMemPool_Pool {
  36. /**
  37. * This function is called when plugin wants to create memory pool
  38. *
  39. * <b>may/will sleep</b>
  40. *
  41. * @param pool_name pool name, for debug purposes, max RTSAFE_MEMORY_POOL_NAME_MAX chars, including terminating zero char. May be NULL.
  42. * @param data_size memory chunk size
  43. * @param min_preallocated min chunks preallocated
  44. * @param max_preallocated max chunks preallocated
  45. *
  46. * @return Success status, true if successful
  47. */
  48. bool (*create)(LV2_RtMemPool_Handle * handle_ptr,
  49. const char * pool_name,
  50. size_t data_size,
  51. size_t min_preallocated,
  52. size_t max_preallocated);
  53. /**
  54. * This function is called when plugin wants to destroy previously created memory pool
  55. *
  56. * <b>may/will sleep</b>
  57. */
  58. void (*destroy)(LV2_RtMemPool_Handle handle);
  59. /**
  60. * This function is called when plugin wants to allocate memory in context where sleeping is not allowed
  61. *
  62. * <b>will not sleep</b>
  63. *
  64. * @return Pointer to allocated memory or NULL if memory no memory is available
  65. */
  66. void * (*allocate_atomic)(LV2_RtMemPool_Handle handle);
  67. /**
  68. * This function is called when plugin wants to allocate memory in context where sleeping is allowed
  69. *
  70. * <b>may/will sleep</b>
  71. *
  72. * @return Pointer to allocated memory or NULL if memory no memory is available (should not happen under normal conditions)
  73. */
  74. void * (*allocate_sleepy)(LV2_RtMemPool_Handle handle);
  75. /**
  76. * This function is called when plugin wants to deallocate previously allocated memory
  77. *
  78. * <b>will not sleep</b>
  79. *
  80. * @param memory_ptr pointer to previously allocated memory chunk
  81. */
  82. void (*deallocate)(LV2_RtMemPool_Handle handle,
  83. void * memory_ptr);
  84. } LV2_RtMemPool_Pool;
  85. #ifdef __cplusplus
  86. } /* extern "C" */
  87. #endif
  88. #endif /* LV2_RTMEMPOOL_H */