alsa-util/sink/source: Add infrastructure for supported sample formats

There has been a function to get supported sample rates from alsa and
an array for it in userdata of each module-alsa-sink/source. Similarly,
this patch adds a function to get supported sample formats(bit depth)
from alsa and an array for it to each userdata of the modules.

Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
This commit is contained in:
Sangchul Lee 2018-06-29 04:57:01 +09:00 committed by Tanu Kaskinen
parent 7c066fd886
commit 9d7055004e
4 changed files with 99 additions and 0 deletions

View file

@ -111,6 +111,7 @@ struct userdata {
pa_cvolume hardware_volume;
pa_sample_format_t *supported_formats;
unsigned int *rates;
size_t
@ -2349,6 +2350,12 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
if ((is_iec958(u) || is_hdmi(u)) && ss.channels == 2)
set_formats = true;
u->supported_formats = pa_alsa_get_supported_formats(u->pcm_handle, ss.format);
if (!u->supported_formats) {
pa_log_error("Failed to find any supported sample formats.");
goto fail;
}
u->rates = pa_alsa_get_supported_rates(u->pcm_handle, ss.rate);
if (!u->rates) {
pa_log_error("Failed to find any supported sample rates.");
@ -2629,6 +2636,9 @@ static void userdata_free(struct userdata *u) {
if (u->formats)
pa_idxset_free(u->formats, (pa_free_cb_t) pa_format_info_free);
if (u->supported_formats)
pa_xfree(u->supported_formats);
if (u->rates)
pa_xfree(u->rates);