From 483b42d2b8379b12901e029ac72867d282878644 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Sat, 29 Jul 2023 22:54:49 +0200 Subject: [PATCH] GstStartup: Use directsoundsink as primary sink --- src/engine/gststartup.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/engine/gststartup.cpp b/src/engine/gststartup.cpp index 7ba1b768..dd3ed09b 100644 --- a/src/engine/gststartup.cpp +++ b/src/engine/gststartup.cpp @@ -84,18 +84,23 @@ 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. +#ifdef Q_OS_WIN32 + // Use directsoundsink as the default sink on Windows. + // wasapisink does not support device switching and wasapi2sink has issues, see #1227. 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) { + if (GstPluginFeature *directsoundsink = gst_registry_lookup_feature(reg, "directsoundsink")) { gst_plugin_feature_set_rank(directsoundsink, GST_RANK_PRIMARY); - gst_plugin_feature_set_rank(wasapisink, GST_RANK_SECONDARY); + gst_object_unref(directsoundsink); + } + if (GstPluginFeature *wasapisink = gst_registry_lookup_feature(reg, "wasapisink")) { + gst_plugin_feature_set_rank(wasapisink, GST_RANK_SECONDARY); + gst_object_unref(wasapisink); + } + if (GstPluginFeature *wasapi2sink = gst_registry_lookup_feature(reg, "wasapi2sink")) { + gst_plugin_feature_set_rank(wasapi2sink, GST_RANK_SECONDARY); + gst_object_unref(wasapi2sink); } - if (directsoundsink) gst_object_unref(directsoundsink); - if (wasapisink) gst_object_unref(wasapisink); } #endif