ifc_audiostream.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef NULLSOFT_AGAVE_IFC_AUDIOSTREAM_H
  2. #define NULLSOFT_AGAVE_IFC_AUDIOSTREAM_H
  3. #include <bfc/dispatch.h>
  4. class ifc_audiostream : public Dispatchable
  5. {
  6. protected:
  7. ifc_audiostream() {}
  8. ~ifc_audiostream() {}
  9. public:
  10. /* returns number of bytes written to buffer.
  11. * a return value of 0 means EOF
  12. */
  13. size_t ReadAudio(void *buffer, size_t sizeBytes);
  14. size_t ReadAudio(void *buffer, size_t, int *killswitch, int *errorCode);
  15. /* Seeks to a point in the stream in milliseconds
  16. * returns TRUE if successful, FALSE otherwise
  17. */
  18. int SeekToTimeMs(int millisecs);
  19. /* returns 1 if this stream is seekable using SeekToTime, 0 otherwise
  20. */
  21. int CanSeek();
  22. public:
  23. DISPATCH_CODES
  24. {
  25. IFC_AUDIOSTREAM_READAUDIO = 10,
  26. IFC_AUDIOSTREAM_READAUDIO2 = 11,
  27. IFC_AUDIOSTREAM_SEEKTOTIMEMS = 20,
  28. IFC_AUDIOSTREAM_CANSEEK = 30,
  29. };
  30. };
  31. inline size_t ifc_audiostream::ReadAudio(void *buffer, size_t sizeBytes)
  32. {
  33. return _call(IFC_AUDIOSTREAM_READAUDIO, (size_t)0, buffer, sizeBytes);
  34. }
  35. inline size_t ifc_audiostream::ReadAudio(void *buffer, size_t sizeBytes, int *killswitch, int *errorCode)
  36. {
  37. void *params[4] = { &buffer, &sizeBytes, &killswitch, &errorCode};
  38. size_t retval;
  39. if (_dispatch(IFC_AUDIOSTREAM_READAUDIO2, &retval, params, 4))
  40. return retval;
  41. else
  42. {
  43. *errorCode=0;
  44. return ReadAudio(buffer, sizeBytes);
  45. }
  46. }
  47. inline int ifc_audiostream::SeekToTimeMs(int millisecs)
  48. {
  49. return _call(IFC_AUDIOSTREAM_SEEKTOTIMEMS, (int)0, millisecs);
  50. }
  51. inline int ifc_audiostream::CanSeek()
  52. {
  53. return _call(IFC_AUDIOSTREAM_CANSEEK, (int)0);
  54. }
  55. #endif