Pip node #6
+31
-12
@@ -117,7 +117,8 @@ class PiPNode : public dmf::NodeBase {
|
|||||||
uint64_t index = mxlGetCurrentIndex(&rate);
|
uint64_t index = mxlGetCurrentIndex(&rate);
|
||||||
log("start index=%llu", index);
|
log("start index=%llu", index);
|
||||||
|
|
||||||
uint64_t frame_count = 0, timeout_count = 0;
|
uint64_t frame_count = 0, stall_count = 0;
|
||||||
|
bool fatal = false;
|
||||||
|
|
||||||
while (dmf::g_running.load(std::memory_order_relaxed)) {
|
while (dmf::g_running.load(std::memory_order_relaxed)) {
|
||||||
// WaitForDataAt expects TAI nanoseconds, not a grain index.
|
// WaitForDataAt expects TAI nanoseconds, not a grain index.
|
||||||
@@ -130,12 +131,24 @@ class PiPNode : public dmf::NodeBase {
|
|||||||
uint8_t* bg_buf = nullptr;
|
uint8_t* bg_buf = nullptr;
|
||||||
uint8_t* inset_buf = nullptr;
|
uint8_t* inset_buf = nullptr;
|
||||||
|
|
||||||
mxlFlowReaderGetGrainNonBlocking(bg_reader, index, &bg_grain, &bg_buf);
|
const mxlStatus bg_st = mxlFlowReaderGetGrainNonBlocking(
|
||||||
mxlFlowReaderGetGrainNonBlocking(inset_reader, index, &inset_grain, &inset_buf);
|
bg_reader, index, &bg_grain, &bg_buf);
|
||||||
|
const mxlStatus in_st = mxlFlowReaderGetGrainNonBlocking(
|
||||||
|
inset_reader, index, &inset_grain, &inset_buf);
|
||||||
|
|
||||||
|
if (bg_st != MXL_STATUS_OK || in_st != MXL_STATUS_OK || !bg_buf || !inset_buf) {
|
||||||
|
log("grain read after sync OK: bg=%s inset=%s at index=%llu",
|
||||||
|
dmf::mxl_status_str(bg_st), dmf::mxl_status_str(in_st), index);
|
||||||
|
index++;
|
||||||
|
} else {
|
||||||
mxlGrainInfo out_grain{};
|
mxlGrainInfo out_grain{};
|
||||||
uint8_t* out_buf = nullptr;
|
uint8_t* out_buf = nullptr;
|
||||||
if (mxlFlowWriterOpenGrain(out_writer, index, &out_grain, &out_buf) == MXL_STATUS_OK) {
|
const mxlStatus wst = mxlFlowWriterOpenGrain(
|
||||||
|
out_writer, index, &out_grain, &out_buf);
|
||||||
|
if (wst != MXL_STATUS_OK) {
|
||||||
|
log("writer OpenGrain failed (%s) at index=%llu",
|
||||||
|
dmf::mxl_status_str(wst), index);
|
||||||
|
} else {
|
||||||
std::memcpy(out_buf, bg_buf,
|
std::memcpy(out_buf, bg_buf,
|
||||||
static_cast<size_t>(bg_stride) * static_cast<size_t>(bg_h));
|
static_cast<size_t>(bg_stride) * static_cast<size_t>(bg_h));
|
||||||
|
|
||||||
@@ -149,27 +162,33 @@ class PiPNode : public dmf::NodeBase {
|
|||||||
out_grain.validSlices = out_grain.totalSlices;
|
out_grain.validSlices = out_grain.totalSlices;
|
||||||
mxlFlowWriterCommitGrain(out_writer, &out_grain);
|
mxlFlowWriterCommitGrain(out_writer, &out_grain);
|
||||||
frame_count++;
|
frame_count++;
|
||||||
|
if (frame_count % 25 == 0)
|
||||||
|
log("heartbeat frames=%llu stalls=%llu index=%llu",
|
||||||
|
frame_count, stall_count, index);
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (st == MXL_ERR_TIMEOUT ||
|
} else if (st == MXL_ERR_TIMEOUT ||
|
||||||
st == MXL_ERR_OUT_OF_RANGE_TOO_EARLY ||
|
st == MXL_ERR_OUT_OF_RANGE_TOO_EARLY ||
|
||||||
st == MXL_ERR_OUT_OF_RANGE_TOO_LATE) {
|
st == MXL_ERR_OUT_OF_RANGE_TOO_LATE) {
|
||||||
timeout_count++;
|
stall_count++;
|
||||||
const uint64_t current = mxlGetCurrentIndex(&rate);
|
const uint64_t current = mxlGetCurrentIndex(&rate);
|
||||||
index = (current > index) ? current : index + 1;
|
const uint64_t next = (current > index) ? current : index + 1;
|
||||||
if (timeout_count % 25 == 1)
|
log("sync stall (%s) at index=%llu → jumping to %llu frames=%llu",
|
||||||
log("sync stall (%s) frames=%llu count=%llu",
|
dmf::mxl_status_str(st), index, next, frame_count);
|
||||||
dmf::mxl_status_str(st), frame_count, timeout_count);
|
index = next;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log("sync error (%s) at index=%llu", dmf::mxl_status_str(st), index);
|
log("sync fatal (%s) at index=%llu", dmf::mxl_status_str(st), index);
|
||||||
|
fatal = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("stopped at index=%llu frames=%llu timeouts=%llu",
|
log("stopped: %s frames=%llu stalls=%llu index=%llu",
|
||||||
index, frame_count, timeout_count);
|
fatal ? "fatal error" : "shutdown signal",
|
||||||
|
frame_count, stall_count, index);
|
||||||
|
|
||||||
mxlReleaseFlowSynchronizationGroup(instance(), sync_group);
|
mxlReleaseFlowSynchronizationGroup(instance(), sync_group);
|
||||||
mxlReleaseFlowReader(instance(), bg_reader);
|
mxlReleaseFlowReader(instance(), bg_reader);
|
||||||
|
|||||||
Reference in New Issue
Block a user