Patch-Source: https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/commit/a400e057d182391f51cd7ab5078b9c5818efd7e8
--
From a400e057d182391f51cd7ab5078b9c5818efd7e8 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Mon, 10 Jan 2022 17:55:02 +0100
Subject: [PATCH] sink-widget: add support for TrueHD and DTS-HD formats

Also add toggles for TrueHD and DTS-HD formats in the sink widget.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/merge_requests/71>
---
 src/pavucontrol.glade | 26 ++++++++++++++++++++++++++
 src/sinkwidget.cc     | 22 ++++++++++++++++++++++
 src/sinkwidget.h      |  2 +-
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade
index 253534e..d081e8a 100644
--- a/src/pavucontrol.glade
+++ b/src/pavucontrol.glade
@@ -581,6 +581,32 @@
                                 <property name="top_attach">1</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkCheckButton" id="encodingFormatTRUEHD">
+                                <property name="label" translatable="yes">TrueHD</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">0</property>
+                                <property name="top_attach">2</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="encodingFormatDTSHD">
+                                <property name="label" translatable="yes">DTS-HD</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="top_attach">2</property>
+                              </packing>
+                            </child>
                           </object>
                           <packing>
                             <property name="expand">False</property>
diff --git a/src/sinkwidget.cc b/src/sinkwidget.cc
index b9002dd..f30bd37 100644
--- a/src/sinkwidget.cc
+++ b/src/sinkwidget.cc
@@ -73,6 +73,28 @@ SinkWidget::SinkWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
         encodings[i].widget->signal_toggled().connect(sigc::mem_fun(*this, &SinkWidget::onEncodingsChange));
         encodings[i].widget->set_sensitive(true);
     }
+#endif
+    ++i;
+    encodings[i].encoding = PA_ENCODING_INVALID;
+    x->get_widget("encodingFormatTRUEHD", encodings[i].widget);
+    encodings[i].widget->set_sensitive(false);
+#ifdef PA_ENCODING_TRUEHD_IEC61937
+    if (pa_context_get_server_protocol_version(get_context()) >= 33) {
+        encodings[i].encoding = PA_ENCODING_TRUEHD_IEC61937;
+        encodings[i].widget->signal_toggled().connect(sigc::mem_fun(*this, &SinkWidget::onEncodingsChange));
+        encodings[i].widget->set_sensitive(true);
+    }
+#endif
+    ++i;
+    encodings[i].encoding = PA_ENCODING_INVALID;
+    x->get_widget("encodingFormatDTSHD", encodings[i].widget);
+    encodings[i].widget->set_sensitive(false);
+#ifdef PA_ENCODING_DTSHD_IEC61937
+    if (pa_context_get_server_protocol_version(get_context()) >= 33) {
+        encodings[i].encoding = PA_ENCODING_DTSHD_IEC61937;
+        encodings[i].widget->signal_toggled().connect(sigc::mem_fun(*this, &SinkWidget::onEncodingsChange));
+        encodings[i].widget->set_sensitive(true);
+    }
 #endif
 #endif
 }
diff --git a/src/sinkwidget.h b/src/sinkwidget.h
index 924fca0..207d115 100644
--- a/src/sinkwidget.h
+++ b/src/sinkwidget.h
@@ -27,7 +27,7 @@
 #if HAVE_EXT_DEVICE_RESTORE_API
 #  include <pulse/format.h>
 
-#  define PAVU_NUM_ENCODINGS 6
+#  define PAVU_NUM_ENCODINGS 8
 
 typedef struct {
     pa_encoding encoding;
-- 
GitLab

