diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Agave/DecodeFile/ifc_audiostream.h | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Agave/DecodeFile/ifc_audiostream.h')
-rw-r--r-- | Src/Agave/DecodeFile/ifc_audiostream.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/Src/Agave/DecodeFile/ifc_audiostream.h b/Src/Agave/DecodeFile/ifc_audiostream.h new file mode 100644 index 00000000..586d704c --- /dev/null +++ b/Src/Agave/DecodeFile/ifc_audiostream.h @@ -0,0 +1,65 @@ +#ifndef NULLSOFT_AGAVE_IFC_AUDIOSTREAM_H +#define NULLSOFT_AGAVE_IFC_AUDIOSTREAM_H + +#include <bfc/dispatch.h> + +class ifc_audiostream : public Dispatchable +{ +protected: + ifc_audiostream() {} + ~ifc_audiostream() {} +public: + /* returns number of bytes written to buffer. + * a return value of 0 means EOF + */ + size_t ReadAudio(void *buffer, size_t sizeBytes); + + size_t ReadAudio(void *buffer, size_t, int *killswitch, int *errorCode); + /* Seeks to a point in the stream in milliseconds + * returns TRUE if successful, FALSE otherwise + */ + int SeekToTimeMs(int millisecs); + + /* returns 1 if this stream is seekable using SeekToTime, 0 otherwise + */ + int CanSeek(); +public: + DISPATCH_CODES + { + IFC_AUDIOSTREAM_READAUDIO = 10, + IFC_AUDIOSTREAM_READAUDIO2 = 11, + IFC_AUDIOSTREAM_SEEKTOTIMEMS = 20, + IFC_AUDIOSTREAM_CANSEEK = 30, + }; +}; + +inline size_t ifc_audiostream::ReadAudio(void *buffer, size_t sizeBytes) +{ + return _call(IFC_AUDIOSTREAM_READAUDIO, (size_t)0, buffer, sizeBytes); +} + +inline size_t ifc_audiostream::ReadAudio(void *buffer, size_t sizeBytes, int *killswitch, int *errorCode) +{ + void *params[4] = { &buffer, &sizeBytes, &killswitch, &errorCode}; + size_t retval; + + if (_dispatch(IFC_AUDIOSTREAM_READAUDIO2, &retval, params, 4)) + return retval; + else + { + *errorCode=0; + return ReadAudio(buffer, sizeBytes); + } +} + +inline int ifc_audiostream::SeekToTimeMs(int millisecs) +{ + return _call(IFC_AUDIOSTREAM_SEEKTOTIMEMS, (int)0, millisecs); +} + +inline int ifc_audiostream::CanSeek() +{ + return _call(IFC_AUDIOSTREAM_CANSEEK, (int)0); +} + +#endif |