[graphics/digikam] core: Move audio backend preference to a shared helper, use in Showfoto
Gilles Caulier <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 6122c27f1c3074eabf2a8b1270b71ff2f7faa339 by Gilles Caulier, on behalf of Mark Cockram.
Committed on 22/07/2026 at 19:42.
Pushed by cgilles into branch 'master'.
Move audio backend preference to a shared helper, use in Showfoto
Host the QT_AUDIO_BACKEND=pulseaudio default in a new
setAudioBackendEnvironment() function in digikam_globals_bundles.cpp,
next to the other per-platform environment helpers, and call it from
both the digiKam and Showfoto main functions so the Showfoto media
player gets the same complete audio output list.
M +2 -17 core/app/main/main.cpp
M +6 -0 core/app/utils/digikam_globals.h
M +24 -0 core/app/utils/digikam_globals_bundles.cpp
M +4 -0 core/showfoto/main/main.cpp
https://invent.kde.org/graphics/digikam/-/commit/6122c27f1c3074eabf2a8b1270b71ff2f7faa339
diff --git a/core/app/main/main.cpp b/core/app/main/main.cpp
index 70b1387a61..06072f608f 100644
--- a/core/app/main/main.cpp
+++ b/core/app/main/main.cpp
@@ -181,24 +181,9 @@ MAIN_EXPORT int MAIN_FN(int argc, char** argv)
qputenv("QT_MEDIA_BACKEND", system.videoBackend.toLatin1());
-# if defined Q_OS_LINUX
+ // Common audio backend rules from digikam_globals.
- if (!qEnvironmentVariableIsSet("QT_AUDIO_BACKEND"))
- {
- // On PipeWire systems Qt >= 6.10 defaults to its native PipeWire
- // audio backend, whose asynchronous format enumeration can fail
- // for sinks owned by other PipeWire clients (for example
- // module-filter-chain effect sinks): the affected outputs then
- // never appear in QMediaDevices::audioOutputs(), so they are
- // missing from the audio output selection of the media player.
- // The PulseAudio backend enumerates the same devices through
- // pipewire-pulse without this defect, so prefer it until the Qt
- // issue is fixed.
-
- qputenv("QT_AUDIO_BACKEND", "pulseaudio");
- }
-
-# endif
+ setAudioBackendEnvironment();
#endif
diff --git a/core/app/utils/digikam_globals.h b/core/app/utils/digikam_globals.h
index d7c1e05213..38b46973fc 100644
--- a/core/app/utils/digikam_globals.h
+++ b/core/app/utils/digikam_globals.h
@@ -312,6 +312,12 @@ DIGIKAM_EXPORT void setMacOSEnvironment();
*/
DIGIKAM_EXPORT void setWindowsEnvironment(QApplication& app);
+/**
+ * For Linux only, prefer the PulseAudio backend of Qt Multimedia if the user
+ * has not selected an audio backend explicitly with QT_AUDIO_BACKEND.
+ */
+DIGIKAM_EXPORT void setAudioBackendEnvironment();
+
/**
* For OpenCV framework, set necessary environment variables to use OpenCL features.
*/
diff --git a/core/app/utils/digikam_globals_bundles.cpp b/core/app/utils/digikam_globals_bundles.cpp
index c673de71a9..923ee17af0 100644
--- a/core/app/utils/digikam_globals_bundles.cpp
+++ b/core/app/utils/digikam_globals_bundles.cpp
@@ -583,6 +583,30 @@ void setWindowsEnvironment(QApplication& app)
}
+void setAudioBackendEnvironment()
+{
+
+#if defined(Q_OS_LINUX) && (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+
+ if (!qEnvironmentVariableIsSet("QT_AUDIO_BACKEND"))
+ {
+ // On PipeWire systems Qt >= 6.10 defaults to its native PipeWire
+ // audio backend, whose asynchronous format enumeration can fail
+ // for sinks owned by other PipeWire clients (for example
+ // module-filter-chain effect sinks): the affected outputs then
+ // never appear in QMediaDevices::audioOutputs(), so they are
+ // missing from the audio output selection of the media player
+ // (QTBUG-143570). The PulseAudio backend enumerates the same
+ // devices through pipewire-pulse without this defect, so prefer
+ // it until the Qt issue is fixed.
+
+ qputenv("QT_AUDIO_BACKEND", "pulseaudio");
+ }
+
+#endif
+
+}
+
void delayForRemoteDebuging(int delaySecs)
{
const QByteArray remoteDebug = qgetenv("DIGIKAM_REMOTE_DEBUG");
diff --git a/core/showfoto/main/main.cpp b/core/showfoto/main/main.cpp
index 73f29ab459..ff9b4c6297 100644
--- a/core/showfoto/main/main.cpp
+++ b/core/showfoto/main/main.cpp
@@ -156,6 +156,10 @@ MAIN_EXPORT int MAIN_FN(int argc, char** argv)
qputenv("QT_MEDIA_BACKEND", system.videoBackend.toLatin1());
+ // Common audio backend rules from digikam_globals.
+
+ setAudioBackendEnvironment();
+
#endif
#if defined HAVE_KICONTHEMES && (KICONTHEMES_VERSION >= QT_VERSION_CHECK(6, 3, 0))