1
0

FLACFileCallbacks.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <FLAC/all.h>
  3. #include "nx/nxfile.h"
  4. FLAC__StreamDecoderReadStatus FLAC_NXFile_Read(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
  5. FLAC__StreamDecoderSeekStatus FLAC_NXFile_Seek(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data);
  6. FLAC__StreamDecoderTellStatus FLAC_NXFile_Tell(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
  7. FLAC__StreamDecoderLengthStatus FLAC_NXFile_Length(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data);
  8. FLAC__bool FLAC_NXFile_EOF(const FLAC__StreamDecoder *decoder, void *client_data);
  9. class FLACClientData
  10. {
  11. public:
  12. FLACClientData() : object(0) {}
  13. void SetFile(nx_file_t file) { this->file = file; }
  14. void SetObject(void *object) { this->object = object; }
  15. nx_file_t GetFile() { return file; }
  16. void *GetObject() { return object; }
  17. private:
  18. nx_file_t file;
  19. void *object;
  20. };
  21. template <typename _t>
  22. static _t *FLAC_GetObject(void *client_data)
  23. {
  24. return (_t *)((FLACClientData *)client_data)->GetObject();
  25. }
  26. static nx_file_t FLAC_GetFile(void *client_data)
  27. {
  28. return ((FLACClientData *)client_data)->GetFile();
  29. }