[vlc-commits] qt: fix wrong audio settings with automatic device

Thomas Guillem git at videolan.org
Thu Mar 22 09:47:05 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Mar 20 16:04:20 2018 +0100| [a32e93567b6d5d284a0f2d326f9f446f5b1c5cae] | committer: Thomas Guillem

qt: fix wrong audio settings with automatic device

Fetch the actual audio module instead of relying on the config.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a32e93567b6d5d284a0f2d326f9f446f5b1c5cae
---

 modules/gui/qt/components/simple_preferences.cpp | 36 ++++++++++++++++--------
 modules/gui/qt/components/simple_preferences.hpp |  1 +
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt/components/simple_preferences.cpp b/modules/gui/qt/components/simple_preferences.cpp
index da2fea5ee8..cd65b5b2fe 100644
--- a/modules/gui/qt/components/simple_preferences.cpp
+++ b/modules/gui/qt/components/simple_preferences.cpp
@@ -29,6 +29,7 @@
 
 #include "components/simple_preferences.hpp"
 #include "components/preferences_widgets.hpp"
+#include "input_manager.hpp"
 
 #include <vlc_config_cat.h>
 #include <vlc_configuration.h>
@@ -128,15 +129,7 @@ static struct {
 static int getDefaultAudioVolume(const char *aout)
 {
     if (!strcmp(aout, "") || !strcmp(aout, "any"))
-#ifdef _WIN32
-        /* All Windows aouts, that can be selected automatically, handle volume
-         * saving. In case of automatic mode, we'll save the last volume for
-         * every modules. Therefore, all volumes variable we be the same and we
-         * can use the first one (mmdevice). */
-        return config_GetFloat("mmdevice-volume") * 100.f + .5f;
-#else
         return -1;
-#endif
     else
     /* Note: For hysterical raisins, this is sorted by decreasing priority
      * order (then alphabetical order). */
@@ -964,15 +957,36 @@ void SPrefsPanel::updateVideoOptions( int number )
 #endif
 }
 
+char *SPrefsPanel::getAoutModuleName()
+{
+    audio_output_t *p_aout = THEMIM->getAout();
+    if (p_aout == NULL)
+        return NULL;
+
+    char *module = var_GetString(p_aout, "module-name");
+    vlc_object_release(p_aout);
+    return module;
+}
 
 void SPrefsPanel::updateAudioOptions( int number)
 {
     QString value = qobject_cast<QComboBox *>(optionWidgets["audioOutCoB"])
                                             ->itemData( number ).toString();
+
+    if (value == "any" || value == "")
+    {
+        char *module = getAoutModuleName();
+        if (module != NULL)
+        {
+            value = qfu(module);
+            free(module);
+        }
+    }
+
 #ifdef _WIN32
     /* Since MMDevice is most likely to be used by default, we show MMDevice
      * options by default */
-    const bool mmDeviceEnabled = value == "mmdevice" || value == "any";
+    const bool mmDeviceEnabled = value == "mmdevice";
     optionWidgets["mmdevicePassthroughL"]->setVisible( mmDeviceEnabled );
     optionWidgets["mmdevicePassthroughB"]->setVisible( mmDeviceEnabled );
     optionWidgets["mmdeviceW"]->setVisible( mmDeviceEnabled );
@@ -1113,12 +1127,12 @@ void SPrefsPanel::apply()
             qobject_cast<QSlider *>(optionWidgets["defaultVolume"])->value();
         bool b_reset_volume =
             qobject_cast<QCheckBox *>(optionWidgets["resetVolumeCheckbox"])->isChecked();
-        char *psz_aout = config_GetPsz( "aout" );
+        char *psz_aout = getAoutModuleName();
 
         float f_gain = powf( i_volume / 100.f, 3 );
 
 #define save_vol_aout( name ) \
-            module_exists( name ) && ( !psz_aout || !strcmp( psz_aout, name ) || !strcmp( psz_aout, "any" ) )
+            module_exists( name ) && ( !psz_aout || !strcmp( psz_aout, name ) )
 
         //FIXME this is moot
 #if defined( _WIN32 )
diff --git a/modules/gui/qt/components/simple_preferences.hpp b/modules/gui/qt/components/simple_preferences.hpp
index 856b88ba97..6f72836972 100644
--- a/modules/gui/qt/components/simple_preferences.hpp
+++ b/modules/gui/qt/components/simple_preferences.hpp
@@ -113,6 +113,7 @@ private:
     bool addType( const char * psz_ext, QTreeWidgetItem*, QTreeWidgetItem*, QVLCRegistry* );
     void saveLang();
 #endif
+    char *getAoutModuleName();
 
 /* Display only the options for the selected audio output */
 private slots:



More information about the vlc-commits mailing list