Respect the rate from the position as the default

This commit is contained in:
Wim Taymans 2020-01-09 16:43:08 +01:00
parent 9b41e4dfd9
commit c14881fbe2
3 changed files with 25 additions and 4 deletions

View file

@ -258,7 +258,7 @@ spa_alsa_enum_format(struct state *state, int seq, uint32_t start, uint32_t num,
bool opened; bool opened;
struct spa_pod_frame f[2]; struct spa_pod_frame f[2];
struct spa_result_node_params result; struct spa_result_node_params result;
uint32_t count = 0; uint32_t count = 0, rate;
opened = state->opened; opened = state->opened;
if ((err = spa_alsa_open(state)) < 0) 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); spa_pod_builder_push_choice(&b, &f[1], SPA_CHOICE_None, 0);
choice = (struct spa_pod_choice*)spa_pod_builder_frame(&b, &f[1]); 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) { if (min != max) {
spa_pod_builder_int(&b, min); spa_pod_builder_int(&b, min);
spa_pod_builder_int(&b, max); spa_pod_builder_int(&b, max);

View file

@ -506,6 +506,8 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
switch (id) { switch (id) {
case SPA_IO_Position: case SPA_IO_Position:
res = spa_node_set_io(this->resample, id, data, size); 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; break;
default: default:
res = -ENOENT; res = -ENOENT;

View file

@ -109,6 +109,8 @@ struct impl {
struct spa_log *log; struct spa_log *log;
struct spa_cpu *cpu; struct spa_cpu *cpu;
struct spa_io_position *io_position;
uint64_t info_all; uint64_t info_all;
struct spa_node_info info; struct spa_node_info info;
struct props props; 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) 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) 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); info.info.raw.channels, info.info.raw.position);
} }
} else { } else {
uint32_t rate = this->io_position ?
this->io_position->clock.rate.denom : DEFAULT_RATE;
spa_pod_builder_add(builder, spa_pod_builder_add(builder,
SPA_FORMAT_AUDIO_rate, SPA_POD_CHOICE_RANGE_Int( 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( SPA_FORMAT_AUDIO_channels, SPA_POD_CHOICE_RANGE_Int(
DEFAULT_CHANNELS, 1, INT32_MAX), DEFAULT_CHANNELS, 1, INT32_MAX),
0); 0);