[vlc-commits] ALSA: only try S/PDIF default device if "spdif" is enabled

Rémi Denis-Courmont git at videolan.org
Mon Apr 18 18:02:33 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Apr 18 19:00:09 2011 +0300| [06ac7b773e98af42f5e391f5bc2662c98a2b1397] | committer: Rémi Denis-Courmont

ALSA: only try S/PDIF default device if "spdif" is enabled

Otherwise, use the normal default device even if the audio input format
is non-linear (VLC does A/52, DTS and MPGA to linear decoding as audio
filter rather than decoder).

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

 modules/audio_output/alsa.c |   67 ++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 32 deletions(-)

diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 71f2a45..58f9372 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -183,39 +183,10 @@ static int Open (vlc_object_t *obj)
     if (unlikely(psz_device == NULL))
         return VLC_ENOMEM;
 
-    /* Choose the IEC device for S/PDIF output:
-       if the device is overridden by the user then it will be the one
-       otherwise we compute the default device based on the output format. */
-    if (AOUT_FMT_NON_LINEAR(&p_aout->output.output)
-     && !strcmp (psz_device, DEFAULT_ALSA_DEVICE))
-    {
-        unsigned aes3;
-
-        switch (p_aout->output.output.i_rate)
-        {
-#define FS(freq) \
-            case freq: aes3 = IEC958_AES3_CON_FS_ ## freq; break;
-            FS( 44100) /* def. */ FS( 48000) FS( 32000)
-            FS( 22050)            FS( 24000)
-            FS( 88200) FS(768000) FS( 96000)
-            FS(176400)            FS(192000)
-#undef FS
-            default:
-                aes3 = IEC958_AES3_CON_FS_NOTID;
-                break;
-        }
-
-        free (psz_device);
-        if (asprintf (&psz_device,
-                      "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
-                      IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
-                      IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
-                      0, aes3) == -1)
-            return VLC_ENOMEM;
-    }
-
     snd_pcm_format_t pcm_format; /* ALSA sample format */
     vlc_fourcc_t fourcc = p_aout->output.output.i_format;
+    bool spdif = false;
+
     switch (fourcc)
     {
         case VLC_CODEC_F64B:
@@ -271,6 +242,8 @@ static int Open (vlc_object_t *obj)
             pcm_format = SND_PCM_FORMAT_U8;
             break;
         default:
+            if (AOUT_FMT_NON_LINEAR(&p_aout->output.output))
+                spdif = var_InheritBool (p_aout, "spdif");
             if (HAVE_FPU)
             {
                 fourcc = VLC_CODEC_FL32;
@@ -283,6 +256,36 @@ static int Open (vlc_object_t *obj)
             }
     }
 
+    /* Choose the IEC device for S/PDIF output:
+       if the device is overridden by the user then it will be the one
+       otherwise we compute the default device based on the output format. */
+    if (spdif && !strcmp (psz_device, DEFAULT_ALSA_DEVICE))
+    {
+        unsigned aes3;
+
+        switch (p_aout->output.output.i_rate)
+        {
+#define FS(freq) \
+            case freq: aes3 = IEC958_AES3_CON_FS_ ## freq; break;
+            FS( 44100) /* def. */ FS( 48000) FS( 32000)
+            FS( 22050)            FS( 24000)
+            FS( 88200) FS(768000) FS( 96000)
+            FS(176400)            FS(192000)
+#undef FS
+            default:
+                aes3 = IEC958_AES3_CON_FS_NOTID;
+                break;
+        }
+
+        free (psz_device);
+        if (asprintf (&psz_device,
+                      "iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x",
+                      IEC958_AES0_CON_EMPHASIS_NONE | IEC958_AES0_NONAUDIO,
+                      IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER,
+                      0, aes3) == -1)
+            return VLC_ENOMEM;
+    }
+
     /* Allocate structures */
     aout_sys_t *p_sys = malloc (sizeof (*p_sys));
     if (unlikely(p_sys == NULL))
@@ -339,7 +342,7 @@ static int Open (vlc_object_t *obj)
     snd_pcm_uframes_t i_period_size;
     int i_channels;
 
-    if (var_InheritBool (obj, "spdif"))
+    if (spdif)
     {
         fourcc = VLC_CODEC_SPDIFL;
         i_buffer_size = ALSA_SPDIF_BUFFER_SIZE;



More information about the vlc-commits mailing list