[vlc-commits] alsa: add HDMI passthrough mode

Rémi Denis-Courmont git at videolan.org
Sun Apr 15 15:40:22 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr  8 12:31:53 2018 +0300| [24d281fedea113b98bfa55c675ba140493f63a8d] | committer: Rémi Denis-Courmont

alsa: add HDMI passthrough mode

(This is untested.)

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

 NEWS                        |  4 ++++
 modules/audio_output/alsa.c | 18 +++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 6ad7c760fd..087f434eb5 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,10 @@ Platform support changes:
      - Android 4.1.x or later (API-16)
      - GCC 5.0 or Clang 3.4 (or equivalent)
 
+Audio output:
+ * ALSA: HDMI passthrough support.
+   Use --alsa-passthrough to configure S/PDIF or HDMI passthrough.
+
 Demuxer:
  * Support for HEIF format
 
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 57c4e9641b..dd1889b41e 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -56,6 +56,7 @@ struct aout_sys_t
 enum {
     PASSTHROUGH_NONE,
     PASSTHROUGH_SPDIF,
+    PASSTHROUGH_HDMI,
 };
 
 #include "audio_output/volume.h"
@@ -84,10 +85,10 @@ static const char *const channels_text[] = {
 
 #define PASSTHROUGH_TEXT N_("Audio passthrough mode")
 static const int passthrough_modes[] = {
-    PASSTHROUGH_NONE, PASSTHROUGH_SPDIF,
+    PASSTHROUGH_NONE, PASSTHROUGH_SPDIF, PASSTHROUGH_HDMI,
 };
 static const char *const passthrough_modes_text[] = {
-    N_("None"), N_("S/PDIF"),
+    N_("None"), N_("S/PDIF"), N_("HDMI"),
 };
 
 vlc_module_begin ()
@@ -329,6 +330,13 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
                 passthrough = var_InheritInteger(aout, "alsa-passthrough");
                 channels = 2;
             }
+            if (AOUT_FMT_HDMI(fmt))
+            {
+                passthrough = var_InheritInteger(aout, "alsa-passthrough");
+                if (passthrough == PASSTHROUGH_SPDIF)
+                    passthrough = PASSTHROUGH_NONE; /* TODO? convert down */
+                channels = 8;
+            }
 
             if (passthrough != PASSTHROUGH_NONE)
             {
@@ -350,14 +358,14 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
 
     const char *device = sys->device;
 
-    /* Choose the IEC device for S/PDIF output */
+    /* Choose the device for passthrough output */
     char sep = '\0';
     if (passthrough != PASSTHROUGH_NONE)
     {
         const char *opt = NULL;
 
         if (!strcmp (device, "default"))
-            device = "iec958"; /* TODO: hdmi */
+            device = (passthrough == PASSTHROUGH_HDMI) ? "hdmi" : "iec958";
 
         if (!strncmp (device, "iec958", 6))
             opt = device + 6;
@@ -597,7 +605,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     /* Setup audio_output_t */
     if (passthrough != PASSTHROUGH_NONE)
     {
-        fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
+        fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE * (channels / 2);
         fmt->i_frame_length = A52_FRAME_NB;
     }
     fmt->channel_type = AUDIO_CHANNEL_TYPE_BITMAP;



More information about the vlc-commits mailing list