mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(videoout): accept a zeroed open param
sceVideoOutOpen threw for any non-null param. PS5 titles pass a 16-byte open param whose first word is its size, so they could not open a port. A param whose size word is 16 and whose other three words are zero requests nothing beyond a null param and is accepted. Any other size, or any non-zero option word, still throws.
This commit is contained in:
@@ -37,6 +37,7 @@ static constexpr int VIDEO_OUT_ERROR_UNAVAILABLE_OUTPUT_MODE = -2144796633;
|
||||
static constexpr int VIDEO_OUT_ERROR_INVALID_EVENT = -2144796624;
|
||||
|
||||
static constexpr int VIDEO_OUT_BUS_TYPE_MAIN = 0;
|
||||
static constexpr std::uint32_t VIDEO_OUT_OPEN_PARAM_SIZE = 16;
|
||||
static constexpr int VIDEO_OUT_BUS_TYPE_OVERLAY = 1;
|
||||
static constexpr int VIDEO_OUT_BUS_TYPE_SUB = 2;
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <stdexcept>
|
||||
@@ -31,7 +34,14 @@ extern "C" {
|
||||
|
||||
int APS5_VABI sceVideoOutOpen(int userId, int busType, int index, const void* param) try {
|
||||
if (param != nullptr) {
|
||||
throw std::runtime_error(std::string(__func__) + ": param not implemented");
|
||||
std::array<std::uint32_t, VIDEO_OUT_OPEN_PARAM_SIZE / sizeof(std::uint32_t)> words{};
|
||||
std::memcpy(words.data(), param, sizeof(words));
|
||||
if (words[0] != VIDEO_OUT_OPEN_PARAM_SIZE) {
|
||||
throw std::runtime_error(std::string(__func__) + ": unsupported param size");
|
||||
}
|
||||
if (std::any_of(words.begin() + 1, words.end(), [](std::uint32_t word) { return word != 0; })) {
|
||||
throw std::runtime_error(std::string(__func__) + ": param options not implemented");
|
||||
}
|
||||
}
|
||||
if (userId != 255 && userId != 0) {
|
||||
throw std::runtime_error(std::string(__func__) + ": VIDEO_OUT_ERROR_INVALID_VALUE");
|
||||
|
||||
@@ -160,7 +160,14 @@ void testDecode() {
|
||||
}
|
||||
|
||||
void testControls() {
|
||||
const auto handle = sceVideoOutOpen(255, 0, 0, nullptr);
|
||||
std::array<std::uint32_t, 4> openParam{VIDEO_OUT_OPEN_PARAM_SIZE, 0, 0, 0};
|
||||
const auto handle = sceVideoOutOpen(255, 0, 0, openParam.data());
|
||||
check(handle >= 0, "open with a zeroed param failed");
|
||||
openParam[0] = 24;
|
||||
expectFailure([&] { sceVideoOutOpen(255, 0, 0, openParam.data()); });
|
||||
openParam[0] = VIDEO_OUT_OPEN_PARAM_SIZE;
|
||||
openParam[2] = 1;
|
||||
expectFailure([&] { sceVideoOutOpen(255, 0, 0, openParam.data()); });
|
||||
const auto cfg = VideoOutDriver::Get().GetConfig(handle);
|
||||
for (int rate = 0; rate <= 2; ++rate) {
|
||||
check(sceVideoOutSetFlipRate(handle, rate) == 0 && cfg->flipRate == rate, "flip rate was not applied");
|
||||
|
||||
Reference in New Issue
Block a user