Collection of tools useful for audio production
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.

125 lines
3.6KB

  1. /* -*- Mode: C ; c-basic-offset: 2 -*- */
  2. /*****************************************************************************
  3. *
  4. * This work is in public domain.
  5. *
  6. * This file is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. *
  10. * If you have questions, contact Nedko Arnaudov <nedko@arnaudov.name> or
  11. * ask in #lad channel, FreeNode IRC network.
  12. *
  13. *****************************************************************************/
  14. /**
  15. * @file lv2_rtmempool.h
  16. * @brief LV2 realtime safe memory pool extension definition
  17. *
  18. */
  19. #ifndef LV2_RTMEMPOOL_H__8914012A_720D_4EAC_B0DB_6F93F2B47975__INCLUDED
  20. #define LV2_RTMEMPOOL_H__8914012A_720D_4EAC_B0DB_6F93F2B47975__INCLUDED
  21. #define LV2_RTSAFE_MEMORY_POOL_URI "http://home.gna.org/lv2dynparam/rtmempool/v1"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #if 0
  26. } /* Adjust editor indent */
  27. #endif
  28. /** opaque handle to memory pool */
  29. typedef struct { /** fake */ int unused; } * lv2_rtsafe_memory_pool_handle;
  30. /** max size of memory pool name, in chars, including terminating zero char */
  31. #define LV2_RTSAFE_MEMORY_POOL_NAME_MAX 128
  32. /** structure, pointer to which is to be supplied as @c data member of ::LV2_Feature */
  33. typedef struct
  34. {
  35. /**
  36. * This function is called when plugin wants to create memory pool
  37. *
  38. * <b>may/will sleep</b>
  39. *
  40. * @param pool_name pool name, for debug purposes, max RTSAFE_MEMORY_POOL_NAME_MAX chars, including terminating zero char. May be NULL.
  41. * @param data_size memory chunk size
  42. * @param min_preallocated min chunks preallocated
  43. * @param max_preallocated chunks preallocated
  44. * @param pool_ptr pointer to variable receiving handle to newly created pool object
  45. *
  46. * @return Success status
  47. * @retval Non-zero - success
  48. * @retval Zero - error
  49. */
  50. unsigned char
  51. (*create)(
  52. const char * pool_name,
  53. size_t data_size, /* chunk size */
  54. size_t min_preallocated, /* min chunks preallocated */
  55. size_t max_preallocated, /* max chunks preallocated */
  56. lv2_rtsafe_memory_pool_handle * pool_ptr);
  57. /**
  58. * This function is called when plugin wants to destroy previously created memory pool
  59. *
  60. * <b>may/will sleep</b>
  61. *
  62. * @param pool handle to pool object
  63. */
  64. void
  65. (*destroy)(
  66. lv2_rtsafe_memory_pool_handle pool);
  67. /**
  68. * This function is called when plugin wants to allocate memory in context where sleeping is not allowed
  69. *
  70. * <b>will not sleep</b>
  71. *
  72. * @param pool handle to pool object
  73. *
  74. * @return Pointer to allocated memory or NULL if memory no memory is available
  75. */
  76. void *
  77. (*allocate_atomic)(
  78. lv2_rtsafe_memory_pool_handle pool);
  79. /**
  80. * This function is called when plugin wants to allocate memory in context where sleeping is allowed
  81. *
  82. * <b>may/will sleep</b>
  83. *
  84. * @param pool handle to pool object
  85. *
  86. * @return Pointer to allocated memory or NULL if memory no memory is available (should not happen under normal conditions)
  87. */
  88. void *
  89. (*allocate_sleepy)(
  90. lv2_rtsafe_memory_pool_handle pool);
  91. /**
  92. * This function is called when plugin wants to deallocate previously allocated memory
  93. *
  94. * <b>will not sleep</b>
  95. *
  96. * @param pool handle to pool object
  97. * @param memory_ptr pointer to previously allocated memory chunk
  98. */
  99. /* will not sleep */
  100. void
  101. (*deallocate)(
  102. lv2_rtsafe_memory_pool_handle pool,
  103. void * memory_ptr);
  104. } lv2_rtsafe_memory_pool_provider;
  105. #if 0
  106. { /* Adjust editor indent */
  107. #endif
  108. #ifdef __cplusplus
  109. } /* extern "C" */
  110. #endif
  111. #endif /* #ifndef LV2_RTMEMPOOL_H__8914012A_720D_4EAC_B0DB_6F93F2B47975__INCLUDED */