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; const char *s = info->items[i].value;
if (spa_streq(k, "node.freewheel")) { if (spa_streq(k, "node.freewheel")) {
this->props.freewheel = spa_atob(s); 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, spa_scnprintf(this->props.clock_name,
sizeof(this->props.clock_name), "%s", s); 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); this->props.clock_id = clock_name_to_id(s);
if (this->props.clock_id == -1) { if (this->props.clock_id == -1) {
spa_log_warn(this->log, "unknown clock id '%s'", s); 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")) { } else if (spa_streq(k, "clock.device")) {
this->clock_fd = open(s, O_RDWR); this->clock_fd = open(s, O_RDWR);
if (this->clock_fd == -1) { 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 { } else {
this->props.clock_id = FD_TO_CLOCKID(this->clock_fd); 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 # An example clock reading from /dev/ptp0. Another option is to sync the
# ptp clock to CLOCK_TAI and then set clock.id = tai. # ptp clock to CLOCK_TAI and then set clock.id = tai.
#{ factory = spa-node-factory # If both device and ID are given and available, device takes precedence
# args = { { factory = spa-node-factory
# factory.name = support.node.driver args = {
# node.name = PTP0-Driver factory.name = support.node.driver
# node.group = pipewire.ptp0 node.name = PTP0-Driver
# priority.driver = 30000 node.group = pipewire.ptp0
# clock.name = "clock.system.ptp0" # This driver should only be used for network nodes marked with group
# clock.id = tai priority.driver = 0
# #clock.device = "/dev/ptp0" clock.name = "clock.system.ptp0"
# } clock.device = "/dev/ptp0"
#} clock.id = tai
}
}
# This creates a new Source node. It will have input ports # This creates a new Source node. It will have input ports
# that you can link, to provide audio for this source. # that you can link, to provide audio for this source.