[vlc-devel] [PATCH 8/9] pulse: handle AC-3 core + EAC3 ext

Thomas Guillem thomas at gllm.fr
Thu Oct 3 16:33:58 CEST 2019


And fallback to AC-3 if not supported (disabled from pavucontrol, not handled
by the amplifier, spdif...).

TODO: handle DTS-HD now that it is supported by PulseAudio.
---
 modules/audio_output/pulse.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 158244c425..a9abc0db4c 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -735,14 +735,19 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict original_
             ss.format = PA_SAMPLE_U8;
             break;
         case VLC_CODEC_A52:
-            fmt.i_format = VLC_CODEC_SPDIFL;
-            fmt.i_bytes_per_frame = 4;
-            fmt.i_frame_length = 1;
-            fmt.i_physical_channels = AOUT_CHANS_2_0;
-            fmt.i_channels = 2;
-            encoding = PA_ENCODING_AC3_IEC61937;
-            ss.format = PA_SAMPLE_S16NE;
-            break;
+            if (!fmt.extended)
+            {
+                fmt.i_format = VLC_CODEC_SPDIFL;
+                fmt.i_bytes_per_frame = 4;
+                fmt.i_frame_length = 1;
+                fmt.i_physical_channels = AOUT_CHANS_2_0;
+                fmt.i_channels = 2;
+                encoding = PA_ENCODING_AC3_IEC61937;
+                ss.format = PA_SAMPLE_S16NE;
+                break;
+            }
+            /* else AC-3 Core + EAC3 extension, try EAC3 first */
+            /* fall-through */
         case VLC_CODEC_EAC3:
             fmt.i_format = VLC_CODEC_SPDIFL;
             fmt.i_bytes_per_frame = 4;
@@ -948,8 +953,22 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict original_
                                    cvolume, NULL) < 0
      || stream_wait(s, sys->mainloop)) {
         if (encoding != PA_ENCODING_PCM)
+        {
+            pa_threaded_mainloop_unlock(sys->mainloop);
+            Stop(aout);
+            if (original_fmt->extended
+             && (original_fmt->i_format == VLC_CODEC_A52
+           /* || original_fmt->i_format == VLC_CODEC_DTS */))
+            {
+                msg_Warn(aout, "fallback to '%4.4s' core",
+                         (const char *)&original_fmt->i_format);
+                original_fmt->extended = false;
+                return Start(aout, original_fmt);
+            }
             vlc_pa_error(aout, "digital pass-through stream connection failure",
                          sys->context);
+            return VLC_EGENERIC;
+        }
         else
             vlc_pa_error(aout, "stream connection failure", sys->context);
         goto fail;
-- 
2.20.1



More information about the vlc-devel mailing list