Browse Source

linux-v4l2: Fix camera reconnecting issue

Unable to add device after OBS start. Function device_added is never
called. HAVE_UDEV is not set correctly by cmake.
Grzegorz Godlewski 3 years ago
parent
commit
b98ce32670
2 changed files with 5 additions and 4 deletions
  1. 2 3
      plugins/linux-v4l2/CMakeLists.txt
  2. 3 1
      plugins/linux-v4l2/v4l2-input.c

+ 2 - 3
plugins/linux-v4l2/CMakeLists.txt

@@ -23,13 +23,12 @@ target_link_libraries(
 
 set_target_properties(linux-v4l2 PROPERTIES FOLDER "plugins")
 
-if(NOT ENABLE_UDEV)
-  target_compile_definitions(linux-v4l2 PRIVATE HAVE_UDEV)
-else()
+if(ENABLE_UDEV)
   find_package(Udev REQUIRED)
   target_sources(linux-v4l2 PRIVATE v4l2-udev.c)
 
   target_link_libraries(linux-v4l2 PRIVATE Udev::Udev)
+  target_compile_definitions(linux-v4l2 PRIVATE HAVE_UDEV)
 endif()
 
 setup_plugin_target(linux-v4l2)

+ 3 - 1
plugins/linux-v4l2/v4l2-input.c

@@ -1037,7 +1037,7 @@ static void v4l2_init(struct v4l2_data *data)
 		goto fail;
 	return;
 fail:
-	blog(LOG_ERROR, "Initialization failed");
+	blog(LOG_ERROR, "Initialization failed, errno: %s", strerror(errno));
 	v4l2_terminate(data);
 }
 
@@ -1166,6 +1166,8 @@ static void *v4l2_create(obs_data_t *settings, obs_source_t *source)
 
 	signal_handler_connect(sh, "device_added", &device_added, data);
 	signal_handler_connect(sh, "device_removed", &device_removed, data);
+#else
+	blog(LOG_INFO, "Compiled without libudev, you can't reconnect devices");
 #endif
 
 	return data;