loop_fstream.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) 2018 Actions Semiconductor Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file file stream interface
  8. */
  9. #ifndef __LOOP_FSTREAM_H__
  10. #define __LOOP_FSTREAM_H__
  11. #include <stream.h>
  12. #ifdef CONFIG_FILE_SYSTEM
  13. #include <fs/fs.h>
  14. #endif
  15. /**
  16. * @defgroup loop_fstream_apis Loop Fstream APIs
  17. * @ingroup stream_apis, shared structures
  18. * @{
  19. */
  20. /**
  21. * loop fstream is a stream very similar to file stream, but read only.
  22. * It has a extremly big length by repeating the true file many many times.
  23. */
  24. /**
  25. * @brief create loop fstream , return stream handle
  26. *
  27. * This routine provides create stream ,and return stream handle.
  28. * and stream state is STATE_INIT
  29. *
  30. * @param param create stream param, loop fstream is file url
  31. *
  32. * @return stream handle if create stream success
  33. * @return NULL if create stream failed
  34. */
  35. io_stream_t loop_fstream_create(const char *param);
  36. /**
  37. * @brief get loop fstream info
  38. *
  39. * This routine allows app who uses this stream to set some file info or special ops,
  40. * which are alternative but can help to improve experience.
  41. */
  42. void loop_fstream_get_info(void *info, uint8_t info_id);
  43. /* loop fstream info_id to get info from app */
  44. #define LOOPFS_FILE_INFO (1)
  45. #define LOOPFS_CALLBACK (2)
  46. /* get file head&tail info */
  47. struct loopfs_file_info {
  48. uint32_t head;
  49. uint32_t tail;
  50. int bitrate;
  51. };
  52. /* get callback func */
  53. typedef void (*loopfs_energy_cb)(uint8_t energy_enable);
  54. /**
  55. * @} end defgroup loop_stream_apis
  56. */
  57. #endif /* __LOOP_STREAM_H__ */