osi_line_cache.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _OSI_LINE_CACHE_H_
  13. #define _OSI_LINE_CACHE_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /**
  21. * \brief opaque line cache data struct
  22. */
  23. typedef struct osiLineCache osiLineCache_t;
  24. /**
  25. * \brief function prototype for line cache output
  26. *
  27. * This function will output line cache data.
  28. *
  29. * \param ctx output function context
  30. * \param data output data
  31. * \param size output size
  32. */
  33. typedef void (*osiLineCacheOutput_t)(void *ctx, const void *data, unsigned size);
  34. /**
  35. * \brief create a line cache
  36. *
  37. * The output function of line cache specified at creation, and can't be
  38. * changed.
  39. *
  40. * \param output output function
  41. * \param size line cache size
  42. * \return
  43. * - line cache object
  44. * - NULL if invalid parameter, or out of memory
  45. */
  46. osiLineCache_t *osiLineCacheCreate(osiLineCacheOutput_t output, unsigned size);
  47. /**
  48. * \brief delete a line cache
  49. *
  50. * When \p d is NULL, nothing will be done.
  51. *
  52. * \param d line cache object
  53. */
  54. void osiLineCacheDelete(osiLineCache_t *d);
  55. /**
  56. * \brief write data to line cache
  57. *
  58. * \p owner is the context of output function.
  59. *
  60. * When \p owner is the same as the owner of existed data, and there are
  61. * rooms of internal buffer, \p data will be copied to internal buffer.
  62. * Otherwise, the registered output function will be called.
  63. *
  64. * \param d line cache object
  65. * \param owner owner the data
  66. * \param data data to be written
  67. * \param size written data size
  68. */
  69. void osiLineCacheWrite(osiLineCache_t *d, void *owner, const void *data, unsigned size);
  70. /**
  71. * \brief flush data in internal buffer
  72. *
  73. * \param d line cache object
  74. */
  75. void osiLineCacheFlush(osiLineCache_t *d);
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif