[vlc-commits] PulseAudio: negotiate digital pass-through for A/52 and DTS

Rémi Denis-Courmont git at videolan.org
Tue Oct 4 19:33:00 CEST 2011


vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Sep 27 20:36:04 2011 +0300| [3367e357d8c416d14871c8f2bc5b02f3ab325c7a] | committer: Rémi Denis-Courmont

PulseAudio: negotiate digital pass-through for A/52 and DTS

(cherry picked from commit 5b24e072c971c5984ba29a16f029e36f13b3d5d1)

Conflicts:

	modules/audio_output/pulse.c

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=3367e357d8c416d14871c8f2bc5b02f3ab325c7a
---

 modules/audio_output/pulse.c |   69 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 154865f..d67dc31 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -439,6 +439,9 @@ static int Open(vlc_object_t *obj)
 
     /* Sample format specification */
     struct pa_sample_spec ss;
+#if PA_CHECK_VERSION(1,0,0)
+    pa_encoding_t encoding = PA_ENCODING_INVALID;
+#endif
 
     switch(aout->output.output.i_format)
     {
@@ -479,6 +482,28 @@ static int Open(vlc_object_t *obj)
         case VLC_CODEC_U8:
             ss.format = PA_SAMPLE_U8;
             break;
+#if PA_CHECK_VERSION(1,0,0)
+        case VLC_CODEC_A52:
+            aout->output.output.i_format = VLC_CODEC_SPDIFL;
+            encoding = PA_ENCODING_AC3_IEC61937;
+            ss.format = HAVE_FPU ? PA_SAMPLE_FLOAT32NE : PA_SAMPLE_S16NE;
+            break;
+        /*case VLC_CODEC_EAC3:
+            aout->output.output.i_format = VLC_CODEC_SPDIFL FIXME;
+            encoding = PA_ENCODING_EAC3_IEC61937;
+            ss.format = HAVE_FPU ? PA_SAMPLE_FLOAT32NE : PA_SAMPLE_S16NE;
+            break;
+        case VLC_CODEC_MPGA:
+            aout->output.output.i_format = VLC_CODEC_SPDIFL FIXME;
+            encoding = PA_ENCODING_MPEG_IEC61937;
+            ss.format = HAVE_FPU ? PA_SAMPLE_FLOAT32NE : PA_SAMPLE_S16NE;
+            break;*/
+        case VLC_CODEC_DTS:
+            aout->output.output.i_format = VLC_CODEC_SPDIFL;
+            encoding = PA_ENCODING_DTS_IEC61937;
+            ss.format = HAVE_FPU ? PA_SAMPLE_FLOAT32NE : PA_SAMPLE_S16NE;
+            break;
+#endif
         default:
             if (HAVE_FPU)
             {
@@ -605,8 +630,37 @@ static int Open(vlc_object_t *obj)
         goto fail;
     }
 
+#if PA_CHECK_VERSION(1,0,0)
+    pa_format_info *formatv[2];
+    unsigned formatc = 0;
+
+    /* Favor digital pass-through if available*/
+    if (encoding != PA_ENCODING_INVALID) {
+        formatv[formatc] = pa_format_info_new();
+        formatv[formatc]->encoding = encoding;
+        pa_format_info_set_rate(formatv[formatc], ss.rate);
+        pa_format_info_set_channels(formatv[formatc], ss.channels);
+        formatc++;
+    }
+
+    /* Fallback to PCM */
+    formatv[formatc] = pa_format_info_new();
+    formatv[formatc]->encoding = PA_ENCODING_PCM;
+    pa_format_info_set_sample_format(formatv[formatc], ss.format);
+    pa_format_info_set_rate(formatv[formatc], ss.rate);
+    pa_format_info_set_channels(formatv[formatc], ss.channels);
+    formatc++;
+
     /* Create a playback stream */
+    pa_stream *s;
+
+    s = pa_stream_new_extended(ctx, "audio stream", formatv, formatc, NULL);
+
+    for (unsigned i = 0; i < formatc; i++)
+        pa_format_info_free(formatv[i]);
+#else
     pa_stream *s = pa_stream_new(ctx, "audio stream", &ss, &map);
+#endif
     if (s == NULL) {
         error(aout, "cannot create stream", ctx);
         goto fail;
@@ -627,6 +681,21 @@ static int Open(vlc_object_t *obj)
     }
     stream_moved_cb(s, aout);
 
+#if PA_CHECK_VERSION(1,0,0)
+    if (encoding != PA_ENCODING_INVALID) {
+        const pa_format_info *info = pa_stream_get_format_info(s);
+
+        assert (info != NULL);
+        if (pa_format_info_is_pcm (info)) {
+            msg_Dbg(aout, "digital pass-through not available");
+            aout->output.output.i_format = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_S16N;
+        } else {
+            msg_Dbg(aout, "digital pass-through enabled");
+            pa_stream_set_latency_update_callback(s, NULL, NULL);
+        }
+    }
+#endif
+
     const struct pa_buffer_attr *pba = pa_stream_get_buffer_attr(s);
     msg_Dbg(aout, "using buffer metrics: maxlength=%u, tlength=%u, "
             "prebuf=%u, minreq=%u",



More information about the vlc-commits mailing list