From 67385e37ae101119723dc57baf4dd2ac4eaffb4c Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 9 Jun 2023 14:46:01 +0200 Subject: [PATCH] set acap to vidcap even when set after Previous commit modified the behavior that audio connection (embedded et al.) specification is applied to following capture. To be more user-friendly when there is only one vidcap device, set the audio also to previous device (similarly it has been done for -F), so: uv -s embedded -t testcard uv -t testcard -s embedded # <- this now works again uv -t switcher -t testcard -s embedded # this doesn't (ambigous) --- src/video_capture.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/video_capture.cpp b/src/video_capture.cpp index 25544e3bb..936862f07 100644 --- a/src/video_capture.cpp +++ b/src/video_capture.cpp @@ -62,6 +62,7 @@ #include "lib_common.h" #include "module.h" #include "video_capture.h" +#include "video_capture_params.h" #include #include @@ -120,6 +121,20 @@ int initialize_video_capture(struct module *parent, } vidcap_params_set_capture_filter(tprev, vidcap_params_get_capture_filter(tlast)); } + // similarly for audio connection + if (vidcap_params_get_driver(tlast) == nullptr + && vidcap_params_get_flags(tlast) != 0) { + if (tprev != param) { // more than one -t + log_msg(LOG_LEVEL_ERROR, "Audio connection (-s) needs to be " + "specified before capture (-t)\n"); + return -1; + } + if (vidcap_params_get_flags(tprev) != 0) { // one -t but -s specified both before and after it + log_msg(LOG_LEVEL_ERROR, "Multiple audio connection specification.\n"); + return -1; + } + vidcap_params_set_flags(tprev, vidcap_params_get_flags(tlast)); + } const struct video_capture_info *vci = (const struct video_capture_info *) load_library(vidcap_params_get_driver(param), LIBRARY_CLASS_VIDEO_CAPTURE, VIDEO_CAPTURE_ABI_VERSION);