1
0

ifc_playback.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #include "foundation/dispatch.h"
  3. #include "foundation/error.h"
  4. #include "types.h"
  5. #include "svc_output.h"
  6. #include "ifc_playback_parameters.h"
  7. /* Note that since a typical ifc_playback implementation
  8. is running on another thread, most functions will always succeed (except for out of memory or thread creation problems)
  9. but might report an error later to the ifc_player object that was passed
  10. when creating the playback object */
  11. class NOVTABLE ifc_playback : public Wasabi2::Dispatchable
  12. {
  13. protected:
  14. ifc_playback() : Dispatchable(NUM_DISPATCH_CODES) {}
  15. ~ifc_playback() {}
  16. public:
  17. /* optionally call Cue before calling Play to set the start and end positions
  18. in a cuesheet situation, these will might also get called after
  19. you indicate that cue end position has been reached */
  20. int Cue(Agave_PositionType position_type, Agave_Position start, Agave_Position end) { return Playback_Cue(position_type, start, end); }
  21. // start only version of Cue
  22. int CueStart(Agave_PositionType position_type, Agave_Position start) { return Playback_CueStart(position_type, start); }
  23. // begins playback.
  24. int Play(svc_output *output, ifc_playback_parameters *secondary_parameters) { return Playback_Play(output, secondary_parameters); }
  25. int SeekSeconds(double seconds) { return Playback_SeekSeconds(seconds); }
  26. // called on user-initiated stop. not called if the playback object indiciated a stop (e.g. EOF)
  27. int Stop() { return Playback_Stop(); }
  28. int Pause() { return Playback_Pause(); }
  29. int Unpause() { return Playback_Unpause(); }
  30. /* called to shut things down.
  31. note that if your playback object is in a 'stopped' state,
  32. it should be prepared to receive Cue/Play call until Close() is called */
  33. int Close() { return Playback_Close(); }
  34. /* most of the time, you'll pass SetVolume and SetPan on to the output object
  35. but some special-use playback objects (e.g. analog CD playback) might have to implement this */
  36. // 0 to 1.0
  37. int SetVolume(float volume) { return Playback_SetVolume(volume); }
  38. // -1.0 to 1.0
  39. int SetPan(float pan) { return Playback_SetPan(pan); }
  40. /* most of the time, you'll ignore SetEQ
  41. but some special-use playback objects (e.g. analog CD playback) might have to implement this */
  42. int SetEQ(float preamp, int num_bands, float *bands) { return Playback_SetEQ(preamp, num_bands, bands); }
  43. enum
  44. {
  45. NUM_DISPATCH_CODES,
  46. };
  47. protected:
  48. virtual int WASABICALL Playback_Cue(Agave_PositionType position_type, Agave_Position start, Agave_Position end) { return NErr_NotImplemented; }
  49. virtual int WASABICALL Playback_CueStart(Agave_PositionType position_type, Agave_Position start) { return NErr_NotImplemented; }
  50. virtual int WASABICALL Playback_Play(svc_output *output, ifc_playback_parameters *secondary_parameters)=0;
  51. virtual int WASABICALL Playback_SeekSeconds(double seconds)=0;
  52. virtual int WASABICALL Playback_Stop()=0;
  53. virtual int WASABICALL Playback_Pause()=0;
  54. virtual int WASABICALL Playback_Unpause()=0;
  55. virtual int WASABICALL Playback_Close()=0;
  56. virtual int WASABICALL Playback_SetVolume(float volume) { return NErr_NotImplemented; }
  57. virtual int WASABICALL Playback_SetPan(float pan) { return NErr_NotImplemented; }
  58. virtual int WASABICALL Playback_SetEQ(float preamp, int num_bands, float *bands) { return NErr_NotImplemented; }
  59. };