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.

lv2_rtmempool.h 3.6KB

12 years ago
12 years ago
12 years ago
12 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. /** This extension used to be defined by a different URI */
  23. #define LV2_RTSAFE_MEMORY_POOL_DEPRECATED_URI "http://home.gna.org/lv2dynparam/rtmempool/v1"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #else
  27. #include <stdbool.h>
  28. #endif
  29. /**
  30. * Opaque data to host data for LV2_RtMemPool_Pool.
  31. */
  32. typedef void* LV2_RtMemPool_Handle;
  33. /**
  34. * On instantiation, host must supply LV2_RTSAFE_MEMORY_POOL__Pool feature.
  35. * LV2_Feature::data must be pointer to LV2_RtMemPool_Pool.
  36. */
  37. typedef struct _LV2_RtMemPool_Pool {
  38. /**
  39. * This function is called when plugin wants to create memory pool
  40. *
  41. * <b>may/will sleep</b>
  42. *
  43. * @param pool_name pool name, for debug purposes, max RTSAFE_MEMORY_POOL_NAME_MAX chars, including terminating zero char. May be NULL.
  44. * @param data_size memory chunk size
  45. * @param min_preallocated min chunks preallocated
  46. * @param max_preallocated max chunks preallocated
  47. *
  48. * @return Success status, true if successful
  49. */
  50. bool (*create)(LV2_RtMemPool_Handle * handle_ptr,
  51. const char * pool_name,
  52. size_t data_size,
  53. size_t min_preallocated,
  54. size_t max_preallocated);
  55. /**
  56. * This function is called when plugin wants to destroy previously created memory pool
  57. *
  58. * <b>may/will sleep</b>
  59. */
  60. void (*destroy)(LV2_RtMemPool_Handle handle);
  61. /**
  62. * This function is called when plugin wants to allocate memory in context where sleeping is not allowed
  63. *
  64. * <b>will not sleep</b>
  65. *
  66. * @return Pointer to allocated memory or NULL if memory no memory is available
  67. */
  68. void * (*allocate_atomic)(LV2_RtMemPool_Handle handle);
  69. /**
  70. * This function is called when plugin wants to allocate memory in context where sleeping is allowed
  71. *
  72. * <b>may/will sleep</b>
  73. *
  74. * @return Pointer to allocated memory or NULL if memory no memory is available (should not happen under normal conditions)
  75. */
  76. void * (*allocate_sleepy)(LV2_RtMemPool_Handle handle);
  77. /**
  78. * This function is called when plugin wants to deallocate previously allocated memory
  79. *
  80. * <b>will not sleep</b>
  81. *
  82. * @param memory_ptr pointer to previously allocated memory chunk
  83. */
  84. void (*deallocate)(LV2_RtMemPool_Handle handle,
  85. void * memory_ptr);
  86. } LV2_RtMemPool_Pool;
  87. /**
  88. * Deprecated feature for backwards compatibility.
  89. */
  90. typedef struct _LV2_RtMemPool_Pool_Deprecated {
  91. unsigned char (*create)(const char*,size_t,size_t,size_t,LV2_RtMemPool_Handle*);
  92. void (*destroy)(LV2_RtMemPool_Handle);
  93. void* (*allocate_atomic)(LV2_RtMemPool_Handle);
  94. void* (*allocate_sleepy)(LV2_RtMemPool_Handle);
  95. void (*deallocate)(LV2_RtMemPool_Handle,void*);
  96. } LV2_RtMemPool_Pool_Deprecated;
  97. #ifdef __cplusplus
  98. } /* extern "C" */
  99. #endif
  100. #endif /* LV2_RTMEMPOOL_H */