fix: separate grain processing thread from LWS event loop
The fundamental issue: mxlSleepUntil/mxlSleepForNs blocks the entire thread, making LWS unresponsive and causing control commands to hang. Meanwhile, LWS poll(1) adds latency that makes grain timing unreliable. Solution: run node->process() in a dedicated thread that can freely use mxlSleepUntil for precise grain timing, while the main thread runs control_server->poll(10) for LWS event handling. Passthrough now uses mxlSleepUntil(deadline) matching the mxl-gst-sink Cursor pattern, with 2-grain read delay for buffering.
This commit is contained in:
@@ -51,13 +51,12 @@ void PassthroughNode::on_remove_reader(const std::string& port_id) {
|
||||
|
||||
void PassthroughNode::process() {
|
||||
if (!reader_ || !writer_ || !aligned_) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
return;
|
||||
}
|
||||
|
||||
auto ns_until = mxlGetNsUntilIndex(read_index_, &grain_rate_);
|
||||
if (ns_until > 2000000ULL) {
|
||||
return;
|
||||
}
|
||||
auto deadline = mxlIndexToTimestamp(&grain_rate_, read_index_ + 1);
|
||||
mxlSleepUntil(deadline);
|
||||
|
||||
mxlGrainInfo grain_info{};
|
||||
uint8_t* payload = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user