diff --git a/Common/File/VFS/VFS.cpp b/Common/File/VFS/VFS.cpp index 041616c14ee6..0b6636d83e83 100644 --- a/Common/File/VFS/VFS.cpp +++ b/Common/File/VFS/VFS.cpp @@ -63,7 +63,7 @@ uint8_t *VFS::ReadFile(const char *filename, size_t *size) { if (!fileSystemFound) { ERROR_LOG(IO, "Missing filesystem for '%s'", filename); } // Otherwise, the file was just missing. No need to log. - return 0; + return nullptr; } bool VFS::GetFileListing(const char *path, std::vector *listing, const char *filter) { diff --git a/Core/FrameTiming.cpp b/Core/FrameTiming.cpp index 3fb6e34003bc..b6816e5c5840 100644 --- a/Core/FrameTiming.cpp +++ b/Core/FrameTiming.cpp @@ -81,6 +81,8 @@ void FrameTiming::PostSubmit() { } Draw::PresentMode ComputePresentMode(Draw::DrawContext *draw, int *interval) { + _assert_(draw); + Draw::PresentMode mode = Draw::PresentMode::FIFO; if (draw->GetDeviceCaps().presentModesSupported & (Draw::PresentMode::IMMEDIATE | Draw::PresentMode::MAILBOX)) { diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index ad0b6e5153f4..8f142bb456ad 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -312,6 +312,7 @@ class PsmfStream { psmf->EPMap.clear(); for (u32 i = 0; i < psmf->EPMapEntriesNum; i++) { + // TODO: Should look into validating these offsets. Got a crash report here. const u8 *const entryAddr = data + psmf->EPMapOffset + EP_MAP_STRIDE * i; PsmfEntry entry; entry.EPIndex = entryAddr[0]; diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index c00c2cbc2f03..ef56105a8c15 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -113,11 +113,11 @@ namespace Reporting static std::condition_variable crcCond; static Path crcFilename; static std::map crcResults; - static volatile bool crcPending = false; - static volatile bool crcCancel = false; + static std::atomic crcPending = false; + static std::atomic crcCancel = false; static std::thread crcThread; - static u32 CalculateCRC(BlockDevice *blockDevice, volatile bool *cancel) { + static u32 CalculateCRC(BlockDevice *blockDevice, std::atomic *cancel) { auto ga = GetI18NCategory(I18NCat::GAME); u32 crc = crc32(0, Z_NULL, 0); @@ -162,7 +162,6 @@ namespace Reporting crcResults[crcFilename] = crc; crcPending = false; crcCond.notify_one(); - return 0; } diff --git a/UI/BackgroundAudio.cpp b/UI/BackgroundAudio.cpp index c9ddd9c19031..742e0c4cc4f5 100644 --- a/UI/BackgroundAudio.cpp +++ b/UI/BackgroundAudio.cpp @@ -380,9 +380,9 @@ inline int16_t ConvertU8ToI16(uint8_t value) { } Sample *Sample::Load(const std::string &path) { - size_t bytes; + size_t bytes = 0; uint8_t *data = g_VFS.ReadFile(path.c_str(), &bytes); - if (!data) { + if (!data || bytes > 100000000) { WARN_LOG(AUDIO, "Failed to load sample '%s'", path.c_str()); return nullptr; } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 984c0f827bf1..3ddc1a67e162 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1396,7 +1396,7 @@ UI::EventReturn GameSettingsScreen::OnChangeBackground(UI::EventParams &e) { FILE *f = File::OpenCFile(path, "rb"); uint8_t buffer[8]; ImageFileType type = ImageFileType::UNKNOWN; - if (8 == fread(buffer, 1, ARRAY_SIZE(buffer), f)) { + if (f != nullptr && 8 == fread(buffer, 1, ARRAY_SIZE(buffer), f)) { type = DetectImageFileType(buffer, ARRAY_SIZE(buffer)); } diff --git a/android/jni/OpenSLContext.cpp b/android/jni/OpenSLContext.cpp index 5a67b71484d7..c5ebffbe6a85 100644 --- a/android/jni/OpenSLContext.cpp +++ b/android/jni/OpenSLContext.cpp @@ -10,7 +10,6 @@ #include #include "Common/Log.h" -#include "Common/StringUtils.h" #include "OpenSLContext.h" #include "Core/HLE/sceUsbMic.h" @@ -58,7 +57,9 @@ void OpenSLContext::BqPlayerCallback(SLAndroidSimpleBufferQueueItf bq) { memset(buffer[curBuffer] + renderedFrames * 2, 0, byteCount); } SLresult result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, buffer[curBuffer], sizeInBytes); - CheckResult(result, StringFromFormat("Failed to enqueue: %d %d", renderedFrames, sizeInBytes).c_str()); + + // TODO: get rid of this snprintf too + CheckResult(result, "Failed to enqueue"); // Comment from sample code: // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT, // which for this code example would indicate a programming error diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 92c4b8415581..a568076fbe51 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1162,13 +1162,11 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendRequestResult(JNIEn } } -void LockedNativeUpdateRender() { - std::lock_guard renderGuard(renderLock); - NativeFrame(graphicsContext); -} - void UpdateRunLoopAndroid(JNIEnv *env) { - LockedNativeUpdateRender(); + { + std::lock_guard renderGuard(renderLock); + NativeFrame(graphicsContext); + } std::lock_guard guard(frameCommandLock); if (!nativeActivity) { @@ -1639,7 +1637,10 @@ static void VulkanEmuThread(ANativeWindow *wnd) { renderer_inited = true; while (!exitRenderLoop) { - LockedNativeUpdateRender(); + { + std::lock_guard renderGuard(renderLock); + NativeFrame(graphicsContext); + } ProcessFrameCommands(env); } INFO_LOG(G3D, "Leaving Vulkan main loop.");