alsa-sink/source, sink, source: Consider sample format for avoid-resampling/passthrough

Sample format(e.g. 16 bit, 24 bit) was not considered even if the
avoid-resampling option is set or the passthrough mode is used.
This patch checks both sample format and rate of a stream to
determine whether to avoid resampling in case of the option is set.
In other word, it is possble to use the stream's original sample
format and rate without resampling as long as these are supported
by the device.

pa_sink_input_update_rate() and pa_source_output_update_rate() are
renamed to pa_sink_input_update_resampler() and pa_source_output
_update_resampler() respectively.

functions are added as below.
 pa_sink_set_sample_format(), pa_sink_set_sample_rate(),
 pa_source_set_sample_format(), pa_source_set_sample_rate()

Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
This commit is contained in:
Sangchul Lee 2018-11-16 01:12:05 +09:00 committed by Tanu Kaskinen
parent 73156649e7
commit 547998db44
11 changed files with 335 additions and 165 deletions

View file

@ -225,7 +225,7 @@ struct pa_source {
/* Called whenever device parameters need to be changed. Called from
* main thread. */
int (*reconfigure)(pa_source *s, pa_sample_spec *spec, bool passthrough);
void (*reconfigure)(pa_source *s, pa_sample_spec *spec, bool passthrough);
/* Contains copies of the above data so that the real-time worker
* thread can work without access locking */
@ -416,7 +416,7 @@ bool pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_proplist
int pa_source_set_port(pa_source *s, const char *name, bool save);
int pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, bool passthrough);
void pa_source_reconfigure(pa_source *s, pa_sample_spec *spec, bool passthrough);
unsigned pa_source_linked_by(pa_source *s); /* Number of connected streams */
unsigned pa_source_used_by(pa_source *s); /* Number of connected streams that are not corked */
@ -442,6 +442,9 @@ pa_idxset* pa_source_get_formats(pa_source *s);
bool pa_source_check_format(pa_source *s, pa_format_info *f);
pa_idxset* pa_source_check_formats(pa_source *s, pa_idxset *in_formats);
void pa_source_set_sample_format(pa_source *s, pa_sample_format_t format);
void pa_source_set_sample_rate(pa_source *s, uint32_t rate);
/*** To be called exclusively by the source driver, from IO context */
void pa_source_post(pa_source*s, const pa_memchunk *chunk);