From c14881fbe2eb6de248e4f0d380650a02fcd22583 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 9 Jan 2020 16:43:08 +0100 Subject: [PATCH] Respect the rate from the position as the default --- spa/plugins/alsa/alsa-pcm.c | 6 ++++-- spa/plugins/audioconvert/audioconvert.c | 2 ++ spa/plugins/audioconvert/fmtconvert.c | 21 +++++++++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 63d75549b..6e4cadc50 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -258,7 +258,7 @@ spa_alsa_enum_format(struct state *state, int seq, uint32_t start, uint32_t num, bool opened; struct spa_pod_frame f[2]; struct spa_result_node_params result; - uint32_t count = 0; + uint32_t count = 0, rate; opened = state->opened; if ((err = spa_alsa_open(state)) < 0) @@ -323,7 +323,9 @@ spa_alsa_enum_format(struct state *state, int seq, uint32_t start, uint32_t num, spa_pod_builder_push_choice(&b, &f[1], SPA_CHOICE_None, 0); choice = (struct spa_pod_choice*)spa_pod_builder_frame(&b, &f[1]); - spa_pod_builder_int(&b, SPA_CLAMP(DEFAULT_RATE, min, max)); + rate = state->position ? state->position->clock.rate.denom : DEFAULT_RATE; + + spa_pod_builder_int(&b, SPA_CLAMP(rate, min, max)); if (min != max) { spa_pod_builder_int(&b, min); spa_pod_builder_int(&b, max); diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 284795945..5c5285ff1 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -506,6 +506,8 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) switch (id) { case SPA_IO_Position: res = spa_node_set_io(this->resample, id, data, size); + res = spa_node_set_io(this->fmt[0], id, data, size); + res = spa_node_set_io(this->fmt[1], id, data, size); break; default: res = -ENOENT; diff --git a/spa/plugins/audioconvert/fmtconvert.c b/spa/plugins/audioconvert/fmtconvert.c index 3f48219a1..cd6e93829 100644 --- a/spa/plugins/audioconvert/fmtconvert.c +++ b/spa/plugins/audioconvert/fmtconvert.c @@ -109,6 +109,8 @@ struct impl { struct spa_log *log; struct spa_cpu *cpu; + struct spa_io_position *io_position; + uint64_t info_all; struct spa_node_info info; struct props props; @@ -214,7 +216,20 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags, static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size) { - return -ENOTSUP; + struct impl *this = object; + + spa_return_val_if_fail(this != NULL, -EINVAL); + + spa_log_debug(this->log, NAME " %p: io %d %p/%zd", this, id, data, size); + + switch (id) { + case SPA_IO_Position: + this->io_position = data; + break; + default: + return -ENOENT; + } + return 0; } static int impl_node_send_command(void *object, const struct spa_command *command) @@ -387,9 +402,11 @@ static int port_enum_formats(void *object, info.info.raw.channels, info.info.raw.position); } } else { + uint32_t rate = this->io_position ? + this->io_position->clock.rate.denom : DEFAULT_RATE; spa_pod_builder_add(builder, SPA_FORMAT_AUDIO_rate, SPA_POD_CHOICE_RANGE_Int( - DEFAULT_RATE, 1, INT32_MAX), + rate, 1, INT32_MAX), SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int( DEFAULT_CHANNELS, 1, INT32_MAX), 0);