All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4l-utils 1/2] qv4l2: fix ALSA audio playback
@ 2026-11-23 14:46 dungeonlords789
  2026-11-23 14:46 ` [PATCH v4l-utils 2/2] qv4l2: drop Qt5, Core5Compat dungeonlords789
  0 siblings, 1 reply; 3+ messages in thread
From: dungeonlords789 @ 2026-11-23 14:46 UTC (permalink / raw)
  To: linux-media; +Cc: kieran.bingham, laurent.pinchart, Andrei Cherniaev

From: Andrei Cherniaev <27889022+AndreiCherniaev@users.noreply.github.com>

fix commit f306132f

Signed-off-by: Andrei Cherniaev <27889022+AndreiCherniaev@users.noreply.github.com>
---
 utils/qv4l2/general-tab.cpp | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp
index 7de7e7a6..ca835fc1 100644
--- a/utils/qv4l2/general-tab.cpp
+++ b/utils/qv4l2/general-tab.cpp
@@ -32,7 +32,12 @@
 #include <math.h>
 #include <stdio.h>
 #include <errno.h>
+
+#if QT_VERSION < 0x060000		
 #include <QRegExp>
+#else
+#include <QRegularExpression>
+#endif
 
 bool GeneralTab::m_fullAudioName = false;
 
@@ -2406,9 +2411,24 @@ int GeneralTab::checkMatchAudioDevice(void *md, const char *vid, enum device_typ
 			QStringList devAddr = QString(devname).split(QRegExp("[:,]"));
 			return devAddr.value(1).toInt();
 #else
-			QRegExp rx("[:,]");
-			rx.indexIn(devname);
-			return rx.cap(1).toInt();
+			// Matches "hw:2,0", "plughw:2", "sysdefault:CARD=PCH", "hw:PCH,0"
+			static const QRegularExpression re(QStringLiteral(":(?:CARD=)?([^,]+)"));
+			QRegularExpressionMatch match = re.match(QString::fromUtf8(devname));
+
+			if (!match.hasMatch()) {
+				return -1; // invalid format
+			}
+
+			QString cardToken = match.captured(1);
+			bool ok = false;
+			int cardIndex = cardToken.toInt(&ok);
+
+			if (ok) {
+				return cardIndex; // e.g., "hw:2,0" -> 2
+			}
+
+			// Fallback for named cards (e.g., "hw:PCH,0" or "sysdefault:CARD=PCH")
+			return snd_card_get_index(cardToken.toUtf8().constData());
 #endif
 		}
 	}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-02 11:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 14:46 [PATCH v4l-utils 1/2] qv4l2: fix ALSA audio playback dungeonlords789
2026-11-23 14:46 ` [PATCH v4l-utils 2/2] qv4l2: drop Qt5, Core5Compat dungeonlords789
2026-12-02 11:44   ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.