From 814c0371a493cf47df4e6e27253cfd5ec3cef783 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Wed, 17 Aug 2011 22:38:43 +0530 Subject: [PATCH] alsa: Open iec958 device with NONAUDIO bit set in passthrough mode This is required for E-AC3 streams, as well as to let receivers we're sending non-PCM data (which avoids playing noise if the data is incorrect for some reason). --- src/modules/alsa/alsa-sink.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 2bf19c601..88a750626 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -990,13 +990,22 @@ static int unsuspend(struct userdata *u) { int err; pa_bool_t b, d; snd_pcm_uframes_t period_size, buffer_size; + char *device_name = NULL; pa_assert(u); pa_assert(!u->pcm_handle); pa_log_info("Trying resume..."); - if ((err = snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STREAM_PLAYBACK, + if ((is_spdif(u) || is_hdmi(u)) && pa_sink_is_passthrough(u->sink)) { + /* Need to open device in NONAUDIO mode */ + int len = strlen(u->device_name) + 8; + + device_name = pa_xmalloc(len); + pa_snprintf(device_name, len, "%s,AES0=6", u->device_name); + } + + if ((err = snd_pcm_open(&u->pcm_handle, device_name ? device_name : u->device_name, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK| SND_PCM_NO_AUTO_RESAMPLE| SND_PCM_NO_AUTO_CHANNELS| @@ -1050,6 +1059,7 @@ static int unsuspend(struct userdata *u) { pa_log_info("Resumed successfully..."); + pa_xfree(device_name); return 0; fail: @@ -1058,6 +1068,8 @@ fail: u->pcm_handle = NULL; } + pa_xfree(device_name); + return -PA_ERR_IO; }