X-Git-Url: https://git.sesse.net/?p=nageru;a=blobdiff_plain;f=nageru%2Fpbo_frame_allocator.cpp;fp=nageru%2Fpbo_frame_allocator.cpp;h=1000a727326604c2d30a2f7567b296f0af096833;hp=70675b1a630dfbdf1c30730f5134e9f014820c41;hb=0478d360a9aa0f816b21b0c6b1df91c1426c35d6;hpb=11d27b16a092efb99c045b21903da0eb7ee8c4d1 diff --git a/nageru/pbo_frame_allocator.cpp b/nageru/pbo_frame_allocator.cpp index 70675b1..1000a72 100644 --- a/nageru/pbo_frame_allocator.cpp +++ b/nageru/pbo_frame_allocator.cpp @@ -437,7 +437,15 @@ void PBOFrameAllocator::reconfigure(bmusb::PixelFormat pixel_format, return; } - size_t old_num_queued_frames = this->num_queued_frames; + lock_guard lock(freelist_mutex); + lingering_generations[generation] = LingeringGeneration{ move(userdata), this->num_queued_frames }; + ++generation; + + while (!freelist.empty()) { + Frame frame = freelist.front(); + freelist.pop(); + destroy_frame(&frame); + } this->pixel_format = pixel_format; this->frame_size = frame_size; @@ -450,16 +458,6 @@ void PBOFrameAllocator::reconfigure(bmusb::PixelFormat pixel_format, this->permissions = permissions; this->map_bits = map_bits; - lock_guard lock(freelist_mutex); - lingering_generations[generation] = LingeringGeneration{ move(userdata), old_num_queued_frames }; - ++generation; - - while (!freelist.empty()) { - Frame frame = freelist.front(); - freelist.pop(); - destroy_frame(&frame); - } - userdata.reset(new Userdata[num_queued_frames]); for (size_t i = 0; i < num_queued_frames; ++i) { init_frame(i, frame_size, width, height, permissions, map_bits, generation);