Browse Source

UI: Default mixer volume meter to two channels

If OBS is set to mono, it will still default to mono.
Also corrects a somewhat related comment (which was also wrong before
this change)
gxalpha 3 years ago
parent
commit
2422deb78a
1 changed files with 11 additions and 2 deletions
  1. 11 2
      UI/volume-control.cpp

+ 11 - 2
UI/volume-control.cpp

@@ -750,6 +750,14 @@ inline void VolumeMeter::resetLevels()
 bool VolumeMeter::needLayoutChange()
 {
 	int currentNrAudioChannels = obs_volmeter_get_nr_channels(obs_volmeter);
+
+	if (!currentNrAudioChannels) {
+		struct obs_audio_info oai;
+		obs_get_audio_info(&oai);
+		currentNrAudioChannels = (oai.speakers == SPEAKERS_MONO) ? 1
+									 : 2;
+	}
+
 	if (displayNrAudioChannels != currentNrAudioChannels) {
 		displayNrAudioChannels = currentNrAudioChannels;
 		recalculateLayout = true;
@@ -758,8 +766,9 @@ bool VolumeMeter::needLayoutChange()
 	return recalculateLayout;
 }
 
-// When this is called from the constructor, obs_volmeter_get_nr_channels returns 1
-// and Q_PROPERTY settings have not yet been read from the stylesheet.
+// When this is called from the constructor, obs_volmeter_get_nr_channels has not
+// yet been called and Q_PROPERTY settings have not yet been read from the
+// stylesheet.
 inline void VolumeMeter::doLayout()
 {
 	QMutexLocker locker(&dataMutex);