sink, source: Rework reconfiguration logic to apply to more than rate

This rejigs the update_rate() logic to encompass changes to the sample
spec as a whole, as well as passthrough status. As a result,
sinks/sources provide a reconfigure() method which allows
reconfiguration as required.

The behaviour itself is currently unchanged -- alsa-sink/-source do not
actually implement anything other than rate updates for now (nor are
they ever requested to). This can be modified in the future, to allow,
for example 24-bit output when incoming media supports it, as well as
channel count changes for passthrough sinks.

Another related change is that passthrough status is now part of
sink/source reconfiguration, and we can stop doing a suspend/unsuspend
when entering/leaving passthrough state. So that part is now divided
in two -- pa_sink_reconfigure() sets the sink in passthrough mode if
required, and pa_sink_enter_passthrough() sets up everything else
(this currently means only volumes, but could disable other processing)
for passthrough mode.
This commit is contained in:
Arun Raghavan 2017-09-03 16:53:17 +05:30
parent 4f1041c271
commit 7a7072557a
8 changed files with 90 additions and 94 deletions

View file

@ -1596,31 +1596,35 @@ static bool sink_set_formats(pa_sink *s, pa_idxset *formats) {
return true;
}
static int sink_update_rate_cb(pa_sink *s, uint32_t rate) {
static int sink_reconfigure_cb(pa_sink *s, pa_sample_spec *spec, bool passthrough) {
struct userdata *u = s->userdata;
int i;
bool supported = false;
/* FIXME: we only update rate for now */
pa_assert(u);
for (i = 0; u->rates[i]; i++) {
if (u->rates[i] == rate) {
if (u->rates[i] == spec->rate) {
supported = true;
break;
}
}
if (!supported) {
pa_log_info("Sink does not support sample rate of %d Hz", rate);
pa_log_info("Sink does not support sample rate of %d Hz", spec->rate);
return -1;
}
if (!PA_SINK_IS_OPENED(s->state)) {
pa_log_info("Updating rate for device %s, new rate is %d",u->device_name, rate);
u->sink->sample_spec.rate = rate;
pa_log_info("Updating rate for device %s, new rate is %d", u->device_name, spec->rate);
u->sink->sample_spec.rate = spec->rate;
return 0;
}
/* Passthrough status change is handled during unsuspend */
return -1;
}
@ -2357,7 +2361,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
else
u->sink->set_port = sink_set_port_cb;
if (u->sink->alternate_sample_rate)
u->sink->update_rate = sink_update_rate_cb;
u->sink->reconfigure = sink_reconfigure_cb;
u->sink->userdata = u;
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);