mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Assorted paranoia, get rid of an allocation in the audio loop
This commit is contained in:
parent
0170e8f081
commit
9979372a97
@ -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<File::FileInfo> *listing, const char *filter) {
|
||||
|
@ -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)) {
|
||||
|
@ -312,6 +312,7 @@ public:
|
||||
|
||||
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];
|
||||
|
@ -113,11 +113,11 @@ namespace Reporting
|
||||
static std::condition_variable crcCond;
|
||||
static Path crcFilename;
|
||||
static std::map<Path, u32> crcResults;
|
||||
static volatile bool crcPending = false;
|
||||
static volatile bool crcCancel = false;
|
||||
static std::atomic<bool> crcPending = false;
|
||||
static std::atomic<bool> crcCancel = false;
|
||||
static std::thread crcThread;
|
||||
|
||||
static u32 CalculateCRC(BlockDevice *blockDevice, volatile bool *cancel) {
|
||||
static u32 CalculateCRC(BlockDevice *blockDevice, std::atomic<bool> *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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <SLES/OpenSLES_Android.h>
|
||||
|
||||
#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
|
||||
|
@ -1162,13 +1162,11 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendRequestResult(JNIEn
|
||||
}
|
||||
}
|
||||
|
||||
void LockedNativeUpdateRender() {
|
||||
std::lock_guard<std::mutex> renderGuard(renderLock);
|
||||
NativeFrame(graphicsContext);
|
||||
}
|
||||
|
||||
void UpdateRunLoopAndroid(JNIEnv *env) {
|
||||
LockedNativeUpdateRender();
|
||||
{
|
||||
std::lock_guard<std::mutex> renderGuard(renderLock);
|
||||
NativeFrame(graphicsContext);
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(frameCommandLock);
|
||||
if (!nativeActivity) {
|
||||
@ -1639,7 +1637,10 @@ static void VulkanEmuThread(ANativeWindow *wnd) {
|
||||
renderer_inited = true;
|
||||
|
||||
while (!exitRenderLoop) {
|
||||
LockedNativeUpdateRender();
|
||||
{
|
||||
std::lock_guard<std::mutex> renderGuard(renderLock);
|
||||
NativeFrame(graphicsContext);
|
||||
}
|
||||
ProcessFrameCommands(env);
|
||||
}
|
||||
INFO_LOG(G3D, "Leaving Vulkan main loop.");
|
||||
|
Loading…
Reference in New Issue
Block a user