From patchwork Fri Mar 14 20:29:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22965 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1D22DC32F9 for ; Fri, 14 Mar 2025 20:30:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A0AA68952; Fri, 14 Mar 2025 21:30:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="i+cF/RN6"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C6CAB6894A for ; Fri, 14 Mar 2025 21:30:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741984209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vgaUImN0wCsNk1ynC8rrqJWeH66K7Oy23vSbw7kLXeo=; b=i+cF/RN606cwrrezQF1INt+u1eXOYgUiSpmrfoxdOS7PGLFWb2GWYYEvJOaKuwJnE0h1l9 vNbNzenmhXQVcj7MPNwgqIJomKzb8/NPdOLnkFRohSEvC6LZIq0qbMF6nIt4l2idqJkF8i 35TMzagWIVHcyaUduU0NxaP6EEuzt5A= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-vcXUUOfkN5WuCghSZnxDaw-1; Fri, 14 Mar 2025 16:30:08 -0400 X-MC-Unique: vcXUUOfkN5WuCghSZnxDaw-1 X-Mimecast-MFC-AGG-ID: vcXUUOfkN5WuCghSZnxDaw_1741984207 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 877F1195608B; Fri, 14 Mar 2025 20:30:07 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.19]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 006621954B32; Fri, 14 Mar 2025 20:30:05 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Laurent Pinchart Subject: [RFC PATCH 5/7] apps: cam: Report error on multiple default sinks Date: Fri, 14 Mar 2025 21:29:33 +0100 Message-ID: <20250314202943.112109-6-mzamazal@redhat.com> In-Reply-To: <20250314202943.112109-1-mzamazal@redhat.com> References: <20250314202943.112109-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lUAg-kvS8NiekhtfwHWYg5BTSU_GInB7X9ArUL-znhY_1741984207 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- src/apps/cam/camera_session.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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(); + } #endif if (options_.isSet(OptFile)) { + if (defaultSink) { + std::cerr << "Multiple default sinks not allowed" << std::endl; + return -EINVAL; + } + std::unique_ptr sink = std::make_unique(camera_.get(), streamNames_);