]> code.delx.au - pulseaudio/commitdiff
alsa: Give compressed formats preference over PCM
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Tue, 4 Oct 2011 05:35:59 +0000 (11:05 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Tue, 4 Oct 2011 06:59:32 +0000 (12:29 +0530)
This makes set_formats() put PCM formats lower down the list than
compressed formats since we negotiate by picking the first format in
this list that is also in the client-provided list of possible formats
during sink input creation.

This will be incorrect if we ever decide to do encoding in PA (for
things like AC3/DTS encoding for multichannel output over S/PDIF).

src/modules/alsa/alsa-sink.c

index 5b8dd31544ea7559b3386f64c4fd9d2e2b0cfd26..80bd6bacd7a8d305f68e4a8054bd6161135ca383 100644 (file)
@@ -1534,8 +1534,20 @@ static pa_bool_t sink_set_formats(pa_sink *s, pa_idxset *formats) {
     pa_idxset_free(u->formats, (pa_free2_cb_t) pa_format_info_free2, NULL);
     u->formats = pa_idxset_new(NULL, NULL);
 
+    /* Note: the logic below won't apply if we're using software encoding.
+     * This is fine for now since we don't support that via the passthrough
+     * framework, but this must be changed if we do. */
+
+    /* First insert non-PCM formats since we prefer those. */
+    PA_IDXSET_FOREACH(f, formats, idx) {
+        if (!pa_format_info_is_pcm(f))
+            pa_idxset_put(u->formats, pa_format_info_copy(f), NULL);
+    }
+
+    /* Now add any PCM formats */
     PA_IDXSET_FOREACH(f, formats, idx) {
-        pa_idxset_put(u->formats, pa_format_info_copy(f), NULL);
+        if (pa_format_info_is_pcm(f))
+            pa_idxset_put(u->formats, pa_format_info_copy(f), NULL);
     }
 
     return TRUE;