The base-application for Laborejo, Fluajho, Patroneo, Vico etc.
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.

75 lines
2.3KB

  1. /*
  2. Calf Box, an open source musical instrument.
  3. Copyright (C) 2010-2013 Krzysztof Foltman
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef CBOX_TARFILE_H
  16. #define CBOX_TARFILE_H
  17. #include <glib.h>
  18. #include <stdint.h>
  19. #include <sndfile.h>
  20. struct cbox_taritem
  21. {
  22. gchar *filename;
  23. gchar *filename_nc;
  24. uint64_t offset;
  25. uint64_t size;
  26. int refs;
  27. };
  28. struct cbox_tarfile
  29. {
  30. int fd;
  31. int refs;
  32. GHashTable *items_byname;
  33. GHashTable *items_byname_nc;
  34. char *file_pathname; //full path to the .tar file with filename.ext
  35. };
  36. struct cbox_tarpool
  37. {
  38. GHashTable *files;
  39. };
  40. struct cbox_tarfile_sndstream
  41. {
  42. struct cbox_tarfile *file;
  43. struct cbox_taritem *item;
  44. uint64_t filepos;
  45. };
  46. extern struct SF_VIRTUAL_IO cbox_taritem_virtual_io;
  47. extern struct cbox_tarfile *cbox_tarfile_open(const char *pathname, GError **error);
  48. extern struct cbox_taritem *cbox_tarfile_get_item_by_name(struct cbox_tarfile *tarfile, const char *item_filename, gboolean ignore_case);
  49. extern int cbox_tarfile_openitem(struct cbox_tarfile *tarfile, struct cbox_taritem *item);
  50. extern void cbox_tarfile_closeitem(struct cbox_tarfile *tarfile, struct cbox_taritem *item, int fd);
  51. extern SNDFILE *cbox_tarfile_opensndfile(struct cbox_tarfile *tarfile, struct cbox_taritem *item, struct cbox_tarfile_sndstream *stream, SF_INFO *sfinfo);
  52. // No need to close - it reuses the cbox_tarfile file descriptor
  53. extern void cbox_tarfile_destroy(struct cbox_tarfile *tf);
  54. extern struct cbox_tarpool *cbox_tarpool_new(void);
  55. extern struct cbox_tarfile *cbox_tarpool_get_tarfile(struct cbox_tarpool *pool, const char *name, GError **error);
  56. extern void cbox_tarpool_release_tarfile(struct cbox_tarpool *pool, struct cbox_tarfile *file);
  57. extern void cbox_tarpool_destroy(struct cbox_tarpool *pool);
  58. #endif