Free dummy images when they are no longer needed

This commit is contained in:
Cameron Gutman
2023-04-04 21:51:24 -05:00
parent bd443395c6
commit 036aa2e470

View File

@@ -1317,11 +1317,15 @@ namespace video {
auto packets = mail::man->queue<packet_t>(mail::video_packets); auto packets = mail::man->queue<packet_t>(mail::video_packets);
auto idr_events = mail->event<bool>(mail::idr); auto idr_events = mail->event<bool>(mail::idr);
// Load a dummy image into the AVFrame to ensure we have something to encode {
// even if we timeout waiting on the first frame. // Load a dummy image into the AVFrame to ensure we have something to encode
auto dummy_img = disp->alloc_img(); // even if we timeout waiting on the first frame. This is a relatively large
if (!dummy_img || disp->dummy_img(dummy_img.get()) || session->device->convert(*dummy_img)) { // allocation which can be freed immediately after convert(), so we do this
return; // in a separate scope.
auto dummy_img = disp->alloc_img();
if (!dummy_img || disp->dummy_img(dummy_img.get()) || session->device->convert(*dummy_img)) {
return;
}
} }
while (true) { while (true) {
@@ -1728,12 +1732,12 @@ namespace video {
return -1; return -1;
} }
auto img = disp->alloc_img(); {
if (!img || disp->dummy_img(img.get())) { // Image buffers are large, so we use a separate scope to free it immediately after convert()
return -1; auto img = disp->alloc_img();
} if (!img || disp->dummy_img(img.get()) || session->device->convert(*img)) {
if (session->device->convert(*img)) { return -1;
return -1; }
} }
auto frame = session->device->frame; auto frame = session->device->frame;