From ba3c2994eeca9339d207651b9e2f6c1c7facfe9c Mon Sep 17 00:00:00 2001 From: itten Date: Fri, 3 Jul 2026 09:52:29 +0300 Subject: [PATCH 1/6] ndi out before refactoring --- .vscode/c_cpp_properties.json | 1 + nodes/ndiout/main.cpp | 122 +++++++++++++++++++++++++++------- studio-manager/main.cpp | 14 ++-- 3 files changed, 108 insertions(+), 29 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index fb5ba7c..2bd9817 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,6 +4,7 @@ "name": "Linux", "includePath": [ "${workspaceFolder}/**", + "${workspaceFolder}/shared", "${HOME}/SDK/NDI/include" ], "defines": [], diff --git a/nodes/ndiout/main.cpp b/nodes/ndiout/main.cpp index a0ed70a..19163f2 100644 --- a/nodes/ndiout/main.cpp +++ b/nodes/ndiout/main.cpp @@ -53,15 +53,15 @@ class NDIOutNode : public dmf::NodeBase { if (!dmf::g_running) return; log("flow active — starting read"); - mxlFlowReader reader{}; - mxlStatus st = mxlCreateFlowReader(instance(), flow_id.c_str(), nullptr, &reader); - if (st != MXL_STATUS_OK) { - log("mxlCreateFlowReader failed (status=%d)", st); + mxlFlowReader video_reader{}; + mxlStatus vst = mxlCreateFlowReader(instance(), flow_id.c_str(), nullptr, &video_reader); + if (vst != MXL_STATUS_OK) { + log("mxlCreateFlowReader failed (status=%d)", vst); return; } - mxlFlowConfigInfo cfg_info{}; - mxlFlowReaderGetConfigInfo(reader, &cfg_info); - const uint32_t mxl_stride = cfg_info.discrete.sliceSizes[0]; + mxlFlowConfigInfo video_cfg{}; + mxlFlowReaderGetConfigInfo(video_reader, &video_cfg); + const uint32_t mxl_stride = video_cfg.discrete.sliceSizes[0]; NDIContext ndi(flow_id.c_str()); @@ -72,6 +72,8 @@ class NDIOutNode : public dmf::NodeBase { NDIlib_video_frame_v2_t ndi_frame_10bit{}; ndi_frame_10bit.xres = width; ndi_frame_10bit.yres = height; + ndi_frame_10bit.frame_rate_N = fps_num; + ndi_frame_10bit.frame_rate_D = fps_den; ndi_frame_10bit.FourCC = static_cast(NDI_LIB_FOURCC('V','2','1','0')); ndi_frame_10bit.line_stride_in_bytes = mxl_stride; ndi_frame_10bit.p_data = buf_10bit.data(); @@ -84,8 +86,48 @@ class NDIOutNode : public dmf::NodeBase { ndi_frame_16bit.line_stride_in_bytes = width * static_cast(sizeof(uint16_t)); ndi_frame_16bit.p_data = buf_16bit.data(); - const mxlRational rate = {fps_num, fps_den}; - uint64_t index = mxlGetCurrentIndex(&rate); + // audio + mxlFlowReader audio_reader{}; + mxlFlowConfigInfo audio_cfg{}; + mxlStatus ast; + + int sample_rate = 0; + int channels = 0; + int bit_depth = 32; + int no_samples = 0; + bool has_audio = config().contains("audio_flow_id"); + + if (has_audio) + { + const auto audio_flow_info = config().at("audio_flow_id"); + const auto audio_flow_id = audio_flow_info.at("id").get(); + ast = mxlCreateFlowReader(instance(), audio_flow_id.c_str(), nullptr, &audio_reader); + if (ast != MXL_STATUS_OK) { + log("audio mxlCreateFlowReader failed (status=%d) — continuing without audio", ast); + has_audio = false; + } else { + mxlFlowReaderGetConfigInfo(audio_reader, &audio_cfg); + sample_rate = audio_flow_info.at("sample_rate").get(); + channels = audio_cfg.continuous.channelCount; + no_samples = sample_rate / fps_num; + log("audio channels: %i, samples: %i", channels, audio_cfg.continuous.bufferLength); + } + } + + NDIlib_audio_frame_v3_t ndi_audio_frame; + ndi_audio_frame.sample_rate = sample_rate; + ndi_audio_frame.no_channels = channels; + ndi_audio_frame.no_samples = no_samples; + ndi_audio_frame.FourCC = NDIlib_FourCC_audio_type_FLTP; + ndi_audio_frame.channel_stride_in_bytes = ndi_audio_frame.no_samples * sizeof(float); + + // core loop + const mxlRational video_rate = {fps_num, fps_den}; + const mxlRational audio_rate = {sample_rate, 1}; + + uint64_t video_index = mxlGetCurrentIndex(&video_rate); + uint64_t audio_index = has_audio ? mxlGetCurrentIndex(&audio_rate) : 0; + uint64_t frame_count = 0; uint64_t invalid_count = 0; uint64_t late_count = 0; @@ -93,19 +135,50 @@ class NDIOutNode : public dmf::NodeBase { auto wall_start = std::chrono::steady_clock::now(); auto last_log_time = wall_start; + std::vector audio_planar(static_cast(channels) * no_samples); + ndi_audio_frame.p_data = reinterpret_cast(audio_planar.data()); + while (dmf::g_running.load(std::memory_order_relaxed)) { - mxlGrainInfo grain{}; - uint8_t* buf = nullptr; + mxlGrainInfo video_grain{}; + mxlGrainInfo audio_grain{}; + uint8_t* video_buf = nullptr; + mxlWrappedMultiBufferSlice audio_slices; - st = mxlFlowReaderGetGrainNonBlocking(reader, index, &grain, &buf); + vst = mxlFlowReaderGetGrainNonBlocking(video_reader, video_index, &video_grain, &video_buf); + bool ndi_has_connections = NDIlib_send_get_no_connections(ndi.sender, 0) > 0; - if (st == MXL_STATUS_OK) { + if (has_audio) { + ast = mxlFlowReaderGetSamplesNonBlocking(audio_reader, audio_index, no_samples, &audio_slices); + if (ast == MXL_STATUS_OK) { + for (size_t c = 0; c < audio_slices.count; c++) { + float* dst = audio_planar.data() + c * 1920; + size_t frag0_samples = audio_slices.base.fragments[0].size / sizeof(float); + const uint8_t* src0 = static_cast(audio_slices.base.fragments[0].pointer) + + c * audio_slices.stride; + std::memcpy(dst, src0, frag0_samples * sizeof(float)); + + if (audio_slices.base.fragments[1].size > 0) { + size_t frag1_samples = audio_slices.base.fragments[1].size / sizeof(float); + const uint8_t* src1 = static_cast(audio_slices.base.fragments[1].pointer) + + c * audio_slices.stride; + std::memcpy(dst + frag0_samples, src1, frag1_samples * sizeof(float)); + } + } + NDIlib_send_send_audio_v3(ndi.sender, &ndi_audio_frame); + audio_index += no_samples; + } else if (ast == MXL_ERR_OUT_OF_RANGE_TOO_LATE) { + mxlFlowRuntimeInfo ari{}; + mxlFlowReaderGetRuntimeInfo(audio_reader, &ari); + audio_index = ari.headIndex; + } + } + + if (vst == MXL_STATUS_OK) { frame_count++; - if (grain.flags & MXL_GRAIN_FLAG_INVALID) invalid_count++; - index++; + if (video_grain.flags & MXL_GRAIN_FLAG_INVALID) invalid_count++; - if (NDIlib_send_get_no_connections(ndi.sender, 0) > 0) { - std::memcpy(ndi_frame_10bit.p_data, buf, mxl_stride * height); + if (ndi_has_connections) { + std::memcpy(ndi_frame_10bit.p_data, video_buf, mxl_stride * height); NDIlib_util_V210_to_P216(&ndi_frame_10bit, &ndi_frame_16bit); NDIlib_send_send_video_v2(ndi.sender, &ndi_frame_16bit); if (++ndi_frame_count == 1) @@ -114,17 +187,19 @@ class NDIOutNode : public dmf::NodeBase { ndi_frame_count = 0; } - } else if (st == MXL_ERR_OUT_OF_RANGE_TOO_EARLY) { + video_index++; + + } else if (vst == MXL_ERR_OUT_OF_RANGE_TOO_EARLY) { mxlSleepForNs(1'000'000); - } else if (st == MXL_ERR_OUT_OF_RANGE_TOO_LATE) { + } else if (vst == MXL_ERR_OUT_OF_RANGE_TOO_LATE) { late_count++; mxlFlowRuntimeInfo ri{}; - mxlFlowReaderGetRuntimeInfo(reader, &ri); - index = ri.headIndex; + mxlFlowReaderGetRuntimeInfo(video_reader, &ri); + video_index = ri.headIndex; } else { - log("unexpected status=%d on index=%llu", st, index); + log("unexpected status=%d on index=%llu", vst, video_index); break; } @@ -140,7 +215,8 @@ class NDIOutNode : public dmf::NodeBase { log("stopped — total frames=%llu invalid=%llu late=%llu", frame_count, invalid_count, late_count); - mxlReleaseFlowReader(instance(), reader); + mxlReleaseFlowReader(instance(), video_reader); + if (has_audio) mxlReleaseFlowReader(instance(), audio_reader); } }; diff --git a/studio-manager/main.cpp b/studio-manager/main.cpp index 5d37016..bf240bb 100644 --- a/studio-manager/main.cpp +++ b/studio-manager/main.cpp @@ -44,8 +44,8 @@ static dmf::FlowGraph build_graph() { const std::string ndi_audio_flow = gen_uuid(); g.nodes = { { "testpattern", "testpattern", {{"pattern", "bars"}} }, - { "ndiin", "ndiin", {} }, - { "fakesink", "fakesink", {} }, + // { "ndiin", "ndiin", {} }, + // { "fakesink", "fakesink", {} }, { "ndiout", "ndiout", {} }, }; const nlohmann::json video_fmt = { @@ -55,10 +55,12 @@ static dmf::FlowGraph build_graph() { {"kind","audio"}, {"sample_rate",48000}, {"channels",2}, {"bit_depth",32} }; g.edges = { - { tp_video_flow, "testpattern", "flow_id", "fakesink", "flow_id", video_fmt }, - { tp_audio_flow, "testpattern", "audio_flow_id", "", "", audio_fmt }, - { ndi_video_flow, "ndiin", "video_flow_id", "ndiout", "flow_id", video_fmt }, - { ndi_audio_flow, "ndiin", "audio_flow_id", "", "", audio_fmt }, + // { tp_video_flow, "testpattern", "flow_id", "fakesink", "flow_id", video_fmt }, + // { tp_audio_flow, "testpattern", "audio_flow_id", "", "", audio_fmt }, + // { ndi_video_flow, "ndiin", "video_flow_id", "ndiout", "flow_id", video_fmt }, + // { ndi_audio_flow, "ndiin", "audio_flow_id", "", "", audio_fmt }, + { tp_video_flow, "testpattern", "flow_id", "ndiout", "flow_id", video_fmt }, + { tp_audio_flow, "testpattern", "audio_flow_id", "ndiout", "audio_flow_id", audio_fmt }, }; return g; } -- 2.52.0 From b7fb54e2bc0b3d189767d50bad9736143f3a158e Mon Sep 17 00:00:00 2001 From: JohannesItten Date: Fri, 3 Jul 2026 09:58:06 +0300 Subject: [PATCH 2/6] =?UTF-8?q?refactor:=20clean=20up=20ndiout=20=E2=80=94?= =?UTF-8?q?=20fix=20hardcoded=201920,=20consistent=20naming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: c * 1920 → c * samples_per_frame (broke non-25fps or non-48kHz). Fix: audio channel loop now iterates `channels` not `audio_slices.count`. Rename: mxl_stride → video_stride, no_samples → samples_per_frame, ndi_frame_10bit/16bit → v210_frame/p216_frame, ndi_audio_frame → ndi_audio. Scope `ast` locally to its use block. Drop unused #include "V210.hpp" and #include "FlowDef.hpp". ndi_audio struct zero-initialized then filled only when has_audio. Co-Authored-By: Claude Sonnet 4.6 --- nodes/ndiout/main.cpp | 193 +++++++++++++++++++++--------------------- 1 file changed, 96 insertions(+), 97 deletions(-) diff --git a/nodes/ndiout/main.cpp b/nodes/ndiout/main.cpp index 19163f2..b1629be 100644 --- a/nodes/ndiout/main.cpp +++ b/nodes/ndiout/main.cpp @@ -6,8 +6,6 @@ #include #include #include "NodeBase.hpp" -#include "FlowDef.hpp" -#include "V210.hpp" #include // RAII wrapper: init NDI, create sender, destroy both on scope exit. @@ -35,6 +33,7 @@ struct NDIContext { class NDIOutNode : public dmf::NodeBase { void run() override { + // --- video flow --- const auto flow_info = config().at("flow_id"); const auto flow_id = flow_info.at("id").get(); const int width = flow_info.value("width", 1920); @@ -42,7 +41,7 @@ class NDIOutNode : public dmf::NodeBase { const int fps_num = flow_info.value("fps_num", 25); const int fps_den = flow_info.value("fps_den", 1); - log("flow=%s", flow_id.c_str()); + log("flow=%s %dx%d @ %d/%d fps", flow_id.c_str(), width, height, fps_num, fps_den); log("waiting for flow to become active..."); bool active = false; @@ -53,119 +52,114 @@ class NDIOutNode : public dmf::NodeBase { if (!dmf::g_running) return; log("flow active — starting read"); - mxlFlowReader video_reader{}; - mxlStatus vst = mxlCreateFlowReader(instance(), flow_id.c_str(), nullptr, &video_reader); - if (vst != MXL_STATUS_OK) { - log("mxlCreateFlowReader failed (status=%d)", vst); - return; - } + mxlFlowReader video_reader{}; mxlFlowConfigInfo video_cfg{}; + mxlStatus vst = mxlCreateFlowReader(instance(), flow_id.c_str(), nullptr, &video_reader); + if (vst != MXL_STATUS_OK) { log("mxlCreateFlowReader failed (status=%d)", vst); return; } mxlFlowReaderGetConfigInfo(video_reader, &video_cfg); - const uint32_t mxl_stride = video_cfg.discrete.sliceSizes[0]; + const uint32_t video_stride = video_cfg.discrete.sliceSizes[0]; - NDIContext ndi(flow_id.c_str()); - - // V210 (10-bit) intermediate and P216 (16-bit) send buffers - std::vector buf_10bit(mxl_stride * height); - std::vector buf_16bit(width * sizeof(uint16_t) * 2 * height); - - NDIlib_video_frame_v2_t ndi_frame_10bit{}; - ndi_frame_10bit.xres = width; - ndi_frame_10bit.yres = height; - ndi_frame_10bit.frame_rate_N = fps_num; - ndi_frame_10bit.frame_rate_D = fps_den; - ndi_frame_10bit.FourCC = static_cast(NDI_LIB_FOURCC('V','2','1','0')); - ndi_frame_10bit.line_stride_in_bytes = mxl_stride; - ndi_frame_10bit.p_data = buf_10bit.data(); - - NDIlib_video_frame_v2_t ndi_frame_16bit{}; - ndi_frame_16bit.xres = width; - ndi_frame_16bit.yres = height; - ndi_frame_16bit.frame_rate_N = fps_num; - ndi_frame_16bit.frame_rate_D = fps_den; - ndi_frame_16bit.line_stride_in_bytes = width * static_cast(sizeof(uint16_t)); - ndi_frame_16bit.p_data = buf_16bit.data(); - - // audio - mxlFlowReader audio_reader{}; + // --- audio flow (optional) --- + mxlFlowReader audio_reader{}; mxlFlowConfigInfo audio_cfg{}; - mxlStatus ast; - - int sample_rate = 0; - int channels = 0; - int bit_depth = 32; - int no_samples = 0; - bool has_audio = config().contains("audio_flow_id"); + int sample_rate = 0; + int channels = 0; + int samples_per_frame = 0; + bool has_audio = config().contains("audio_flow_id"); - if (has_audio) - { + if (has_audio) { const auto audio_flow_info = config().at("audio_flow_id"); - const auto audio_flow_id = audio_flow_info.at("id").get(); - ast = mxlCreateFlowReader(instance(), audio_flow_id.c_str(), nullptr, &audio_reader); + const auto audio_flow_id = audio_flow_info.at("id").get(); + sample_rate = audio_flow_info.value("sample_rate", 48000); + channels = audio_flow_info.value("channels", 2); + samples_per_frame = sample_rate / fps_num; + + log("audio flow=%s %d Hz %dch %d samples/frame", + audio_flow_id.c_str(), sample_rate, channels, samples_per_frame); + + mxlStatus ast = mxlCreateFlowReader(instance(), audio_flow_id.c_str(), nullptr, &audio_reader); if (ast != MXL_STATUS_OK) { log("audio mxlCreateFlowReader failed (status=%d) — continuing without audio", ast); has_audio = false; } else { mxlFlowReaderGetConfigInfo(audio_reader, &audio_cfg); - sample_rate = audio_flow_info.at("sample_rate").get(); - channels = audio_cfg.continuous.channelCount; - no_samples = sample_rate / fps_num; - log("audio channels: %i, samples: %i", channels, audio_cfg.continuous.bufferLength); + log("audio channels=%u buffer=%u samples", + audio_cfg.continuous.channelCount, audio_cfg.continuous.bufferLength); } } - NDIlib_audio_frame_v3_t ndi_audio_frame; - ndi_audio_frame.sample_rate = sample_rate; - ndi_audio_frame.no_channels = channels; - ndi_audio_frame.no_samples = no_samples; - ndi_audio_frame.FourCC = NDIlib_FourCC_audio_type_FLTP; - ndi_audio_frame.channel_stride_in_bytes = ndi_audio_frame.no_samples * sizeof(float); - - // core loop + NDIContext ndi(flow_id.c_str()); + + // V210 intermediate and P216 send buffers for NDI video + std::vector v210_buf(video_stride * height); + std::vector p216_buf(width * sizeof(uint16_t) * 2 * height); + + NDIlib_video_frame_v2_t v210_frame{}; + v210_frame.xres = width; + v210_frame.yres = height; + v210_frame.frame_rate_N = fps_num; + v210_frame.frame_rate_D = fps_den; + v210_frame.FourCC = static_cast(NDI_LIB_FOURCC('V','2','1','0')); + v210_frame.line_stride_in_bytes = video_stride; + v210_frame.p_data = v210_buf.data(); + + NDIlib_video_frame_v2_t p216_frame{}; + p216_frame.xres = width; + p216_frame.yres = height; + p216_frame.frame_rate_N = fps_num; + p216_frame.frame_rate_D = fps_den; + p216_frame.line_stride_in_bytes = width * static_cast(sizeof(uint16_t)); + p216_frame.p_data = p216_buf.data(); + + // Float planar buffer for NDI audio (ch0 samples, ch1 samples, ...) + std::vector audio_planar(static_cast(channels) * samples_per_frame); + NDIlib_audio_frame_v3_t ndi_audio{}; + if (has_audio) { + ndi_audio.sample_rate = sample_rate; + ndi_audio.no_channels = channels; + ndi_audio.no_samples = samples_per_frame; + ndi_audio.FourCC = NDIlib_FourCC_audio_type_FLTP; + ndi_audio.channel_stride_in_bytes = samples_per_frame * sizeof(float); + ndi_audio.p_data = reinterpret_cast(audio_planar.data()); + } + + // --- main loop --- const mxlRational video_rate = {fps_num, fps_den}; const mxlRational audio_rate = {sample_rate, 1}; - uint64_t video_index = mxlGetCurrentIndex(&video_rate); - uint64_t audio_index = has_audio ? mxlGetCurrentIndex(&audio_rate) : 0; - - uint64_t frame_count = 0; - uint64_t invalid_count = 0; - uint64_t late_count = 0; + uint64_t video_index = mxlGetCurrentIndex(&video_rate); + uint64_t audio_index = has_audio ? mxlGetCurrentIndex(&audio_rate) : 0; + uint64_t frame_count = 0; + uint64_t invalid_count = 0; + uint64_t late_count = 0; uint64_t ndi_frame_count = 0; - auto wall_start = std::chrono::steady_clock::now(); - auto last_log_time = wall_start; - - std::vector audio_planar(static_cast(channels) * no_samples); - ndi_audio_frame.p_data = reinterpret_cast(audio_planar.data()); + auto wall_start = std::chrono::steady_clock::now(); + auto last_log_time = wall_start; while (dmf::g_running.load(std::memory_order_relaxed)) { - mxlGrainInfo video_grain{}; - mxlGrainInfo audio_grain{}; - uint8_t* video_buf = nullptr; - mxlWrappedMultiBufferSlice audio_slices; - - vst = mxlFlowReaderGetGrainNonBlocking(video_reader, video_index, &video_grain, &video_buf); - bool ndi_has_connections = NDIlib_send_get_no_connections(ndi.sender, 0) > 0; - + // --- audio: non-blocking, one chunk per video frame --- if (has_audio) { - ast = mxlFlowReaderGetSamplesNonBlocking(audio_reader, audio_index, no_samples, &audio_slices); + mxlWrappedMultiBufferSlice audio_slices{}; + mxlStatus ast = mxlFlowReaderGetSamplesNonBlocking( + audio_reader, audio_index, samples_per_frame, &audio_slices); if (ast == MXL_STATUS_OK) { - for (size_t c = 0; c < audio_slices.count; c++) { - float* dst = audio_planar.data() + c * 1920; - size_t frag0_samples = audio_slices.base.fragments[0].size / sizeof(float); - const uint8_t* src0 = static_cast(audio_slices.base.fragments[0].pointer) - + c * audio_slices.stride; - std::memcpy(dst, src0, frag0_samples * sizeof(float)); - - if (audio_slices.base.fragments[1].size > 0) { - size_t frag1_samples = audio_slices.base.fragments[1].size / sizeof(float); - const uint8_t* src1 = static_cast(audio_slices.base.fragments[1].pointer) - + c * audio_slices.stride; - std::memcpy(dst + frag0_samples, src1, frag1_samples * sizeof(float)); + const size_t frag0 = audio_slices.base.fragments[0].size / sizeof(float); + const size_t frag1 = audio_slices.base.fragments[1].size / sizeof(float); + for (int c = 0; c < channels; ++c) { + float* dst = audio_planar.data() + c * samples_per_frame; + const auto* src0 = reinterpret_cast( + static_cast(audio_slices.base.fragments[0].pointer) + + c * audio_slices.stride); + std::memcpy(dst, src0, frag0 * sizeof(float)); + if (frag1 > 0) { + const auto* src1 = reinterpret_cast( + static_cast(audio_slices.base.fragments[1].pointer) + + c * audio_slices.stride); + std::memcpy(dst + frag0, src1, frag1 * sizeof(float)); } } - NDIlib_send_send_audio_v3(ndi.sender, &ndi_audio_frame); - audio_index += no_samples; + NDIlib_send_send_audio_v3(ndi.sender, &ndi_audio); + audio_index += samples_per_frame; } else if (ast == MXL_ERR_OUT_OF_RANGE_TOO_LATE) { mxlFlowRuntimeInfo ari{}; mxlFlowReaderGetRuntimeInfo(audio_reader, &ari); @@ -173,16 +167,21 @@ class NDIOutNode : public dmf::NodeBase { } } + // --- video --- + mxlGrainInfo video_grain{}; + uint8_t* video_buf = nullptr; + vst = mxlFlowReaderGetGrainNonBlocking(video_reader, video_index, &video_grain, &video_buf); + if (vst == MXL_STATUS_OK) { frame_count++; if (video_grain.flags & MXL_GRAIN_FLAG_INVALID) invalid_count++; - if (ndi_has_connections) { - std::memcpy(ndi_frame_10bit.p_data, video_buf, mxl_stride * height); - NDIlib_util_V210_to_P216(&ndi_frame_10bit, &ndi_frame_16bit); - NDIlib_send_send_video_v2(ndi.sender, &ndi_frame_16bit); + if (NDIlib_send_get_no_connections(ndi.sender, 0) > 0) { + std::memcpy(v210_frame.p_data, video_buf, video_stride * height); + NDIlib_util_V210_to_P216(&v210_frame, &p216_frame); + NDIlib_send_send_video_v2(ndi.sender, &p216_frame); if (++ndi_frame_count == 1) - log("NDI receiver connected"); + log("first NDI receiver connected"); } else { ndi_frame_count = 0; } -- 2.52.0 From 2a5d3758b6816da20831815e5daf4735e1e9b1b3 Mon Sep 17 00:00:00 2001 From: JohannesItten Date: Fri, 3 Jul 2026 09:59:36 +0300 Subject: [PATCH 3/6] refactor: align testpattern naming with ndiin/ndiout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cfg_info → video_cfg, stride → video_stride, writer → video_writer, grain/buf → video_grain/video_buf, index → video_index, st → vst, audio_info/audio_id → audio_flow_info/audio_flow_id. Co-Authored-By: Claude Sonnet 4.6 --- nodes/testpattern/main.cpp | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/nodes/testpattern/main.cpp b/nodes/testpattern/main.cpp index a8f43e7..83f44b4 100644 --- a/nodes/testpattern/main.cpp +++ b/nodes/testpattern/main.cpp @@ -21,37 +21,37 @@ class TestPatternNode : public dmf::NodeBase { log("flow=%s %dx%d @ %d/%d fps pattern=%s", flow_id.c_str(), width, height, fps_num, fps_den, pattern.c_str()); - mxlFlowWriter writer{}; - mxlFlowConfigInfo cfg_info{}; + mxlFlowWriter video_writer{}; + mxlFlowConfigInfo video_cfg{}; bool created = false; - mxlStatus st = mxlCreateFlowWriter( + mxlStatus vst = mxlCreateFlowWriter( instance(), dmf::make_video_flow_def(flow_id, node_id(), width, height, fps_num, fps_den).c_str(), - nullptr, &writer, &cfg_info, &created); - if (st != MXL_STATUS_OK) { log("video mxlCreateFlowWriter failed (status=%d)", st); return; } + nullptr, &video_writer, &video_cfg, &created); + if (vst != MXL_STATUS_OK) { log("video mxlCreateFlowWriter failed (status=%d)", vst); return; } - const uint32_t stride = cfg_info.discrete.sliceSizes[0]; + const uint32_t video_stride = video_cfg.discrete.sliceSizes[0]; log("video stride=%u B/line grain=%u B ring=%u grains", - stride, stride * static_cast(height), cfg_info.discrete.grainCount); + video_stride, video_stride * static_cast(height), video_cfg.discrete.grainCount); // --- audio flow (optional) --- mxlFlowWriter audio_writer{}; mxlFlowConfigInfo audio_cfg{}; - int sample_rate = 48000; - int channels = 2; - bool has_audio = config().contains("audio_flow_id"); + int sample_rate = 48000; + int channels = 2; + bool has_audio = config().contains("audio_flow_id"); if (has_audio) { - const auto audio_info = config().at("audio_flow_id"); - const auto audio_id = audio_info.at("id").get(); - sample_rate = audio_info.value("sample_rate", 48000); - channels = audio_info.value("channels", 2); + const auto audio_flow_info = config().at("audio_flow_id"); + const auto audio_flow_id = audio_flow_info.at("id").get(); + sample_rate = audio_flow_info.value("sample_rate", 48000); + channels = audio_flow_info.value("channels", 2); - log("audio flow=%s %d Hz %dch", audio_id.c_str(), sample_rate, channels); + log("audio flow=%s %d Hz %dch", audio_flow_id.c_str(), sample_rate, channels); mxlStatus ast = mxlCreateFlowWriter( instance(), - dmf::make_audio_flow_def(audio_id, node_id(), sample_rate, channels, 32, + dmf::make_audio_flow_def(audio_flow_id, node_id(), sample_rate, channels, 32, fps_num, fps_den).c_str(), nullptr, &audio_writer, &audio_cfg, &created); if (ast != MXL_STATUS_OK) { @@ -72,29 +72,29 @@ class TestPatternNode : public dmf::NodeBase { // -18 dBFS broadcast reference level const float amplitude = static_cast(std::pow(10.0, -18.0 / 20.0)); - uint64_t index = mxlGetCurrentIndex(&video_rate); + uint64_t video_index = mxlGetCurrentIndex(&video_rate); uint64_t audio_index = has_audio ? mxlGetCurrentIndex(&audio_rate) : 0; - log("start video_index=%llu", index); + log("start video_index=%llu", video_index); while (dmf::g_running.load(std::memory_order_relaxed)) { // --- video grain --- - mxlGrainInfo grain{}; - uint8_t* buf = nullptr; - st = mxlFlowWriterOpenGrain(writer, index, &grain, &buf); - if (st != MXL_STATUS_OK) { - log("OpenGrain failed (status=%d), skipping index=%llu", st, index); - index++; + mxlGrainInfo video_grain{}; + uint8_t* video_buf = nullptr; + vst = mxlFlowWriterOpenGrain(video_writer, video_index, &video_grain, &video_buf); + if (vst != MXL_STATUS_OK) { + log("OpenGrain failed (status=%d), skipping index=%llu", vst, video_index); + video_index++; continue; } - if (pattern == "bars") dmf::v210::fill_colorbars(buf, width, height, stride); - else if (pattern == "ire") dmf::v210::fill_ire_ramp (buf, width, height, stride); - else if (pattern == "black") dmf::v210::fill_black (buf, width, height, stride); - else if (pattern == "white") dmf::v210::fill_white (buf, width, height, stride); - else dmf::v210::fill_colorbars (buf, width, height, stride); - grain.flags = 0; - grain.validSlices = grain.totalSlices; - mxlFlowWriterCommitGrain(writer, &grain); + if (pattern == "bars") dmf::v210::fill_colorbars(video_buf, width, height, video_stride); + else if (pattern == "ire") dmf::v210::fill_ire_ramp (video_buf, width, height, video_stride); + else if (pattern == "black") dmf::v210::fill_black (video_buf, width, height, video_stride); + else if (pattern == "white") dmf::v210::fill_white (video_buf, width, height, video_stride); + else dmf::v210::fill_colorbars (video_buf, width, height, video_stride); + video_grain.flags = 0; + video_grain.validSlices = video_grain.totalSlices; + mxlFlowWriterCommitGrain(video_writer, &video_grain); // --- audio: sine tones, channel c = (c+1) * 1000 Hz --- if (has_audio) { @@ -125,13 +125,13 @@ class TestPatternNode : public dmf::NodeBase { audio_index += samples_per_frame; } - const uint64_t ns = mxlGetNsUntilIndex(index + 1, &video_rate); + const uint64_t ns = mxlGetNsUntilIndex(video_index + 1, &video_rate); if (ns > 0 && ns < 2'000'000'000ULL) mxlSleepForNs(ns); - index++; + video_index++; } - log("stopped at video_index=%llu", index); - mxlReleaseFlowWriter(instance(), writer); + log("stopped at video_index=%llu", video_index); + mxlReleaseFlowWriter(instance(), video_writer); if (has_audio) mxlReleaseFlowWriter(instance(), audio_writer); } }; -- 2.52.0 From 2b11411423ad282662b4b362ee0227c7766a5ce1 Mon Sep 17 00:00:00 2001 From: JohannesItten Date: Fri, 3 Jul 2026 10:01:39 +0300 Subject: [PATCH 4/6] fix: set p216_frame FourCC; scope audio_rate to has_audio branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ndiout: p216_frame.FourCC was zero-initialized — NDI needs it explicitly set to NDIlib_FourCC_video_type_P216 to send the correct format. All three nodes: audio_rate = {sample_rate, 1} was always declared even when has_audio is false (sample_rate = 0 in ndiout). Scoped into the has_audio block so the bad rate can never be passed to mxlGetCurrentIndex. Co-Authored-By: Claude Sonnet 4.6 --- nodes/ndiin/main.cpp | 7 +++++-- nodes/ndiout/main.cpp | 8 ++++++-- nodes/testpattern/main.cpp | 7 +++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/nodes/ndiin/main.cpp b/nodes/ndiin/main.cpp index efc2f74..4241d68 100644 --- a/nodes/ndiin/main.cpp +++ b/nodes/ndiin/main.cpp @@ -81,10 +81,13 @@ class NDIInNode : public dmf::NodeBase { // --- main loop --- const mxlRational video_rate = {fps_num, fps_den}; - const mxlRational audio_rate = {sample_rate, 1}; uint64_t video_index = mxlGetCurrentIndex(&video_rate); - uint64_t audio_index = has_audio ? mxlGetCurrentIndex(&audio_rate) : 0; + uint64_t audio_index = 0; + if (has_audio) { + const mxlRational audio_rate = {sample_rate, 1}; + audio_index = mxlGetCurrentIndex(&audio_rate); + } log("start video_index=%llu", video_index); std::vector latest_video(video_stride * height); diff --git a/nodes/ndiout/main.cpp b/nodes/ndiout/main.cpp index b1629be..b46b43e 100644 --- a/nodes/ndiout/main.cpp +++ b/nodes/ndiout/main.cpp @@ -106,6 +106,7 @@ class NDIOutNode : public dmf::NodeBase { NDIlib_video_frame_v2_t p216_frame{}; p216_frame.xres = width; p216_frame.yres = height; + p216_frame.FourCC = NDIlib_FourCC_video_type_P216; p216_frame.frame_rate_N = fps_num; p216_frame.frame_rate_D = fps_den; p216_frame.line_stride_in_bytes = width * static_cast(sizeof(uint16_t)); @@ -125,10 +126,13 @@ class NDIOutNode : public dmf::NodeBase { // --- main loop --- const mxlRational video_rate = {fps_num, fps_den}; - const mxlRational audio_rate = {sample_rate, 1}; uint64_t video_index = mxlGetCurrentIndex(&video_rate); - uint64_t audio_index = has_audio ? mxlGetCurrentIndex(&audio_rate) : 0; + uint64_t audio_index = 0; + if (has_audio) { + const mxlRational audio_rate = {sample_rate, 1}; + audio_index = mxlGetCurrentIndex(&audio_rate); + } uint64_t frame_count = 0; uint64_t invalid_count = 0; uint64_t late_count = 0; diff --git a/nodes/testpattern/main.cpp b/nodes/testpattern/main.cpp index 83f44b4..982d5f6 100644 --- a/nodes/testpattern/main.cpp +++ b/nodes/testpattern/main.cpp @@ -65,7 +65,6 @@ class TestPatternNode : public dmf::NodeBase { // --- main loop --- const mxlRational video_rate = {fps_num, fps_den}; - const mxlRational audio_rate = {sample_rate, 1}; const size_t samples_per_frame = static_cast(sample_rate) * static_cast(fps_den) / static_cast(fps_num); @@ -73,7 +72,11 @@ class TestPatternNode : public dmf::NodeBase { const float amplitude = static_cast(std::pow(10.0, -18.0 / 20.0)); uint64_t video_index = mxlGetCurrentIndex(&video_rate); - uint64_t audio_index = has_audio ? mxlGetCurrentIndex(&audio_rate) : 0; + uint64_t audio_index = 0; + if (has_audio) { + const mxlRational audio_rate = {sample_rate, 1}; + audio_index = mxlGetCurrentIndex(&audio_rate); + } log("start video_index=%llu", video_index); while (dmf::g_running.load(std::memory_order_relaxed)) { -- 2.52.0 From 9fd41b0312636409160cbd19bcb98805bd577624 Mon Sep 17 00:00:00 2001 From: JohannesItten Date: Fri, 3 Jul 2026 10:06:43 +0300 Subject: [PATCH 5/6] fix: samples_per_frame must multiply fps_den for fractional framerates sample_rate / fps_num gave 48000/30000 = 1 for 29.97 fps, producing silence. Correct formula is sample_rate * fps_den / fps_num, matching the calculation already used in testpattern. Co-Authored-By: Claude Sonnet 4.6 --- nodes/ndiout/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/ndiout/main.cpp b/nodes/ndiout/main.cpp index b46b43e..3c5e1ad 100644 --- a/nodes/ndiout/main.cpp +++ b/nodes/ndiout/main.cpp @@ -72,7 +72,7 @@ class NDIOutNode : public dmf::NodeBase { const auto audio_flow_id = audio_flow_info.at("id").get(); sample_rate = audio_flow_info.value("sample_rate", 48000); channels = audio_flow_info.value("channels", 2); - samples_per_frame = sample_rate / fps_num; + samples_per_frame = sample_rate * fps_den / fps_num; log("audio flow=%s %d Hz %dch %d samples/frame", audio_flow_id.c_str(), sample_rate, channels, samples_per_frame); -- 2.52.0 From 5504b8983ed18b8d032f07b850f0650ae5b85b09 Mon Sep 17 00:00:00 2001 From: JohannesItten Date: Fri, 3 Jul 2026 10:11:06 +0300 Subject: [PATCH 6/6] feat: ndiout supports audio-only mode (video optional) flow_id is now optional (config().contains). When absent: skip the MXL reader, active-wait, and NDI video path entirely. Video buffers and NDI video frames are heap-allocated only when has_video. Loop pacing: video branch sleeps 1ms on TOO_EARLY as before; audio-only path sleeps 1ms when no chunk was available (audio_advanced == false) to avoid busy-spinning. NDI sender name changed from the video flow UUID to node_id(), which is stable and human-readable for both video and audio-only modes. To use audio-only: wire only audio_flow_id in build_graph, omit flow_id. Co-Authored-By: Claude Sonnet 4.6 --- nodes/ndiout/main.cpp | 210 ++++++++++++++++++++++++------------------ 1 file changed, 120 insertions(+), 90 deletions(-) diff --git a/nodes/ndiout/main.cpp b/nodes/ndiout/main.cpp index 3c5e1ad..4f40596 100644 --- a/nodes/ndiout/main.cpp +++ b/nodes/ndiout/main.cpp @@ -33,31 +33,42 @@ struct NDIContext { class NDIOutNode : public dmf::NodeBase { void run() override { - // --- video flow --- - const auto flow_info = config().at("flow_id"); - const auto flow_id = flow_info.at("id").get(); - const int width = flow_info.value("width", 1920); - const int height = flow_info.value("height", 1080); - const int fps_num = flow_info.value("fps_num", 25); - const int fps_den = flow_info.value("fps_den", 1); - - log("flow=%s %dx%d @ %d/%d fps", flow_id.c_str(), width, height, fps_num, fps_den); - - log("waiting for flow to become active..."); - bool active = false; - while (!active && dmf::g_running.load(std::memory_order_relaxed)) { - mxlIsFlowActive(instance(), flow_id.c_str(), &active); - if (!active) mxlSleepForNs(100'000'000); - } - if (!dmf::g_running) return; - log("flow active — starting read"); + // --- video flow (optional) --- + bool has_video = config().contains("flow_id"); + int width = 1920; + int height = 1080; + int fps_num = 25; + int fps_den = 1; + std::string flow_id; mxlFlowReader video_reader{}; - mxlFlowConfigInfo video_cfg{}; - mxlStatus vst = mxlCreateFlowReader(instance(), flow_id.c_str(), nullptr, &video_reader); - if (vst != MXL_STATUS_OK) { log("mxlCreateFlowReader failed (status=%d)", vst); return; } - mxlFlowReaderGetConfigInfo(video_reader, &video_cfg); - const uint32_t video_stride = video_cfg.discrete.sliceSizes[0]; + uint32_t video_stride = 0; + + if (has_video) { + const auto flow_info = config().at("flow_id"); + flow_id = flow_info.at("id").get(); + width = flow_info.value("width", 1920); + height = flow_info.value("height", 1080); + fps_num = flow_info.value("fps_num", 25); + fps_den = flow_info.value("fps_den", 1); + + log("video flow=%s %dx%d @ %d/%d fps", flow_id.c_str(), width, height, fps_num, fps_den); + + log("waiting for flow to become active..."); + bool active = false; + while (!active && dmf::g_running.load(std::memory_order_relaxed)) { + mxlIsFlowActive(instance(), flow_id.c_str(), &active); + if (!active) mxlSleepForNs(100'000'000); + } + if (!dmf::g_running) return; + log("flow active — starting read"); + + mxlFlowConfigInfo video_cfg{}; + mxlStatus vst = mxlCreateFlowReader(instance(), flow_id.c_str(), nullptr, &video_reader); + if (vst != MXL_STATUS_OK) { log("video mxlCreateFlowReader failed (status=%d)", vst); return; } + mxlFlowReaderGetConfigInfo(video_reader, &video_cfg); + video_stride = video_cfg.discrete.sliceSizes[0]; + } // --- audio flow (optional) --- mxlFlowReader audio_reader{}; @@ -88,31 +99,35 @@ class NDIOutNode : public dmf::NodeBase { } } - NDIContext ndi(flow_id.c_str()); + if (!has_video && !has_audio) { log("no flows configured — exiting"); return; } - // V210 intermediate and P216 send buffers for NDI video - std::vector v210_buf(video_stride * height); - std::vector p216_buf(width * sizeof(uint16_t) * 2 * height); + NDIContext ndi(node_id().c_str()); - NDIlib_video_frame_v2_t v210_frame{}; - v210_frame.xres = width; - v210_frame.yres = height; - v210_frame.frame_rate_N = fps_num; - v210_frame.frame_rate_D = fps_den; - v210_frame.FourCC = static_cast(NDI_LIB_FOURCC('V','2','1','0')); - v210_frame.line_stride_in_bytes = video_stride; - v210_frame.p_data = v210_buf.data(); + // Video buffers and NDI frames (only when has_video) + std::vector v210_buf, p216_buf; + NDIlib_video_frame_v2_t v210_frame{}, p216_frame{}; + if (has_video) { + v210_buf.resize(video_stride * height); + p216_buf.resize(width * sizeof(uint16_t) * 2 * height); - NDIlib_video_frame_v2_t p216_frame{}; - p216_frame.xres = width; - p216_frame.yres = height; - p216_frame.FourCC = NDIlib_FourCC_video_type_P216; - p216_frame.frame_rate_N = fps_num; - p216_frame.frame_rate_D = fps_den; - p216_frame.line_stride_in_bytes = width * static_cast(sizeof(uint16_t)); - p216_frame.p_data = p216_buf.data(); + v210_frame.xres = width; + v210_frame.yres = height; + v210_frame.frame_rate_N = fps_num; + v210_frame.frame_rate_D = fps_den; + v210_frame.FourCC = static_cast(NDI_LIB_FOURCC('V','2','1','0')); + v210_frame.line_stride_in_bytes = video_stride; + v210_frame.p_data = v210_buf.data(); - // Float planar buffer for NDI audio (ch0 samples, ch1 samples, ...) + p216_frame.xres = width; + p216_frame.yres = height; + p216_frame.FourCC = NDIlib_FourCC_video_type_P216; + p216_frame.frame_rate_N = fps_num; + p216_frame.frame_rate_D = fps_den; + p216_frame.line_stride_in_bytes = width * static_cast(sizeof(uint16_t)); + p216_frame.p_data = p216_buf.data(); + } + + // Audio buffer and NDI frame (only when has_audio) std::vector audio_planar(static_cast(channels) * samples_per_frame); NDIlib_audio_frame_v3_t ndi_audio{}; if (has_audio) { @@ -125,14 +140,8 @@ class NDIOutNode : public dmf::NodeBase { } // --- main loop --- - const mxlRational video_rate = {fps_num, fps_den}; - - uint64_t video_index = mxlGetCurrentIndex(&video_rate); + uint64_t video_index = 0; uint64_t audio_index = 0; - if (has_audio) { - const mxlRational audio_rate = {sample_rate, 1}; - audio_index = mxlGetCurrentIndex(&audio_rate); - } uint64_t frame_count = 0; uint64_t invalid_count = 0; uint64_t late_count = 0; @@ -140,8 +149,18 @@ class NDIOutNode : public dmf::NodeBase { auto wall_start = std::chrono::steady_clock::now(); auto last_log_time = wall_start; + if (has_video) { + const mxlRational video_rate = {fps_num, fps_den}; + video_index = mxlGetCurrentIndex(&video_rate); + } + if (has_audio) { + const mxlRational audio_rate = {sample_rate, 1}; + audio_index = mxlGetCurrentIndex(&audio_rate); + } + while (dmf::g_running.load(std::memory_order_relaxed)) { - // --- audio: non-blocking, one chunk per video frame --- + // --- audio: non-blocking, one chunk per video frame (or free-running) --- + bool audio_advanced = false; if (has_audio) { mxlWrappedMultiBufferSlice audio_slices{}; mxlStatus ast = mxlFlowReaderGetSamplesNonBlocking( @@ -164,6 +183,7 @@ class NDIOutNode : public dmf::NodeBase { } NDIlib_send_send_audio_v3(ndi.sender, &ndi_audio); audio_index += samples_per_frame; + audio_advanced = true; } else if (ast == MXL_ERR_OUT_OF_RANGE_TOO_LATE) { mxlFlowRuntimeInfo ari{}; mxlFlowReaderGetRuntimeInfo(audio_reader, &ari); @@ -172,53 +192,63 @@ class NDIOutNode : public dmf::NodeBase { } // --- video --- - mxlGrainInfo video_grain{}; - uint8_t* video_buf = nullptr; - vst = mxlFlowReaderGetGrainNonBlocking(video_reader, video_index, &video_grain, &video_buf); + if (has_video) { + mxlGrainInfo video_grain{}; + uint8_t* video_buf = nullptr; + mxlStatus vst = mxlFlowReaderGetGrainNonBlocking( + video_reader, video_index, &video_grain, &video_buf); - if (vst == MXL_STATUS_OK) { - frame_count++; - if (video_grain.flags & MXL_GRAIN_FLAG_INVALID) invalid_count++; + if (vst == MXL_STATUS_OK) { + frame_count++; + if (video_grain.flags & MXL_GRAIN_FLAG_INVALID) invalid_count++; + + if (NDIlib_send_get_no_connections(ndi.sender, 0) > 0) { + std::memcpy(v210_frame.p_data, video_buf, video_stride * height); + NDIlib_util_V210_to_P216(&v210_frame, &p216_frame); + NDIlib_send_send_video_v2(ndi.sender, &p216_frame); + if (++ndi_frame_count == 1) + log("first NDI receiver connected"); + } else { + ndi_frame_count = 0; + } + + video_index++; + + } else if (vst == MXL_ERR_OUT_OF_RANGE_TOO_EARLY) { + mxlSleepForNs(1'000'000); + + } else if (vst == MXL_ERR_OUT_OF_RANGE_TOO_LATE) { + late_count++; + mxlFlowRuntimeInfo ri{}; + mxlFlowReaderGetRuntimeInfo(video_reader, &ri); + video_index = ri.headIndex; - if (NDIlib_send_get_no_connections(ndi.sender, 0) > 0) { - std::memcpy(v210_frame.p_data, video_buf, video_stride * height); - NDIlib_util_V210_to_P216(&v210_frame, &p216_frame); - NDIlib_send_send_video_v2(ndi.sender, &p216_frame); - if (++ndi_frame_count == 1) - log("first NDI receiver connected"); } else { - ndi_frame_count = 0; + log("unexpected video status=%d on index=%llu", vst, video_index); + break; } - video_index++; - - } else if (vst == MXL_ERR_OUT_OF_RANGE_TOO_EARLY) { + auto now = std::chrono::steady_clock::now(); + if (std::chrono::duration(now - last_log_time).count() >= 1.0) { + const double elapsed = std::chrono::duration(now - wall_start).count(); + log("frames=%llu invalid=%llu late=%llu avg=%.2f fps", + frame_count, invalid_count, late_count, + static_cast(frame_count) / elapsed); + last_log_time = now; + } + } else if (!audio_advanced) { + // audio-only and nothing was ready — avoid busy spin mxlSleepForNs(1'000'000); - - } else if (vst == MXL_ERR_OUT_OF_RANGE_TOO_LATE) { - late_count++; - mxlFlowRuntimeInfo ri{}; - mxlFlowReaderGetRuntimeInfo(video_reader, &ri); - video_index = ri.headIndex; - - } else { - log("unexpected status=%d on index=%llu", vst, video_index); - break; - } - - auto now = std::chrono::steady_clock::now(); - if (std::chrono::duration(now - last_log_time).count() >= 1.0) { - const double elapsed = std::chrono::duration(now - wall_start).count(); - log("frames=%llu invalid=%llu late=%llu avg=%.2f fps", - frame_count, invalid_count, late_count, - static_cast(frame_count) / elapsed); - last_log_time = now; } } - log("stopped — total frames=%llu invalid=%llu late=%llu", - frame_count, invalid_count, late_count); - mxlReleaseFlowReader(instance(), video_reader); + if (has_video) + log("stopped — total frames=%llu invalid=%llu late=%llu", + frame_count, invalid_count, late_count); + else + log("stopped"); + + if (has_video) mxlReleaseFlowReader(instance(), video_reader); if (has_audio) mxlReleaseFlowReader(instance(), audio_reader); } }; -- 2.52.0