1
0

svc_decode.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #pragma once
  2. #include "foundation/dispatch.h"
  3. #include "audio/parameters.h"
  4. #include "audio/ifc_audio_decoder_callback.h"
  5. #include "audio/ifc_audio_decoder_pull.h"
  6. #include "nx/nxuri.h"
  7. /* if you return NErr_TryAgain, you will be called again with pass=1 after all other services get a chance at the file */
  8. // DA3BB978-4A85-409F-B67C-10E3E1CF73CB
  9. static const GUID decode_service_type_guid =
  10. { 0xDA3BB978, 0x4A85, 0x409F, { 0xB6, 0x7C, 0x10, 0xE3, 0xE1, 0xCF, 0x73, 0xCB } };
  11. class svc_decode : public Wasabi2::Dispatchable
  12. {
  13. protected:
  14. svc_decode() : Dispatchable(DISPATCHABLE_VERSION) {}
  15. ~svc_decode() {}
  16. public:
  17. static GUID GetServiceType() { return decode_service_type_guid; }
  18. /*
  19. * return values for the CreateAudioDecoder family of functions
  20. * * NErr_Success: Decoder successfully created
  21. * * NErr_False: File type not supported by this decoder
  22. * * NErr_UnsupportedInterface: File type is supported by this decoder, but not the particular style (callback, pull, packet).
  23. * * Any other code is interpreted as an error and enumeration will stop!
  24. */
  25. /* Flags are defined in ifc_audio_decoder_callback */
  26. int CreateAudioDecoder_Callback(ifc_audio_decoder_callback **decoder, nx_uri_t filename, nsaudio::Parameters *parameters, int flags) { return DecodeService_CreateAudioDecoder_Callback(decoder, filename, parameters, flags); }
  27. int CreateAudioDecoder_Pull(ifc_audio_decoder_pull **decoder, nx_uri_t filename, nsaudio::Parameters *parameters, int flags) { return DecodeService_CreateAudioDecoder_Pull(decoder, filename, parameters, flags); }
  28. int CreateAudioDecoder_Callback(unsigned int pass, ifc_audio_decoder_callback **decoder, nx_uri_t filename, nsaudio::Parameters *parameters, int flags)
  29. {
  30. if (dispatchable_version == 0)
  31. {
  32. if (pass == 0)
  33. return DecodeService_CreateAudioDecoder_Callback(decoder, filename, parameters, flags);
  34. else
  35. return NErr_False;
  36. }
  37. else
  38. return DecodeService_CreateAudioDecoder_Callback(pass, decoder, filename, parameters, flags);
  39. }
  40. int CreateAudioDecoder_Pull(unsigned int pass, ifc_audio_decoder_pull **decoder, nx_uri_t filename, nsaudio::Parameters *parameters, int flags)
  41. {
  42. if (dispatchable_version == 0)
  43. {
  44. if (pass == 0)
  45. return DecodeService_CreateAudioDecoder_Pull(decoder, filename, parameters, flags);
  46. else
  47. return NErr_False;
  48. }
  49. else
  50. return DecodeService_CreateAudioDecoder_Pull(pass, decoder, filename, parameters, flags);
  51. }
  52. enum
  53. {
  54. /* Additional flags are defined in the specific decoder interface (e.g. ifc_audio_decoder_pull.h)
  55. They should start at 0x80000001 to ensure uniqueness */
  56. FLAG_NO_METADATA= (1 << 0), // tells the decoder that it doesn't need to parse metadata
  57. FLAG_VALIDATION = (1 << 1), // turns on codec/file-format specific extra validation checks. for most implementations this means turning on CRC checking
  58. };
  59. enum
  60. {
  61. DISPATCHABLE_VERSION=1,
  62. };
  63. private:
  64. /* these two no longer have to be implemented */
  65. virtual int WASABICALL DecodeService_CreateAudioDecoder_Callback(ifc_audio_decoder_callback **decoder, nx_uri_t filename, nsaudio::Parameters *parameters, int flags) { return DecodeService_CreateAudioDecoder_Callback(0, decoder, filename, parameters, flags); }
  66. virtual int WASABICALL DecodeService_CreateAudioDecoder_Pull(ifc_audio_decoder_pull **decoder, nx_uri_t filename, nsaudio::Parameters *parameters, int flags) { return DecodeService_CreateAudioDecoder_Pull(0, decoder, filename, parameters, flags); }
  67. virtual int WASABICALL DecodeService_CreateAudioDecoder_Callback(unsigned int pass, ifc_audio_decoder_callback **decoder, nx_uri_t filename, nsaudio::Parameters *parameters, int flags) { return NErr_NotImplemented; }
  68. virtual int WASABICALL DecodeService_CreateAudioDecoder_Pull(unsigned int pass, ifc_audio_decoder_pull **decoder, nx_uri_t filename, nsaudio::Parameters *parameters, int flags) { return NErr_NotImplemented; }
  69. };