Compare commits

..

1 commit

Author SHA1 Message Date
lizzie
076a1fda9d [android] try fix playtime datarace (using nullptr) by just zealously checking for nullptr
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-10-22 18:42:17 +02:00
4 changed files with 25 additions and 33 deletions

View file

@ -183,8 +183,7 @@ option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF)
option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF)
set(YUZU_QT_MIRROR "" CACHE STRING "What mirror to use for downloading the bundled Qt libraries") set(YUZU_QT_MIRROR "" CACHE STRING "What mirror to use for downloading the bundled Qt libraries")
# FreeBSD doesn't have a cubeb port yet, vendoring it isn't required (it's optional anyways) option(ENABLE_CUBEB "Enables the cubeb audio backend" ON)
cmake_dependent_option(ENABLE_CUBEB "Enables the cubeb audio backend" ON "NOT PLATFORM_FREEBSD" OFF)
set(EXT_DEFAULT OFF) set(EXT_DEFAULT OFF)
if (MSVC OR ANDROID) if (MSVC OR ANDROID)
@ -199,8 +198,7 @@ cmake_dependent_option(YUZU_USE_EXTERNAL_FFMPEG "Build FFmpeg from source" "${PL
# sirit # sirit
option(YUZU_USE_BUNDLED_SIRIT "Download bundled sirit" ${EXT_DEFAULT}) option(YUZU_USE_BUNDLED_SIRIT "Download bundled sirit" ${EXT_DEFAULT})
# Re-allow on FreeBSD once its on mainline ports cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "NOT ANDROID" OFF)
cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "WIN32 OR PLATFORM_LINUX OR APPLE" OFF)
cmake_dependent_option(ENABLE_OPENGL "Enable OpenGL" ON "NOT WIN32 OR NOT ARCHITECTURE_arm64" OFF) cmake_dependent_option(ENABLE_OPENGL "Enable OpenGL" ON "NOT WIN32 OR NOT ARCHITECTURE_arm64" OFF)
mark_as_advanced(FORCE ENABLE_OPENGL) mark_as_advanced(FORCE ENABLE_OPENGL)

View file

@ -743,11 +743,8 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmptyUserDirectory(JNIEnv*
void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerInit(JNIEnv* env, jobject obj) { void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerInit(JNIEnv* env, jobject obj) {
// for some reason the full user directory isnt initialized in Android, so we need to create it // for some reason the full user directory isnt initialized in Android, so we need to create it
const auto play_time_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::PlayTimeDir); const auto play_time_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::PlayTimeDir);
if (!Common::FS::IsDir(play_time_dir)) { if (!Common::FS::IsDir(play_time_dir) && !Common::FS::CreateDir(play_time_dir))
if (!Common::FS::CreateDir(play_time_dir)) {
LOG_WARNING(Frontend, "Failed to create play time directory"); LOG_WARNING(Frontend, "Failed to create play time directory");
}
}
play_time_manager = std::make_unique<PlayTime::PlayTimeManager>(); play_time_manager = std::make_unique<PlayTime::PlayTimeManager>();
} }
@ -760,13 +757,16 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerStart(JNIEnv* env, job
} }
void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerStop(JNIEnv* env, jobject obj) { void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerStop(JNIEnv* env, jobject obj) {
if (play_time_manager)
play_time_manager->Stop(); play_time_manager->Stop();
} }
jlong Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerGetPlayTime(JNIEnv* env, jobject obj, jlong Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerGetPlayTime(JNIEnv* env, jobject obj, jstring jprogramId) {
jstring jprogramId) { if (play_time_manager) {
u64 program_id = EmulationSession::GetProgramId(env, jprogramId); u64 program_id = EmulationSession::GetProgramId(env, jprogramId);
return play_time_manager->GetPlayTime(program_id); return play_time_manager->GetPlayTime(program_id);
}
return 0UL;
} }
jlong Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerGetCurrentTitleId(JNIEnv* env, jlong Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerGetCurrentTitleId(JNIEnv* env,
@ -776,17 +776,17 @@ jlong Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerGetCurrentTitleId(JNI
void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerResetProgramPlayTime(JNIEnv* env, jobject obj, void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerResetProgramPlayTime(JNIEnv* env, jobject obj,
jstring jprogramId) { jstring jprogramId) {
u64 program_id = EmulationSession::GetProgramId(env, jprogramId);
if (play_time_manager) { if (play_time_manager) {
u64 program_id = EmulationSession::GetProgramId(env, jprogramId);
play_time_manager->ResetProgramPlayTime(program_id); play_time_manager->ResetProgramPlayTime(program_id);
} }
} }
void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerSetPlayTime(JNIEnv* env, jobject obj, void Java_org_yuzu_yuzu_1emu_NativeLibrary_playTimeManagerSetPlayTime(JNIEnv* env, jobject obj,
jstring jprogramId, jlong playTimeSeconds) { jstring jprogramId, jlong playTimeSeconds) {
u64 program_id = EmulationSession::GetProgramId(env, jprogramId);
if (play_time_manager) { if (play_time_manager) {
play_time_manager->SetPlayTime(program_id, static_cast<u64>(playTimeSeconds)); u64 program_id = EmulationSession::GetProgramId(env, jprogramId);
play_time_manager->SetPlayTime(program_id, u64(playTimeSeconds));
} }
} }

View file

@ -1,6 +1,3 @@
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2018 yuzu Emulator Project # SPDX-FileCopyrightText: 2018 yuzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
@ -86,7 +83,7 @@ if (ENABLE_LIBUSB)
drivers/gc_adapter.h drivers/gc_adapter.h
) )
target_link_libraries(input_common PRIVATE libusb::usb) target_link_libraries(input_common PRIVATE libusb::usb)
target_compile_definitions(input_common PRIVATE ENABLE_LIBUSB) target_compile_definitions(input_common PRIVATE HAVE_LIBUSB)
endif() endif()
create_target_directory_groups(input_common) create_target_directory_groups(input_common)

View file

@ -1,6 +1,3 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2017 Citra Emulator Project // SPDX-FileCopyrightText: 2017 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
@ -22,7 +19,7 @@
#include "input_common/input_poller.h" #include "input_common/input_poller.h"
#include "input_common/main.h" #include "input_common/main.h"
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
#include "input_common/drivers/gc_adapter.h" #include "input_common/drivers/gc_adapter.h"
#endif #endif
#ifdef HAVE_SDL2 #ifdef HAVE_SDL2
@ -79,7 +76,7 @@ struct InputSubsystem::Impl {
RegisterEngine("keyboard", keyboard); RegisterEngine("keyboard", keyboard);
RegisterEngine("mouse", mouse); RegisterEngine("mouse", mouse);
RegisterEngine("touch", touch_screen); RegisterEngine("touch", touch_screen);
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
RegisterEngine("gcpad", gcadapter); RegisterEngine("gcpad", gcadapter);
#endif #endif
RegisterEngine("cemuhookudp", udp_client); RegisterEngine("cemuhookudp", udp_client);
@ -113,7 +110,7 @@ struct InputSubsystem::Impl {
UnregisterEngine(keyboard); UnregisterEngine(keyboard);
UnregisterEngine(mouse); UnregisterEngine(mouse);
UnregisterEngine(touch_screen); UnregisterEngine(touch_screen);
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
UnregisterEngine(gcadapter); UnregisterEngine(gcadapter);
#endif #endif
UnregisterEngine(udp_client); UnregisterEngine(udp_client);
@ -148,7 +145,7 @@ struct InputSubsystem::Impl {
auto android_devices = android->GetInputDevices(); auto android_devices = android->GetInputDevices();
devices.insert(devices.end(), android_devices.begin(), android_devices.end()); devices.insert(devices.end(), android_devices.begin(), android_devices.end());
#endif #endif
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
auto gcadapter_devices = gcadapter->GetInputDevices(); auto gcadapter_devices = gcadapter->GetInputDevices();
devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end()); devices.insert(devices.end(), gcadapter_devices.begin(), gcadapter_devices.end());
#endif #endif
@ -181,7 +178,7 @@ struct InputSubsystem::Impl {
return android; return android;
} }
#endif #endif
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
if (engine == gcadapter->GetEngineName()) { if (engine == gcadapter->GetEngineName()) {
return gcadapter; return gcadapter;
} }
@ -266,7 +263,7 @@ struct InputSubsystem::Impl {
return true; return true;
} }
#endif #endif
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
if (engine == gcadapter->GetEngineName()) { if (engine == gcadapter->GetEngineName()) {
return true; return true;
} }
@ -297,7 +294,7 @@ struct InputSubsystem::Impl {
#ifdef ANDROID #ifdef ANDROID
android->BeginConfiguration(); android->BeginConfiguration();
#endif #endif
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
gcadapter->BeginConfiguration(); gcadapter->BeginConfiguration();
#endif #endif
udp_client->BeginConfiguration(); udp_client->BeginConfiguration();
@ -313,7 +310,7 @@ struct InputSubsystem::Impl {
#ifdef ANDROID #ifdef ANDROID
android->EndConfiguration(); android->EndConfiguration();
#endif #endif
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
gcadapter->EndConfiguration(); gcadapter->EndConfiguration();
#endif #endif
udp_client->EndConfiguration(); udp_client->EndConfiguration();
@ -346,7 +343,7 @@ struct InputSubsystem::Impl {
std::shared_ptr<VirtualAmiibo> virtual_amiibo; std::shared_ptr<VirtualAmiibo> virtual_amiibo;
std::shared_ptr<VirtualGamepad> virtual_gamepad; std::shared_ptr<VirtualGamepad> virtual_gamepad;
#ifdef ENABLE_LIBUSB #ifdef HAVE_LIBUSB
std::shared_ptr<GCAdapter> gcadapter; std::shared_ptr<GCAdapter> gcadapter;
#endif #endif