X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fpbo_frame_allocator.cpp;h=6211937b701f21dc2bdfbe916781f71f4629fb6b;hb=3a4f297238b16eb74c1dc9fee60b628d9a6d7547;hp=ea17f1259fde4076320c9ebdb37da6c714a6c5f3;hpb=9b7d691b4cc5db7dbfc18c82e86c1207fcac4722;p=nageru diff --git a/nageru/pbo_frame_allocator.cpp b/nageru/pbo_frame_allocator.cpp index ea17f12..6211937 100644 --- a/nageru/pbo_frame_allocator.cpp +++ b/nageru/pbo_frame_allocator.cpp @@ -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 lock(freelist_mutex); // Meh. + lock_guard 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 lock(freelist_mutex); + lock_guard lock(freelist_mutex); freelist.push(frame); //--sumsum; }