node-driver: support node.freewheel property

To activate freewheeling when initializing
This commit is contained in:
Wim Taymans 2021-05-06 18:22:17 +02:00
parent efc497a38a
commit 5c41131d6d

View file

@ -134,6 +134,8 @@ static void on_timeout(struct spa_source *source)
this->next_time = nsec + duration * SPA_NSEC_PER_SEC / rate; this->next_time = nsec + duration * SPA_NSEC_PER_SEC / rate;
if (SPA_LIKELY(this->clock)) { if (SPA_LIKELY(this->clock)) {
SPA_FLAG_UPDATE(this->clock->flags,
SPA_IO_CLOCK_FLAG_FREEWHEEL, this->props.freewheel);
this->clock->nsec = nsec; this->clock->nsec = nsec;
this->clock->position += duration; this->clock->position += duration;
this->clock->duration = duration; this->clock->duration = duration;
@ -302,6 +304,7 @@ impl_init(const struct spa_handle_factory *factory,
uint32_t n_support) uint32_t n_support)
{ {
struct impl *this; struct impl *this;
const char *str;
spa_return_val_if_fail(factory != NULL, -EINVAL); spa_return_val_if_fail(factory != NULL, -EINVAL);
spa_return_val_if_fail(handle != NULL, -EINVAL); spa_return_val_if_fail(handle != NULL, -EINVAL);
@ -354,6 +357,11 @@ impl_init(const struct spa_handle_factory *factory,
reset_props(&this->props); reset_props(&this->props);
if (info) {
if ((str = spa_dict_lookup(info, "node.freewheel")) != NULL)
this->props.freewheel = (strcmp(str, "true") == 0 || atoi(str) == 1);
}
spa_loop_add_source(this->data_loop, &this->timer_source); spa_loop_add_source(this->data_loop, &this->timer_source);
return 0; return 0;