| 1352 | } |
| 1353 | |
| 1354 | error_code cellCameraReadEx(s32 dev_num, vm::ptr<CellCameraReadEx> read) |
| 1355 | { |
| 1356 | cellCamera.trace("cellCameraReadEx(dev_num=%d, read=0x%x)", dev_num, read); |
| 1357 | |
| 1358 | auto& g_camera = g_fxo->get<camera_thread>(); |
| 1359 | |
| 1360 | if (!g_camera.init) |
| 1361 | { |
| 1362 | return CELL_CAMERA_ERROR_NOT_INIT; |
| 1363 | } |
| 1364 | |
| 1365 | if (g_cfg.io.camera == camera_handler::null) |
| 1366 | { |
| 1367 | return not_an_error(CELL_CAMERA_ERROR_NOT_OPEN); |
| 1368 | } |
| 1369 | |
| 1370 | if (!check_dev_num(dev_num)) |
| 1371 | { |
| 1372 | return CELL_CAMERA_ERROR_PARAM; |
| 1373 | } |
| 1374 | |
| 1375 | std::lock_guard lock(g_camera.mutex); |
| 1376 | |
| 1377 | if (!g_camera.is_open) |
| 1378 | { |
| 1379 | return CELL_CAMERA_ERROR_NOT_OPEN; |
| 1380 | } |
| 1381 | |
| 1382 | if (!g_camera.is_attached) |
| 1383 | { |
| 1384 | return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; |
| 1385 | } |
| 1386 | |
| 1387 | if (!g_camera.is_streaming) |
| 1388 | { |
| 1389 | return CELL_CAMERA_ERROR_NOT_STARTED; |
| 1390 | } |
| 1391 | |
| 1392 | // can call cellCameraReset() and cellCameraStop() in some cases |
| 1393 | |
| 1394 | const bool has_new_frame = g_camera.has_new_frame.exchange(false); |
| 1395 | |
| 1396 | if (g_camera.handler) |
| 1397 | { |
| 1398 | if (has_new_frame) |
| 1399 | { |
| 1400 | u32 width{}; |
| 1401 | u32 height{}; |
| 1402 | u64 frame_number{}; |
| 1403 | u64 bytes_read{}; |
| 1404 | |
| 1405 | if (!g_camera.get_camera_frame(g_camera.info.buffer.get_ptr(), width, height, frame_number, bytes_read)) |
| 1406 | { |
| 1407 | return CELL_CAMERA_ERROR_DEVICE_NOT_FOUND; |
| 1408 | } |
| 1409 | |
| 1410 | g_camera.bytes_read = ::narrow<u32>(bytes_read); |
| 1411 |
no test coverage detected