From 8e14ef7c0c4d836eff9b774e26b6cbe4d15e3ba8 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 1 Jun 2023 18:31:55 +0200 Subject: [PATCH] GstStartup: Set rank for directsoundsink higher than wasapisink for MinGW Fixes #1204 --- src/engine/gststartup.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/engine/gststartup.cpp b/src/engine/gststartup.cpp index 6637fde4b..7ba1b7680 100644 --- a/src/engine/gststartup.cpp +++ b/src/engine/gststartup.cpp @@ -84,6 +84,21 @@ void GstStartup::InitializeGStreamer() { gstfastspectrum_register_static(); #endif +#if defined(Q_OS_WIN32) && defined(__MINGW32__) + // MinGW does not have wasapi2sink and wasapisink does not support device switching, so use directsoundsink as the default sink. + GstRegistry *reg = gst_registry_get(); + if (reg) { + GstPluginFeature *directsoundsink = gst_registry_lookup_feature(reg, "directsoundsink"); + GstPluginFeature *wasapisink = gst_registry_lookup_feature(reg, "wasapisink"); + if (directsoundsink && wasapisink) { + gst_plugin_feature_set_rank(directsoundsink, GST_RANK_PRIMARY); + gst_plugin_feature_set_rank(wasapisink, GST_RANK_SECONDARY); + } + if (directsoundsink) gst_object_unref(directsoundsink); + if (wasapisink) gst_object_unref(wasapisink); + } +#endif + } void GstStartup::SetEnvironment() {