- RefCountedFrame(const FrameAllocator::Frame &frame)
- : RefCountedFrameBase(new FrameAllocator::Frame(frame), release_refcounted_frame) {}
+ RefCountedFrame(const bmusb::FrameAllocator::Frame &frame)
+ : RefCountedFrameBase(new bmusb::FrameAllocator::Frame(frame), release_refcounted_frame) {}
+};
+
+// Similar to RefCountedFrame, but as unique_ptr instead of shared_ptr.
+
+struct Unique_frame_deleter {
+ void operator() (bmusb::FrameAllocator::Frame *frame) const {
+ release_refcounted_frame(frame);
+ }
+};
+
+typedef std::unique_ptr<bmusb::FrameAllocator::Frame, Unique_frame_deleter>
+ UniqueFrameBase;
+
+class UniqueFrame : public UniqueFrameBase {
+public:
+ UniqueFrame() {}
+
+ UniqueFrame(const bmusb::FrameAllocator::Frame &frame)
+ : UniqueFrameBase(new bmusb::FrameAllocator::Frame(frame)) {}
+
+ bmusb::FrameAllocator::Frame get_and_release()
+ {
+ bmusb::FrameAllocator::Frame *ptr = release();
+ bmusb::FrameAllocator::Frame frame = *ptr;
+ delete ptr;
+ return frame;
+ }