Compare commits

...

2 commits

Author SHA1 Message Date
CamilleLaVey
32e63b5fa2 fix build 2026-03-08 12:46:31 -04:00
CamilleLaVey
2e89bb890a [android] Modified compiliance of Android's Surface in older API's 2026-03-08 12:31:49 -04:00
2 changed files with 29 additions and 8 deletions

View file

@ -212,18 +212,27 @@ void EmuWindow_Android::UpdateFrameRateHint() {
using SetFrameRateWithChangeStrategyFn = using SetFrameRateWithChangeStrategyFn =
int32_t (*)(ANativeWindow*, float, int8_t, int8_t); int32_t (*)(ANativeWindow*, float, int8_t, int8_t);
using SetFrameRateFn = int32_t (*)(ANativeWindow*, float, int8_t);
static const auto set_frame_rate_with_change_strategy = static const auto set_frame_rate_with_change_strategy =
reinterpret_cast<SetFrameRateWithChangeStrategyFn>( reinterpret_cast<SetFrameRateWithChangeStrategyFn>(
dlsym(RTLD_DEFAULT, "ANativeWindow_setFrameRateWithChangeStrategy")); dlsym(RTLD_DEFAULT, "ANativeWindow_setFrameRateWithChangeStrategy"));
static const auto set_frame_rate = reinterpret_cast<SetFrameRateFn>(
dlsym(RTLD_DEFAULT, "ANativeWindow_setFrameRate"));
if (!set_frame_rate_with_change_strategy) { constexpr int8_t FrameRateCompatibilityDefault = 0;
constexpr int8_t ChangeFrameRateOnlyIfSeamless = 0;
int32_t result = -1;
if (set_frame_rate_with_change_strategy) {
result = set_frame_rate_with_change_strategy(surface, frame_rate_hint,
FrameRateCompatibilityDefault,
ChangeFrameRateOnlyIfSeamless);
} else if (set_frame_rate) {
result = set_frame_rate(surface, frame_rate_hint, FrameRateCompatibilityDefault);
} else {
return; return;
} }
const auto result = set_frame_rate_with_change_strategy(
surface, frame_rate_hint,
static_cast<int8_t>(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT),
static_cast<int8_t>(ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS));
if (result != 0) { if (result != 0) {
LOG_DEBUG(Frontend, "Failed to update Android surface frame rate hint: {}", result); LOG_DEBUG(Frontend, "Failed to update Android surface frame rate hint: {}", result);
return; return;

View file

@ -9,6 +9,10 @@
#include <limits> #include <limits>
#include <vector> #include <vector>
#ifdef __ANDROID__
#include <android/api-level.h>
#endif
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/settings.h" #include "common/settings.h"
#include "common/settings_enums.h" #include "common/settings_enums.h"
@ -170,9 +174,7 @@ bool Swapchain::AcquireNextImage() {
break; break;
} }
#ifdef __ANDROID__ const auto wait_with_frame_pacing = [this] {
scheduler.Wait(resource_ticks[image_index]);
#else
switch (Settings::values.frame_pacing_mode.GetValue()) { switch (Settings::values.frame_pacing_mode.GetValue()) {
case Settings::FramePacingMode::Target_Auto: case Settings::FramePacingMode::Target_Auto:
scheduler.Wait(resource_ticks[image_index]); scheduler.Wait(resource_ticks[image_index]);
@ -190,6 +192,16 @@ bool Swapchain::AcquireNextImage() {
scheduler.Wait(resource_ticks[image_index], 120.0); scheduler.Wait(resource_ticks[image_index], 120.0);
break; break;
} }
};
#ifdef __ANDROID__
if (android_get_device_api_level() >= 30) {
scheduler.Wait(resource_ticks[image_index]);
} else {
wait_with_frame_pacing();
}
#else
wait_with_frame_pacing();
#endif #endif
resource_ticks[image_index] = scheduler.CurrentTick(); resource_ticks[image_index] = scheduler.CurrentTick();