From 86e5ae5cdb1a33d2f63a816aff06f6aa6d5e2cba Mon Sep 17 00:00:00 2001 From: hamb3r Date: Mon, 5 Oct 2026 05:13:21 +0300 Subject: [PATCH] test(avplayer): apply texture limits to active buffers --- core/libs/tests/GuestAvPlayer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/libs/tests/GuestAvPlayer.cpp b/core/libs/tests/GuestAvPlayer.cpp index 30cab7e67..e9981ef53 100644 --- a/core/libs/tests/GuestAvPlayer.cpp +++ b/core/libs/tests/GuestAvPlayer.cpp @@ -479,11 +479,17 @@ struct Allocations { Allocations allocations; +int ActiveTextureCountLocked() { + return static_cast(std::count_if(allocations.blocks.begin(), allocations.blocks.end(), [](const auto& allocation) { + return allocation.second.texture; + })); +} + void* Allocate(std::uint32_t alignment, std::uint32_t size, bool texture) { const auto aligned = static_cast(std::max(alignment, 16)); { std::lock_guard lock(allocations.mutex); - if (texture && allocations.textureLimit && allocations.textures >= *allocations.textureLimit) return nullptr; + if (texture && allocations.textureLimit && ActiveTextureCountLocked() >= *allocations.textureLimit) return nullptr; } void* memory = ::operator new(size, aligned); std::lock_guard lock(allocations.mutex); @@ -522,9 +528,7 @@ void SetTextureLimit(std::optional limit) { int TextureCount() { std::lock_guard lock(allocations.mutex); - return static_cast(std::count_if(allocations.blocks.begin(), allocations.blocks.end(), [](const auto& allocation) { - return allocation.second.texture; - })); + return ActiveTextureCountLocked(); } struct Events {