diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-10-04 11:05:59 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2011-10-08 15:16:51 +0530 |
commit | 4e5943b6ba8b8f6bc45da24bf81d0828d990da20 (patch) | |
tree | e89e8fb81f266c747614031b3f02f1346f0cb07a | |
parent | d71a291721f6e61f8e874d4906ee012a3f5b2a63 (diff) |
alsa: Give compressed formats preference over PCM
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).
-rw-r--r-- | src/modules/alsa/alsa-sink.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 5b8dd315..80bd6bac 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -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; |