From 69fc1f26137e4c208df8dfb10f57a2c8da72b0c1 Mon Sep 17 00:00:00 2001 From: eladash Date: Wed, 19 Dec 2018 22:26:28 +0200 Subject: [PATCH] Added CAMERA_NOT_INIT checks for no camera setting --- rpcs3/Emu/Cell/Modules/cellCamera.cpp | 122 +++++++++++++------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellCamera.cpp b/rpcs3/Emu/Cell/Modules/cellCamera.cpp index 88e9a3d34b..4ab8ddf5be 100644 --- a/rpcs3/Emu/Cell/Modules/cellCamera.cpp +++ b/rpcs3/Emu/Cell/Modules/cellCamera.cpp @@ -276,11 +276,6 @@ s32 cellCameraInit() { cellCamera.todo("cellCameraInit()"); - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_OK; - } - // Start camera thread const auto g_camera = fxm::make("Camera Thread"); @@ -289,6 +284,11 @@ s32 cellCameraInit() return CELL_CAMERA_ERROR_ALREADY_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_OK; + } + std::lock_guard lock(g_camera->mutex); switch (g_cfg.io.camera_type) @@ -349,11 +349,6 @@ s32 cellCameraEnd() { cellCamera.todo("cellCameraEnd()"); - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_OK; - } - const auto g_camera = fxm::withdraw(); if (!g_camera) @@ -456,11 +451,6 @@ s32 cellCameraClose(s32 dev_num) return CELL_CAMERA_ERROR_PARAM; } - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_CAMERA_ERROR_NOT_OPEN; - } - const auto g_camera = fxm::get(); if (!g_camera) @@ -468,6 +458,11 @@ s32 cellCameraClose(s32 dev_num) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_NOT_OPEN; + } + std::lock_guard lock(g_camera->mutex); if (!g_camera->is_open) @@ -503,11 +498,6 @@ s32 cellCameraGetType(s32 dev_num, vm::ptr type) { cellCamera.todo("cellCameraGetType(dev_num=%d, type=*0x%x)", dev_num, type); - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; - } - const auto g_camera = fxm::get(); if (!g_camera) @@ -515,6 +505,11 @@ s32 cellCameraGetType(s32 dev_num, vm::ptr type) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; + } + if (!check_dev_num(dev_num) || !type ) { return CELL_CAMERA_ERROR_PARAM; @@ -636,11 +631,6 @@ s32 cellCameraGetAttribute(s32 dev_num, s32 attrib, vm::ptr arg1, vm::ptr(); if (!g_camera) @@ -648,6 +638,11 @@ s32 cellCameraGetAttribute(s32 dev_num, s32 attrib, vm::ptr arg1, vm::ptr(); if (!g_camera) @@ -695,6 +685,11 @@ s32 cellCameraSetAttribute(s32 dev_num, s32 attrib, u32 arg1, u32 arg2) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_NOT_OPEN; + } + if (!check_dev_num(dev_num) || !attr_name) // invalid attributes don't have a name { return CELL_CAMERA_ERROR_PARAM; @@ -715,11 +710,6 @@ s32 cellCameraGetBufferSize(s32 dev_num, vm::ptr info) { cellCamera.todo("cellCameraGetBufferSize(dev_num=%d, info=*0x%x)", dev_num, info); - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; - } - const auto g_camera = fxm::get(); if (!g_camera) @@ -727,6 +717,11 @@ s32 cellCameraGetBufferSize(s32 dev_num, vm::ptr info) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; + } + // the next few checks have a strange order, if I can trust the tests if (!check_dev_num(dev_num)) @@ -784,11 +779,6 @@ s32 cellCameraGetBufferInfoEx(s32 dev_num, vm::ptr info) // the following should be moved to cellCameraGetBufferInfo - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_CAMERA_ERROR_NOT_OPEN; - } - const auto g_camera = fxm::get(); if (!g_camera) @@ -796,6 +786,11 @@ s32 cellCameraGetBufferInfoEx(s32 dev_num, vm::ptr info) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_NOT_OPEN; + } + if (!check_dev_num(dev_num)) { return CELL_CAMERA_ERROR_PARAM; @@ -852,11 +847,6 @@ s32 cellCameraReset(s32 dev_num) return CELL_CAMERA_ERROR_PARAM; } - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_CAMERA_ERROR_NOT_OPEN; - } - const auto g_camera = fxm::get(); if (!g_camera) @@ -864,6 +854,11 @@ s32 cellCameraReset(s32 dev_num) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_NOT_OPEN; + } + if (!g_camera->is_open) { return CELL_CAMERA_ERROR_NOT_OPEN; @@ -888,11 +883,6 @@ s32 cellCameraStart(s32 dev_num) return CELL_CAMERA_ERROR_PARAM; } - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_CAMERA_ERROR_NOT_OPEN; - } - const auto g_camera = fxm::get(); if (!g_camera) @@ -900,6 +890,11 @@ s32 cellCameraStart(s32 dev_num) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_NOT_OPEN; + } + std::lock_guard lock(g_camera->mutex); if (!g_camera->is_open) @@ -948,11 +943,6 @@ s32 cellCameraReadEx(s32 dev_num, vm::ptr read) { cellCamera.todo("cellCameraReadEx(dev_num=%d, read=0x%x)", dev_num, read); - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_CAMERA_ERROR_NOT_OPEN; - } - const auto g_camera = fxm::get(); if (!g_camera) @@ -960,6 +950,11 @@ s32 cellCameraReadEx(s32 dev_num, vm::ptr read) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_NOT_OPEN; + } + if (!check_dev_num(dev_num)) { return CELL_CAMERA_ERROR_PARAM; @@ -1014,11 +1009,6 @@ s32 cellCameraStop(s32 dev_num) return CELL_CAMERA_ERROR_PARAM; } - if (g_cfg.io.camera == camera_handler::null) - { - return CELL_CAMERA_ERROR_NOT_OPEN; - } - const auto g_camera = fxm::get(); if (!g_camera) @@ -1026,6 +1016,11 @@ s32 cellCameraStop(s32 dev_num) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_CAMERA_ERROR_NOT_OPEN; + } + if (!g_camera->is_open) { return CELL_CAMERA_ERROR_NOT_OPEN; @@ -1064,6 +1059,11 @@ s32 cellCameraSetNotifyEventQueue(u64 key) return CELL_CAMERA_ERROR_NOT_INIT; } + if (g_cfg.io.camera == camera_handler::null) + { + return CELL_OK; + } + g_camera->add_queue(key, 0, 0); return CELL_OK; @@ -1162,7 +1162,7 @@ void camera_context::operator()() { const s32 fps = info.framerate; - if (!fps || Emu.IsPaused()) + if (!fps || Emu.IsPaused() || g_cfg.io.camera == camera_handler::null) { thread_ctrl::wait_for(1000); // hack continue;