diff --git a/fpga/src/villas-fpga-ctrl.cpp b/fpga/src/villas-fpga-ctrl.cpp index 6e8ec20c4..206d829e2 100644 --- a/fpga/src/villas-fpga-ctrl.cpp +++ b/fpga/src/villas-fpga-ctrl.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -151,12 +152,20 @@ int main(int argc, char* argv[]) const fpga::ConnectString parsedConnectString(connectStr); parsedConnectString.configCrossBar(dma, aurora_channels); + std::unique_ptr stdInThread = nullptr; if (!noDma && parsedConnectString.isDstStdout()) { auto formatter = fpga::getBufferedSampleFormatter(outputFormat, 16); - readFromDmaToStdOut(std::move(dma), std::move(formatter)); - } else if (!noDma && parsedConnectString.isSrcStdin()) { + // We copy the dma shared ptr but move the fomatter unqiue ptr as we don't need it + // in this thread anymore + stdInThread = std::make_unique(readFromDmaToStdOut, dma, std::move(formatter)); + } + if (!noDma && parsedConnectString.isSrcStdin()) { } + + if (stdInThread) { + stdInThread->join(); + } } catch (const RuntimeError &e) { logger->error("Error: {}", e.what()); return -1;