200{
201 try {
202 decltype(lr_ipc_shared->
line_)::value_type line_copy;
203 while ((line_copy = lr_ipc_shared->
line_.
pop()) != kTerminate) {
204#pragma warning(suppress : 26445)
205 auto [command_view, value_view] {SplitLine(line_copy)};
206
207
208 if (command_view == "TerminateApplication") [[unlikely]] {
209 if (auto* app = juce::JUCEApplication::getInstance()) { app->systemRequestedQuit(); }
210 return;
211 }
212
213 if (value_view.empty()) [[unlikely]] {
214 rsj::Log(fmt::format(
"No value attached to message. Message from plugin was \"{}\".",
216 std::source_location::current());
217 continue;
218 }
219
220 if (command_view == "SwitchProfile") {
222 continue;
223 }
224
225 if (command_view == "Log") {
226 rsj::Log(fmt::format(
"Plugin: {}.", value_view), std::source_location::current());
227 continue;
228 }
229
230 if (command_view == "SendKey") {
231 int modifiers {0};
232 auto [ptr, ec] {std::from_chars(value_view.data(),
233 value_view.data() + value_view.size(), modifiers)};
234
235 std::string_view key_view {value_view};
236 key_view.remove_prefix(static_cast<size_t>(ptr - value_view.data()));
237 if (!key_view.empty() && (key_view.front() == ' ' || key_view.front() == '\t')) {
238 key_view.remove_prefix(1);
239 }
240 if (!key_view.empty() && ec == std::errc()) {
243 continue;
244 }
246 "plugin was \"{}\".",
248 std::source_location::current());
249 continue;
250 }
251
252
253 double original_value {0.0};
254#if defined(_MSC_VER) || (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_26_0)
255 auto [ptr, ec] {std::from_chars(value_view.data(), value_view.data() + value_view.size(),
256 original_value)};
257 if (ec != std::errc()) {
259 std::source_location::current());
260 continue;
261 }
262#else
263 try {
264 original_value = std::stod(std::string(value_view));
265 }
266 catch (const std::exception& ex) {
268 ex.what()),
269 std::source_location::current());
270 continue;
271 }
272#endif
273 const auto messages {
profile_.GetMessagesForCommand(std::string(command_view))};
274 for (const auto& msg : messages) {
275 const auto value {
controls_model_.PluginToController(msg, original_value)};
279 }
280 }
281 }
282 }
283 catch (const std::exception& e) {
285 throw;
286 }
287}
rsj::ConcurrentQueue< std::string > line_
Definition LR_IPC_In.cpp:57
T pop()
Definition Concurrency.h:190
std::string ReplaceInvisibleChars(std::string_view in)
@ kAbsolute
Definition ControlsModel.h:33
@ kCc
Definition MidiUtilities.h:45
void SendKeyDownUp(const std::string &key, rsj::ActiveModifiers mods) noexcept
Definition SendKeysMac.cpp:378
void LogAndAlertError(const juce::String &error_text, const std::source_location &location=std::source_location::current()) noexcept
Definition Misc.cpp:141
static ActiveModifiers FromMidi2LR(int from) noexcept
Definition SendKeys.cpp:30