[vlc-commits] alsa: set spdif options also if device was specified

Rafaël Carré git at videolan.org
Fri Jan 17 11:31:44 CET 2014


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Fri Jan 17 11:30:19 2014 +0100| [7a19c0b41e4c43392f423338d41b0bcebc3e5329] | committer: Rafaël Carré

alsa: set spdif options also if device was specified

On my laptop I need to specify --alsa-audio-device hdmi

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

 modules/audio_output/alsa.c |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index c285d5f..1aafeb6 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -327,7 +327,7 @@ 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 */
-    if (spdif && !strcmp (device, "default"))
+    if (spdif)
     {
         unsigned aes3;
 
@@ -345,8 +345,23 @@ 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,
-                      "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
+                      "%s%cAES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", device,
+                      opt ? ',' : ':',
                       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