MIDI2LR 6.2.0.1
MIDI2LR is an application that interfaces MIDI controllers with Lightroom 6+/CC Classic. It processes MIDI input into develop parameter updates and photo actions, and sends MIDI output when parameters are changed for motorized feedback (on controllers that have motorized faders). A listing of available LightRoom commands is in the Wiki. Assistance on the code and design is welcome.
Loading...
Searching...
No Matches
LrIpcInShared Class Reference

Public Member Functions

 LrIpcInShared (asio::io_context &io_context)
 
 LrIpcInShared (asio::io_context &io_context)
 

Static Private Member Functions

static void Read (std::shared_ptr< LrIpcInShared > lr_ipc_shared)
 
static void Read (std::shared_ptr< LrIpcInShared > lr_ipc_shared)
 

Private Attributes

rsj::ConcurrentQueue< std::string > line_
 
friend LrIpcIn
 
asio::ip::tcp::socket socket_
 
asio::streambuf streambuf_ {}
 
std::atomic< bool > thread_should_exit_ {false}
 

Constructor & Destructor Documentation

◆ LrIpcInShared() [1/2]

LrIpcInShared::LrIpcInShared ( asio::io_context &  io_context)
inlineexplicit
61: socket_ {asio::make_strand(io_context)} {}
asio::ip::tcp::socket socket_
Definition LR_IPC_In.cpp:54

◆ LrIpcInShared() [2/2]

LrIpcInShared::LrIpcInShared ( asio::io_context &  io_context)
inlineexplicit
61: socket_ {asio::make_strand(io_context)} {}

Member Function Documentation

◆ Read() [1/2]

void LrIpcInShared::Read ( std::shared_ptr< LrIpcInShared lr_ipc_shared)
staticprivate
277{
278 using namespace std::string_literals;
279 try {
280 if (!lr_ipc_shared->thread_should_exit_.load(std::memory_order_acquire)) {
281 asio::async_read_until(lr_ipc_shared->socket_, lr_ipc_shared->streambuf_, '\n',
282 [lr_ipc_shared](const asio::error_code& error,
283 const std::size_t bytes_transferred) mutable {
284 if (!error) [[likely]] {
285 if (bytes_transferred == 0) [[unlikely]] { std::this_thread::sleep_for(kEmptyWait); }
286 else {
287 auto& buf {lr_ipc_shared->streambuf_};
288 std::string command {buffers_begin(buf.data()),
289 buffers_begin(buf.data()) + gsl::narrow<std::ptrdiff_t>(bytes_transferred)};
290 if (command == "TerminateApplication 1\n"s) {
291 lr_ipc_shared->thread_should_exit_.store(true, std::memory_order_release);
292 }
293 lr_ipc_shared->line_.push(std::move(command));
294 buf.consume(bytes_transferred);
295 }
296 Read(std::move(lr_ipc_shared));
297 }
298 else {
299 rsj::Log(fmt::format(FMT_STRING("LR_IPC_In Read error: {}."), error.message()),
300 std::source_location::current());
301
302 if (error == asio::error::misc_errors::eof) { /* LR closed socket */
303 juce::JUCEApplication::getInstance()->systemRequestedQuit();
304 }
305 }
306 });
307 }
308 }
309 catch (const std::exception& e) {
310 rsj::ExceptionResponse(e, std::source_location::current());
311 throw;
312 }
313}
void ExceptionResponse(gsl::czstring id, gsl::czstring fu, const std::exception &e) noexcept

◆ Read() [2/2]

static void LrIpcInShared::Read ( std::shared_ptr< LrIpcInShared lr_ipc_shared)
staticprivate

Member Data Documentation

◆ line_

rsj::ConcurrentQueue< std::string > LrIpcInShared::line_
private

◆ LrIpcIn

LrIpcIn
private

◆ socket_

asio::ip::tcp::socket LrIpcInShared::socket_
private

◆ streambuf_

asio::streambuf LrIpcInShared::streambuf_ {}
private
55{};

◆ thread_should_exit_

std::atomic< bool > LrIpcInShared::thread_should_exit_ {false}
private
57{false};

The documentation for this class was generated from the following file: