]> git.sesse.net Git - nageru/blobdiff - nageru/pbo_frame_allocator.cpp
Fix a confusing variable name (frame_bytes sounded like a number of bytes).
[nageru] / nageru / pbo_frame_allocator.cpp
index ea17f1259fde4076320c9ebdb37da6c714a6c5f3..6211937b701f21dc2bdfbe916781f71f4629fb6b 100644 (file)
@@ -52,6 +52,7 @@ void PBOFrameAllocator::init_frame(size_t frame_idx, size_t frame_size, GLuint w
        Frame frame;
        frame.data = (uint8_t *)glMapBufferRange(buffer, 0, frame_size, permissions | map_bits | GL_MAP_PERSISTENT_BIT);
        frame.data2 = frame.data + frame_size / 2;
+       frame.data_copy = new uint8_t[frame_size];
        check_error();
        frame.size = frame_size;
        frame.userdata = &userdata[frame_idx];
@@ -214,6 +215,8 @@ PBOFrameAllocator::~PBOFrameAllocator()
 
 void PBOFrameAllocator::destroy_frame(Frame *frame)
 {
+       delete[] frame->data_copy;
+
        GLuint pbo = ((Userdata *)frame->userdata)->pbo;
        glBindBuffer(buffer, pbo);
        check_error();
@@ -258,7 +261,7 @@ bmusb::FrameAllocator::Frame PBOFrameAllocator::alloc_frame()
 {
         Frame vf;
 
-       unique_lock<mutex> lock(freelist_mutex);  // Meh.
+       lock_guard<mutex> lock(freelist_mutex);  // Meh.
        if (freelist.empty()) {
                printf("Frame overrun (no more spare PBO frames), dropping frame!\n");
        } else {
@@ -306,7 +309,7 @@ void PBOFrameAllocator::release_frame(Frame frame)
        }
 #endif
 
-       unique_lock<mutex> lock(freelist_mutex);
+       lock_guard<mutex> lock(freelist_mutex);
        freelist.push(frame);
        //--sumsum;
 }