# HG changeset patch # User František Kučera # Date 1589832020 -7200 # Node ID e5f0d3f92eb49ae0e126fdec613577ea202de4e8 # Parent 001b956610ca88dd85d38a39a556b10f7565b30f pass RelationalWriter instead of std::ostream to the JackCommand diff -r 001b956610ca -r e5f0d3f92eb4 src/JackCommand.h --- a/src/JackCommand.h Mon May 18 18:04:12 2020 +0200 +++ b/src/JackCommand.h Mon May 18 22:00:20 2020 +0200 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -61,7 +62,7 @@ uint32_t size; uint32_t time; }; - + public: int enqueueMessage(jack_nframes_t frames) { @@ -137,9 +138,8 @@ continueProcessing = false; } - void processJackStream(ostream &output) { + void processJackStream(std::shared_ptr writer, std::function relationalWriterFlush) { // Relation headers: - std::shared_ptr writer(Factory::create(output)); vector metadata; metadata.push_back({L"event", TypeId::STRING}); metadata.push_back({L"channel", TypeId::INTEGER}); @@ -149,7 +149,7 @@ metadata.push_back({L"controller_id", TypeId::INTEGER}); metadata.push_back({L"controller_value", TypeId::INTEGER}); writer->startRelation(L"midi", metadata, true); - output.flush(); + relationalWriterFlush(); // Initialize JACK connection: std::string clientName = "relpipe-in-jack"; @@ -177,7 +177,7 @@ MidiMessage m; jack_ringbuffer_read(ringBuffer, (char*) &m, sizeof (MidiMessage)); processMessage(writer, &m); - output.flush(); + relationalWriterFlush(); } pthread_cond_wait(&dataReady, &messageThreadLock); } diff -r 001b956610ca -r e5f0d3f92eb4 src/relpipe-in-jack.cpp --- a/src/relpipe-in-jack.cpp Mon May 18 18:04:12 2020 +0200 +++ b/src/relpipe-in-jack.cpp Mon May 18 22:00:20 2020 +0200 @@ -45,7 +45,8 @@ signal(SIGHUP, finish); signal(SIGINT, finish); jackCommand.reset(new JackCommand()); - jackCommand->processJackStream(cout); + std::shared_ptr writer(Factory::create(std::cout)); + jackCommand->processJackStream(writer, std::bind(fflush, stdout)); // std::bind(fflush, XXX) Factory::create(XXX) must be the same stream XXX resultCode = CLI::EXIT_CODE_SUCCESS; } catch (JackException e) { fwprintf(stderr, L"Caught JACK exception: %ls\n", e.getMessge().c_str());