node-driver: allow specifying both PHC and ID

This commit is contained in:
Dmitry Sharshakov 2023-06-17 10:23:24 +03:00 committed by Wim Taymans
parent 0fc1112c6d
commit f257c3407d
2 changed files with 16 additions and 14 deletions

View file

@ -539,10 +539,10 @@ impl_init(const struct spa_handle_factory *factory,
const char *s = info->items[i].value;
if (spa_streq(k, "node.freewheel")) {
this->props.freewheel = spa_atob(s);
} else if (spa_streq(k, "clock.name")) {
} else if (spa_streq(k, "clock.name") && this->clock_fd < 0) {
spa_scnprintf(this->props.clock_name,
sizeof(this->props.clock_name), "%s", s);
} else if (spa_streq(k, "clock.id")) {
} else if (spa_streq(k, "clock.id") && this->clock_fd < 0) {
this->props.clock_id = clock_name_to_id(s);
if (this->props.clock_id == -1) {
spa_log_warn(this->log, "unknown clock id '%s'", s);
@ -551,7 +551,7 @@ impl_init(const struct spa_handle_factory *factory,
} else if (spa_streq(k, "clock.device")) {
this->clock_fd = open(s, O_RDWR);
if (this->clock_fd == -1) {
spa_log_warn(this->log, "failed to open clock device '%s'", s);
spa_log_info(this->log, "failed to open clock device '%s'", s);
} else {
this->props.clock_id = FD_TO_CLOCKID(this->clock_fd);
}

View file

@ -223,17 +223,19 @@ context.objects = [
}
# An example clock reading from /dev/ptp0. Another option is to sync the
# ptp clock to CLOCK_TAI and then set clock.id = tai.
#{ factory = spa-node-factory
# args = {
# factory.name = support.node.driver
# node.name = PTP0-Driver
# node.group = pipewire.ptp0
# priority.driver = 30000
# clock.name = "clock.system.ptp0"
# clock.id = tai
# #clock.device = "/dev/ptp0"
# }
#}
# If both device and ID are given and available, device takes precedence
{ factory = spa-node-factory
args = {
factory.name = support.node.driver
node.name = PTP0-Driver
node.group = pipewire.ptp0
# This driver should only be used for network nodes marked with group
priority.driver = 0
clock.name = "clock.system.ptp0"
clock.device = "/dev/ptp0"
clock.id = tai
}
}
# This creates a new Source node. It will have input ports
# that you can link, to provide audio for this source.