Fix some memory leaks on export.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 1 Jan 2019 00:30:58 +0000 (01:30 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 1 Jan 2019 00:30:58 +0000 (01:30 +0100)
futatabi/player.cpp
futatabi/video_stream.cpp

index cebc317..12b1616 100644 (file)
@@ -506,11 +506,12 @@ Player::Player(JPEGFrameView *destination, Player::StreamOutput stream_output, A
 Player::~Player()
 {
        should_quit = true;
+       new_clip_changed.notify_all();
+       player_thread.join();
+
        if (video_stream != nullptr) {
                video_stream->stop();
        }
-       new_clip_changed.notify_all();
-       player_thread.join();
 }
 
 void Player::play(const vector<ClipWithID> &clips)
index 59ab8bf..8b29794 100644 (file)
@@ -241,6 +241,30 @@ VideoStream::~VideoStream()
        if (last_flow_tex != 0) {
                compute_flow->release_texture(last_flow_tex);
        }
+
+       for (const unique_ptr<InterpolatedFrameResources> &resource : interpolate_resources) {
+               glUnmapNamedBuffer(resource->pbo);
+               check_error();
+               glDeleteBuffers(1, &resource->pbo);
+               check_error();
+               glDeleteFramebuffers(2, resource->input_fbos);
+               check_error();
+               glDeleteFramebuffers(1, &resource->fade_fbo);
+               check_error();
+               glDeleteTextures(1, &resource->input_tex);
+               check_error();
+               glDeleteTextures(1, &resource->gray_tex);
+               check_error();
+               glDeleteTextures(1, &resource->fade_y_output_tex);
+               check_error();
+               glDeleteTextures(1, &resource->fade_cbcr_output_tex);
+               check_error();
+               glDeleteTextures(1, &resource->cb_tex);
+               check_error();
+               glDeleteTextures(1, &resource->cr_tex);
+               check_error();
+       }
+       assert(interpolate_resources.size() == num_interpolate_slots);
 }
 
 void VideoStream::start()