1
0

FilePlayback.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include "player/svc_playback.h"
  3. #include "nx/nxstring.h"
  4. #include "nx/nxfile.h"
  5. #include "nswasabi/ServiceName.h"
  6. #include "nswasabi/PlaybackBase.h"
  7. #include "ifc_fileplayback.h"
  8. #include "replaygain/ifc_replaygain_settings.h"
  9. #include "FileMetadata.h"
  10. // {60DB6A52-1A82-4C0D-A947-203549260758}
  11. static const GUID file_playback_guid =
  12. { 0x60db6a52, 0x1a82, 0x4c0d, { 0xa9, 0x47, 0x20, 0x35, 0x49, 0x26, 0x7, 0x58 } };
  13. class FilePlaybackService : public svc_playback
  14. {
  15. public:
  16. WASABI_SERVICE_NAME("File Playback");
  17. static GUID GetServiceGUID() { return file_playback_guid; }
  18. FilePlaybackService();
  19. int WASABICALL PlaybackService_CreatePlayback(unsigned int pass, nx_uri_t filename, ifc_player *player, ifc_playback **out_playback_object);
  20. };
  21. class FilePlayback : public PlaybackBase, public ifc_fileplayback_parent
  22. {
  23. public:
  24. FilePlayback();
  25. ~FilePlayback();
  26. ns_error_t Initialize(nx_uri_t filename, ifc_player *player);
  27. private:
  28. ns_error_t WASABICALL FilePlaybackParent_OpenOutput(const ifc_audioout::Parameters *parameters);
  29. ns_error_t WASABICALL FilePlaybackParent_Output(const void *audio_data, size_t audio_data_length, size_t *frames_consumed, double begin_position_seconds);
  30. ns_error_t WASABICALL FilePlaybackParent_OutputNonInterleaved(const void *audio_data, size_t audio_data_length, size_t *frames_consumed, double begin_position_seconds);
  31. ns_error_t WASABICALL FilePlaybackParent_OnMetadata(ifc_metadata *new_metadata);
  32. ifc_fileplayback *implementation;
  33. nx_file_t file;
  34. ifc_audioout *out;
  35. bool paused;
  36. double last_position;
  37. ns_error_t exact_length, exact_bitrate;
  38. ifc_audioout::Parameters parameters;
  39. const uint8_t **output_pointers;
  40. ifc_metadata *implementation_metadata;
  41. FileMetadataRead *metadata;
  42. ns_error_t Internal_Interrupt();
  43. ns_error_t OutputWait();
  44. ns_error_t WaitForClose();
  45. /* Thread function */
  46. static nx_thread_return_t NXTHREADCALL FilePlayerThreadFunction(nx_thread_parameter_t param);
  47. nx_thread_return_t NXTHREADCALL DecodeLoop();
  48. };