[vlc-devel] [PATCH 10/10] pulse: handle DTS-HD
Thomas Guillem
thomas at gllm.fr
Wed Jan 18 09:20:09 CET 2017
---
modules/audio_output/pulse.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index 6986febebc..282cc0630a 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -687,10 +687,8 @@ static const char *str_map(const char *key, const char *const table[][2],
return (r != NULL) ? r[1] : NULL;
}
-/**
- * Create a PulseAudio playback stream, a.k.a. a sink input.
- */
-static int Start(audio_output_t *aout, audio_sample_format_t *restrict pfmt)
+static int Restart(audio_output_t *aout, audio_sample_format_t *restrict pfmt,
+ bool force_dts_core)
{
aout_sys_t *sys = aout->sys;
@@ -735,6 +733,17 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict pfmt)
ss.format = PA_SAMPLE_S16NE;
break;*/
case VLC_CODEC_DTS:
+ if (fmt.i_rate >= 48000 && !force_dts_core)
+ {
+ /* Try to configure the output rate (IEC958 rate) at 192kHz.
+ * Indeed, DTS-HD (and other DTS extensions) can only be
+ * transmitted at 192kHz minimum. We'll also be able to
+ * transmit DTS-Core only at this rate. */
+
+ /* FIXME: DTS-X and DTS-HDMA @192kHz should be transmitted at
+ * 768kHz. This is not possible (for now) with pulse audio. */
+ fmt.i_rate = 192000;
+ }
fmt.i_format = VLC_CODEC_SPDIFL;
fmt.i_bytes_per_frame = 4;
fmt.i_frame_length = 1;
@@ -923,8 +932,19 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict pfmt)
cvolume, NULL) < 0
|| stream_wait(s, sys->mainloop)) {
if (encoding != PA_ENCODING_INVALID)
+ {
+ if (pfmt->i_format == VLC_CODEC_DTS && fmt.i_rate == 192000
+ && !force_dts_core)
+ {
+ msg_Warn(aout, "configuring DTS at 192kHz IEC958 rate failed "
+ "(HDMI), fallback to 48kHz (S/PDIF)");
+ pa_threaded_mainloop_unlock(sys->mainloop);
+ Stop(aout);
+ return Restart(aout, pfmt, true);
+ }
vlc_pa_error(aout, "digital pass-through stream connection failure",
sys->context);
+ }
else
vlc_pa_error(aout, "stream connection failure", sys->context);
goto fail;
@@ -954,6 +974,14 @@ fail:
}
/**
+ * Create a PulseAudio playback stream, a.k.a. a sink input.
+ */
+static int Start(audio_output_t *aout, audio_sample_format_t *restrict pfmt)
+{
+ return Restart(aout, pfmt, false);
+}
+
+/**
* Removes a PulseAudio playback stream
*/
static void Stop(audio_output_t *aout)
--
2.11.0
More information about the vlc-devel
mailing list