alsa: Open iec958 device with NONAUDIO bit set in passthrough mode
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Wed, 17 Aug 2011 17:08:43 +0000 (22:38 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Wed, 17 Aug 2011 17:38:45 +0000 (23:08 +0530)
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

index 2bf19c6..88a7506 100644 (file)
@@ -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;
 }