]> git.sesse.net Git - nageru/blobdiff - ref_counted_frame.h
Support audio-only FFmpeg inputs. Somewhat wonky, though.
[nageru] / ref_counted_frame.h
index cb055f9e3a62ea49bf8d8a963d2aa8b07ea87ef5..b3a8187b89411978ec8e9c4a492f2e2d997e71cd 100644 (file)
@@ -6,6 +6,13 @@
 //
 // Note that the important point isn't really the pointer to the Frame itself,
 // it's the resources it's representing that need to go back to the allocator.
+//
+// FIXME: There's an issue here in that we could be releasing a frame while
+// we're still uploading textures from it, causing it to be written to in
+// another thread. (Thankfully, it goes to the back of the queue, and there's
+// usually a render in-between, meaning it's fairly unlikely that someone
+// actually managed to get to that race.) We should probably have some mechanism
+// for registering fences.
 
 #include <memory>
 
@@ -44,9 +51,13 @@ public:
        bmusb::FrameAllocator::Frame get_and_release()
        {
                bmusb::FrameAllocator::Frame *ptr = release();
-               bmusb::FrameAllocator::Frame frame = *ptr;
-               delete ptr;
-               return frame;
+               if (ptr == nullptr) {
+                       return bmusb::FrameAllocator::Frame();
+               } else {
+                       bmusb::FrameAllocator::Frame frame = *ptr;
+                       delete ptr;
+                       return frame;
+               }
        }
 };