From 347d6c4f4128a74f5fd6a9d5e587912c68d992b2 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Sun, 14 Jul 2024 21:09:54 +0200 Subject: [PATCH] Smarter "push_blit_handle" --- client/scenes/stream.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/client/scenes/stream.cpp b/client/scenes/stream.cpp index d3f81b8f..1af53e02 100644 --- a/client/scenes/stream.cpp +++ b/client/scenes/stream.cpp @@ -237,26 +237,18 @@ scenes::stream::~stream() void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_ptr handle) { - std::shared_ptr removed; - + assert(handle); if (!application::is_visible()) return; { std::unique_lock lock(decoder_mutex); - for (auto & i: decoders) + const auto stream = handle->feedback.stream_index; + if (stream < decoders.size()) { - if (i.decoder.get() == decoder) - { - std::swap(removed, i.latest_frames[0]); - for (size_t j = 1; j < i.latest_frames.size(); ++j) - { - std::swap(i.latest_frames[j - 1], i.latest_frames[j]); - } - handle->feedback.received_from_decoder = application::now(); - std::swap(i.latest_frames.back(), handle); - break; - } + assert(decoder == decoders[stream].decoder.get()); + handle->feedback.received_from_decoder = application::now(); + std::swap(handle, decoders[stream].latest_frames[handle->feedback.frame_index % decoders[stream].latest_frames.size()]); } if (state_ != state::streaming && std::all_of(decoders.begin(), decoders.end(), [](accumulator_images & i) { @@ -268,9 +260,9 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p } } - if (removed and not removed->feedback.blitted) + if (handle and not handle->feedback.blitted) { - send_feedback(removed->feedback); + send_feedback(handle->feedback); } }