mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-01 22:58:47 -04:00
alsa: Reconfigure sink sample rate for passthrough inputs
When a passthrough sink-input is added, we need to reconfigure the sink's sample rate since no resampling occurs. We revert to the original rate when the passthrough sink-input is removed.
This commit is contained in:
parent
f94bcae6bd
commit
49b10ba694
1 changed files with 52 additions and 0 deletions
|
|
@ -108,6 +108,8 @@ struct userdata {
|
||||||
|
|
||||||
pa_cvolume hardware_volume;
|
pa_cvolume hardware_volume;
|
||||||
|
|
||||||
|
uint32_t old_rate;
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
frame_size,
|
frame_size,
|
||||||
fragment_size,
|
fragment_size,
|
||||||
|
|
@ -1051,6 +1053,56 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
|
||||||
|
case PA_SINK_MESSAGE_FINISH_MOVE:
|
||||||
|
case PA_SINK_MESSAGE_ADD_INPUT: {
|
||||||
|
pa_sink_input *i = PA_SINK_INPUT(data);
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
|
if (PA_LIKELY(pa_format_info_is_pcm(i->format)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
u->old_rate = u->sink->sample_spec.rate;
|
||||||
|
|
||||||
|
/* Passthrough format, see if we need to reset sink sample rate */
|
||||||
|
if (u->sink->sample_spec.rate == i->thread_info.sample_spec.rate)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* .. we do */
|
||||||
|
if ((r = suspend(u)) < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
u->sink->sample_spec.rate = i->thread_info.sample_spec.rate;
|
||||||
|
|
||||||
|
if ((r = unsuspend(u)) < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case PA_SINK_MESSAGE_START_MOVE:
|
||||||
|
case PA_SINK_MESSAGE_REMOVE_INPUT: {
|
||||||
|
pa_sink_input *i = PA_SINK_INPUT(data);
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
|
if (PA_LIKELY(pa_format_info_is_pcm(i->format)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Passthrough format, see if we need to reset sink sample rate */
|
||||||
|
if (u->sink->sample_spec.rate == u->old_rate)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* .. we do */
|
||||||
|
if ((r = suspend(u)) < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
u->sink->sample_spec.rate = u->old_rate;
|
||||||
|
|
||||||
|
if ((r = unsuspend(u)) < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case PA_SINK_MESSAGE_GET_LATENCY: {
|
case PA_SINK_MESSAGE_GET_LATENCY: {
|
||||||
pa_usec_t r = 0;
|
pa_usec_t r = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue