MIDI2LR 6.1.0.0
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
62: socket_ {asio::make_strand(io_context)} {}
asio::ip::tcp::socket socket_
Definition LR_IPC_In.cpp:55

◆ LrIpcInShared() [2/2]

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

Member Function Documentation

◆ Read() [1/2]

void LrIpcInShared::Read ( std::shared_ptr< LrIpcInShared lr_ipc_shared)
staticprivate
230{
231 try {
232 if (!lr_ipc_shared->thread_should_exit_.load(std::memory_order_acquire)) {
233 asio::async_read_until(lr_ipc_shared->socket_, lr_ipc_shared->streambuf_, '\n',
234 [lr_ipc_shared](const asio::error_code& error,
235 const std::size_t bytes_transferred) mutable {
236 if (!error) [[likely]] {
237 if (bytes_transferred == 0) [[unlikely]] { std::this_thread::sleep_for(kEmptyWait); }
238 else {
239 auto& buf {lr_ipc_shared->streambuf_};
240 std::string command {buffers_begin(buf.data()),
241 buffers_begin(buf.data()) + gsl::narrow<std::ptrdiff_t>(bytes_transferred)};
242 if (command == "TerminateApplication 1\n"s) {
243 lr_ipc_shared->thread_should_exit_.store(true, std::memory_order_release);
244 }
245 lr_ipc_shared->line_.push(std::move(command));
246 buf.consume(bytes_transferred);
247 }
248 Read(std::move(lr_ipc_shared));
249 }
250 else {
251 rsj::Log(fmt::format(FMT_STRING("LR_IPC_In Read error: {}."), error.message()));
252
253 if (error == asio::error::misc_errors::eof) { /* LR closed socket */
254 juce::JUCEApplication::getInstance()->systemRequestedQuit();
255 }
256 }
257 });
258 }
259 }
260 catch (const std::exception& e) {
262 throw;
263 }
264}
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
56{};

◆ thread_should_exit_

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

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