[vlc-commits] ALSA: only append AES parameters to iec958 and hdmi plugs

Rémi Denis-Courmont git at videolan.org
Mon Mar 16 19:05:00 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 16 20:01:05 2015 +0200| [8add728fb5bd34a73e97462960343f604660a48f] | committer: Rémi Denis-Courmont

ALSA: only append AES parameters to iec958 and hdmi plugs

Other ALSA plugs do not support those parameters.

Regresion from 7a19c0b41e4c43392f423338d41b0bcebc3e5329.

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

 modules/audio_output/alsa.c |   43 +++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 1aafeb6..9e0fe10 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -325,10 +325,32 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     }
 
     const char *device = sys->device;
-    char *devbuf = NULL;
+
     /* Choose the IEC device for S/PDIF output */
+    char sep = '\0';
     if (spdif)
     {
+        const char *opt;
+
+        if (!strcmp (device, "default"))
+            device = "iec958"; /* TODO: hdmi */
+
+        if (!strncmp (device, "iec958", 6))
+            opt = device + 6;
+        if (!strncmp (device, "hdmi", 4))
+            opt = device + 4;
+
+        if (opt != NULL)
+            switch (*opt)
+            {
+                case ':':  sep = ','; break;
+                case '\0': sep = ':'; break;
+            }
+    }
+
+    char *devbuf = NULL;
+    if (sep != '\0')
+    {
         unsigned aes3;
 
         switch (fmt->i_rate)
@@ -345,23 +367,8 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
                 break;
         }
 
-        char *opt = NULL;
-        if (!strcmp (device, "default"))
-            device = "iec958"; /* TODO: hdmi */
-        else
-        {
-            opt = strchr(device, ':');
-            if (opt && opt[1] == '\0') {
-                /* if device is terminated by : but there's no options,
-                 * remove ':', we'll add it back in the format string. */
-                *opt = '\0';
-                opt = NULL;
-            }
-        }
-
-        if (asprintf (&devbuf,
-                      "%s%cAES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", device,
-                      opt ? ',' : ':',
+        if (asprintf (&devbuf, "%s%cAES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
+                      device, sep,
                       IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
                       IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
                       0, aes3) == -1)



More information about the vlc-commits mailing list