diff options
author | Michael Maltese <[email protected]> | 2017-04-01 17:20:05 -0700 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2017-04-13 09:22:09 +1200 |
commit | eacf836bb374469c541956a29a933c3c264d93c0 (patch) | |
tree | 4a7c55655830805168dc489a12a1f749e6e501f8 /src/cubeb_utils.h | |
parent | 38d7491392df98034922d8c4e54c8131f19f5f62 (diff) | |
download | cubeb-eacf836bb374469c541956a29a933c3c264d93c0.tar.gz cubeb-eacf836bb374469c541956a29a933c3c264d93c0.zip |
wasapi: Use auto_array_wrapper for linear input buffer
Diffstat (limited to 'src/cubeb_utils.h')
-rw-r--r-- | src/cubeb_utils.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cubeb_utils.h b/src/cubeb_utils.h index e923d37..b889cc8 100644 --- a/src/cubeb_utils.h +++ b/src/cubeb_utils.h @@ -124,6 +124,11 @@ public: return data_; } + T * end() const + { + return data_ + length_; + } + const T& at(size_t index) const { assert(index < length_ && "out of range"); @@ -265,12 +270,17 @@ struct auto_array_wrapper { virtual void push_silence(size_t length) = 0; virtual bool pop(size_t length) = 0; virtual void * data() = 0; + virtual void * end() = 0; virtual void clear() = 0; + virtual bool reserve(size_t capacity) = 0; + virtual void set_length(size_t length) = 0; virtual ~auto_array_wrapper() {} }; template <typename T> struct auto_array_wrapper_impl : public auto_array_wrapper { + auto_array_wrapper_impl() {} + explicit auto_array_wrapper_impl(uint32_t size) : ar(size) {} @@ -295,10 +305,22 @@ struct auto_array_wrapper_impl : public auto_array_wrapper { return ar.data(); } + void * end() override { + return ar.end(); + } + void clear() override { ar.clear(); } + bool reserve(size_t capacity) override { + return ar.reserve(capacity); + } + + void set_length(size_t length) override { + ar.set_length(length); + } + ~auto_array_wrapper_impl() { ar.clear(); } |