File amf-switch-fix.patch of Package obs-studio
diff --git a/plugins/obs-ffmpeg/obs-amf-test/cmake/legacy.cmake b/plugins/obs-ffmpeg/obs-amf-test/cmake/legacy.cmake
index e00cef1..4d2ce87 100644
--- a/plugins/obs-ffmpeg/obs-amf-test/cmake/legacy.cmake
+++ b/plugins/obs-ffmpeg/obs-amf-test/cmake/legacy.cmake
@@ -2,12 +2,18 @@ project(obs-amf-test)
add_executable(obs-amf-test)
-find_package(AMF 1.4.29 REQUIRED)
+find_package(AMF 1.4.34 REQUIRED)
target_include_directories(obs-amf-test PRIVATE ${CMAKE_SOURCE_DIR}/libobs)
-target_sources(obs-amf-test PRIVATE obs-amf-test.cpp)
-target_link_libraries(obs-amf-test d3d11 dxgi dxguid AMF::AMF)
+if(OS_WINDOWS)
+ target_sources(obs-amf-test PRIVATE obs-amf-test.cpp)
+ target_link_libraries(obs-amf-test d3d11 dxgi dxguid AMF::AMF)
+elseif(OS_POSIX AND NOT OS_MACOS)
+ find_package(Vulkan REQUIRED)
+ target_sources(obs-amf-test PRIVATE obs-amf-test-linux.cpp)
+ target_link_libraries(obs-amf-test dl Vulkan::Vulkan AMF::AMF)
+endif()
set_target_properties(obs-amf-test PROPERTIES FOLDER "plugins/obs-ffmpeg")
diff --git a/plugins/obs-ffmpeg/texture-amf.cpp b/plugins/obs-ffmpeg/texture-amf.cpp
index f23adeb..497322f 100644
--- a/plugins/obs-ffmpeg/texture-amf.cpp
+++ b/plugins/obs-ffmpeg/texture-amf.cpp
@@ -651,6 +651,7 @@ static void roi_cb(void *param, obs_encoder_roi *roi)
static void create_roi(amf_base *enc, AMFSurface *amf_surf)
{
+ UNUSED_PARAMETER(amf_surf);
uint32_t mb_size = 16; /* H.264 is always 16x16 */
if (enc->codec == amf_codec_type::HEVC ||
enc->codec == amf_codec_type::AV1)
@@ -1114,6 +1115,8 @@ try {
case VIDEO_FORMAT_RGBA:
enc->amf_format = AMF_SURFACE_RGBA;
break;
+ default:
+ break;
}
/* ------------------------------------ */
@@ -1190,6 +1193,8 @@ static void check_texture_encode_capability(obs_encoder_t *encoder,
case VIDEO_CS_2100_PQ:
case VIDEO_CS_2100_HLG:
throw "OBS does not support 8-bit output of Rec. 2100";
+ default:
+ break;
}
}
@@ -1636,6 +1641,8 @@ try {
obs_encoder_set_last_error(encoder, text);
throw text;
}
+ default:
+ break;
}
}
@@ -2001,6 +2008,8 @@ try {
obs_encoder_set_last_error(encoder, text);
throw text;
}
+ default:
+ break;
}
}
@@ -2329,6 +2338,8 @@ try {
obs_encoder_set_last_error(encoder, text);
throw text;
}
+ default:
+ break;
}
}
@@ -2429,29 +2440,41 @@ try {
std::stringstream cmd;
std::string caps_str;
+#ifdef _WIN32
cmd << '"';
cmd << test_exe;
cmd << '"';
-#ifdef _WIN32
+
enum_graphics_device_luids(enum_luids, &cmd);
+#else
+ cmd << test_exe;
#endif
os_process_pipe_t *pp = os_process_pipe_create(cmd.str().c_str(), "r");
if (!pp)
throw "Failed to launch the AMF test process I guess";
-
+ uint32_t pipetimeout = 0;
for (;;) {
char data[2048];
size_t len =
os_process_pipe_read(pp, (uint8_t *)data, sizeof(data));
- if (!len)
- break;
+ if (!len) {
+ pipetimeout = pipetimeout + 1;
+ if (pipetimeout > 10)
+ break;
+ }
+ else {
+ caps_str.append(data, len);
+ }
+
+
- caps_str.append(data, len);
}
os_process_pipe_destroy(pp);
+ blog(LOG_DEBUG, "amd_amf test results: %s, %s, %d", cmd.str().c_str(), caps_str.c_str(), pipetimeout);
+
if (caps_str.empty())
throw "Seems the AMF test subprocess crashed. "
"Better there than here I guess. "
diff --git a/libobs/util/pipe-posix.c b/libobs/util/pipe-posix.c
index 6f06752..ab2f10f 100644
--- a/libobs/util/pipe-posix.c
+++ b/libobs/util/pipe-posix.c
@@ -132,7 +132,7 @@ os_process_pipe_t *os_process_pipe_create(const char *cmd_line,
if (!cmd_line)
return NULL;
- char *argv[3] = {"-c", (char *)cmd_line, NULL};
+ char *argv[4] = {"/bin/sh", "-c", (char *)cmd_line, NULL};
return os_process_pipe_create_internal("/bin/sh", argv, type);
}