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/Plugins/Input/in_wmvdrm/Remaining.h | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Plugins/Input/in_wmvdrm/Remaining.h')
-rw-r--r-- | Src/Plugins/Input/in_wmvdrm/Remaining.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/Src/Plugins/Input/in_wmvdrm/Remaining.h b/Src/Plugins/Input/in_wmvdrm/Remaining.h new file mode 100644 index 00000000..acfbbffe --- /dev/null +++ b/Src/Plugins/Input/in_wmvdrm/Remaining.h @@ -0,0 +1,68 @@ +#ifndef NULLSOFT_REMAININGH +#define NULLSOFT_REMAININGH +#include <assert.h> +#include <memory.h> +/* this class is used to store leftover samples */ + +class Remaining +{ +public: + Remaining() + : store(0), size(0), used(0) + {} + + void Allocate(unsigned long _size) + { + assert(_size); + used=0; + size=_size; + if (store) + delete [] store; + store = new unsigned char [size]; + } + + /* Saves the incoming data and updates the pointer positions */ + template <class storage_t> + void UpdatingWrite(storage_t *&data, unsigned long &bytes) + { + unsigned long bytesToWrite = min(bytes, SizeRemaining()); + Write(data, bytesToWrite); + assert(bytesToWrite); + data = (storage_t *)((char *)data + bytesToWrite); + bytes -= bytesToWrite; + } + + void Write(void *data, unsigned long bytes) + { + unsigned char *copy = (unsigned char *)store; + copy+=used; + memcpy(copy, data, bytes); + used+=bytes; + } + + unsigned long SizeRemaining() + { + return size-used; + } + + bool Empty() + { + return !used; + } + bool Full() + { + return size == used; + } + void *GetData() + { + return (void *)store; + } + + void Flush() + { + used=0; + } + unsigned char *store; + long size, used; +}; +#endif
\ No newline at end of file |