[RFC,5/7] apps: cam: Report error on multiple default sinks
diff mbox series

Message ID 20250314202943.112109-6-mzamazal@redhat.com
State New
Headers show
Series
  • Support different outputs for cam streams
Related show

Commit Message

Milan Zamazal March 14, 2025, 8:29 p.m. UTC
Multiple default sinks are not really supported, if more than one sink
is present then the last one wins and the other ones are just created
but not used actually.  Let's check for this and report an error in such
a case.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 src/apps/cam/camera_session.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index 54073cdf..b1f5209d 100644
--- a/src/apps/cam/camera_session.cpp
+++ b/src/apps/cam/camera_session.cpp
@@ -265,11 +265,21 @@  int CameraSession::start()
 #endif
 
 #ifdef HAVE_SDL
-	if (options_.isSet(OptSDL))
+	if (options_.isSet(OptSDL)) {
+		if (defaultSink) {
+			std::cerr << "Multiple default sinks not allowed" << std::endl;
+			return -EINVAL;
+		}
 		defaultSink = std::make_unique<SDLSink>();
+	}
 #endif
 
 	if (options_.isSet(OptFile)) {
+		if (defaultSink) {
+			std::cerr << "Multiple default sinks not allowed" << std::endl;
+			return -EINVAL;
+		}
+
 		std::unique_ptr<FileSink> sink =
 			std::make_unique<FileSink>(camera_.get(), streamNames_);