1
0

ifc_audio_decoder_pull.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include "foundation/dispatch.h"
  3. #include "nx/nxuri.h"
  4. #include "metadata/ifc_metadata.h"
  5. class ifc_audio_decoder_pull : public Wasabi2::Dispatchable
  6. {
  7. protected:
  8. ifc_audio_decoder_pull() : Dispatchable(DISPATCHABLE_VERSION) {}
  9. ~ifc_audio_decoder_pull() {}
  10. public:
  11. /* if possible, returns an upper bound on the number of frames used internally. pull decoders are most optimal if you use this to malloc your buffer */
  12. int GetFrameSize(size_t *frame_size) { return AudioDecoderPull_GetFrameSize(frame_size); }
  13. int GetMetadata(ifc_metadata **metadata) { return AudioDecoderPull_GetMetadata(metadata); }
  14. /* returns
  15. * NErr_EndOfFile when decode is done (frames_written will be valid, but probably 0)
  16. * NErr_Success on successful decode, but not end-of-file (frames_written will be valid)
  17. * anything else indicates a decode error */
  18. int Decode(void *buffer, size_t buffer_frames, size_t *frames_written) { return AudioDecoderPull_Decode(buffer, buffer_frames, frames_written); }
  19. /* You need to call Close() when you are done (even if you Release) because some implementations might have ifc_metadata being the same object */
  20. void Close() { AudioDecoderPull_Close(); }
  21. enum
  22. {
  23. DISPATCHABLE_VERSION=0,
  24. };
  25. private:
  26. virtual int WASABICALL AudioDecoderPull_GetFrameSize(size_t *frame_size)=0;
  27. virtual int WASABICALL AudioDecoderPull_GetMetadata(ifc_metadata **metadata)=0;
  28. virtual int WASABICALL AudioDecoderPull_Decode(void *buffer, size_t buffer_frames, size_t *frames_written)=0;
  29. virtual void WASABICALL AudioDecoderPull_Close()=0;
  30. };