From 99ecb2803e4fb2d3217a3d6bf64449453488123e Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 7 May 2020 18:17:11 +0200 Subject: [PATCH] Add logging for the input speaker configuration --- src/common/events.h | 10 +++++---- src/common/logging.cpp | 41 ++++++++++++++++++++++++++++++------ src/common/logging.h | 13 +++++++----- src/plugin/plugin-bridge.cpp | 11 ++++++---- 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/common/events.h b/src/common/events.h index f28f4967..2c256240 100644 --- a/src/common/events.h +++ b/src/common/events.h @@ -155,7 +155,8 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket, if (logging.has_value()) { auto [logger, is_dispatch] = logging.value(); - logger.log_event(is_dispatch, opcode, index, value, payload, option); + logger.log_event(is_dispatch, opcode, index, value, payload, option, + value_payload); } const Event event{opcode, index, value, option, payload, value_payload}; @@ -174,7 +175,7 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket, if (logging.has_value()) { auto [logger, is_dispatch] = logging.value(); logger.log_event_response(is_dispatch, opcode, response.return_value, - response.payload); + response.payload, response.value_payload); } data_converter.write(opcode, data, response); @@ -211,14 +212,15 @@ void receive_event(boost::asio::local::stream_protocol::socket& socket, if (logging.has_value()) { auto [logger, is_dispatch] = logging.value(); logger.log_event(is_dispatch, event.opcode, event.index, event.value, - event.payload, event.option); + event.payload, event.option, event.value_payload); } EventResult response = callback(event); if (logging.has_value()) { auto [logger, is_dispatch] = logging.value(); logger.log_event_response(is_dispatch, event.opcode, - response.return_value, response.payload); + response.return_value, response.payload, + response.value_payload); } write_object(socket, response); diff --git a/src/common/logging.cpp b/src/common/logging.cpp index 671e61aa..5e88f48d 100644 --- a/src/common/logging.cpp +++ b/src/common/logging.cpp @@ -138,7 +138,8 @@ void Logger::log_event(bool is_dispatch, int index, intptr_t value, const EventPayload& payload, - float option) { + float option, + const std::optional& value_payload) { if (BOOST_UNLIKELY(verbosity >= Verbosity::most_events)) { if (should_filter_event(is_dispatch, opcode)) { return; @@ -161,7 +162,19 @@ void Logger::log_event(bool is_dispatch, message << "(index = " << index << ", value = " << value << ", option = " << option << ", data = "; - // TODO: Print value payload + // Only used during `effSetSpeakerArrangement` and + // `effGetSpeakerArrangement` + if (value_payload.has_value()) { + std::visit( + overload{ + [&](auto) {}, + [&](const DynamicSpeakerArrangement& speaker_arrangement) { + message << "<" << speaker_arrangement.speakers.size() + << " input_speakers>, "; + }}, + value_payload.value()); + } + std::visit( overload{ [&](const std::nullptr_t&) { message << ""; }, @@ -207,10 +220,12 @@ void Logger::log_event(bool is_dispatch, } } -void Logger::log_event_response(bool is_dispatch, - int opcode, - intptr_t return_value, - const EventResultPayload& payload) { +void Logger::log_event_response( + bool is_dispatch, + int opcode, + intptr_t return_value, + const EventResultPayload& payload, + const std::optional& value_payload) { if (BOOST_UNLIKELY(verbosity >= Verbosity::most_events)) { if (should_filter_event(is_dispatch, opcode)) { return; @@ -225,7 +240,19 @@ void Logger::log_event_response(bool is_dispatch, message << return_value; - // TODO: Print value payload + // Only used during `effSetSpeakerArrangement` and + // `effGetSpeakerArrangement` + if (value_payload.has_value()) { + std::visit( + overload{ + [&](auto) {}, + [&](const DynamicSpeakerArrangement& speaker_arrangement) { + message << ", <" << speaker_arrangement.speakers.size() + << " input_speakers>"; + }}, + value_payload.value()); + } + std::visit( overload{ [&](const std::nullptr_t&) {}, diff --git a/src/common/logging.h b/src/common/logging.h index d0403d61..a4e33799 100644 --- a/src/common/logging.h +++ b/src/common/logging.h @@ -104,11 +104,14 @@ class Logger { int index, intptr_t value, const EventPayload& payload, - float option); - void log_event_response(bool is_dispatch, - int opcode, - intptr_t return_value, - const EventResultPayload& payload); + float option, + const std::optional& value_payload); + void log_event_response( + bool is_dispatch, + int opcode, + intptr_t return_value, + const EventResultPayload& payload, + const std::optional& value_payload); private: /** diff --git a/src/plugin/plugin-bridge.cpp b/src/plugin/plugin-bridge.cpp index f66fefb5..30c517d7 100644 --- a/src/plugin/plugin-bridge.cpp +++ b/src/plugin/plugin-bridge.cpp @@ -523,12 +523,13 @@ intptr_t PluginBridge::dispatch(AEffect* /*plugin*/, // once Ardour 6.0 gets released. // https://tracker.ardour.org/view.php?id=7668 if (BOOST_UNLIKELY(plugin.magic == 0)) { - logger.log_event(true, opcode, index, value, nullptr, option); + logger.log_event(true, opcode, index, value, nullptr, option, + std::nullopt); logger.log( " WARNING: The host has dispatched an event before the plugin " "has finished initializing, ignoring the event. (are we running " "Ardour 5.X?)"); - logger.log_event_response(true, opcode, 0, nullptr); + logger.log_event_response(true, opcode, 0, nullptr, std::nullopt); return 0; } @@ -598,11 +599,13 @@ intptr_t PluginBridge::dispatch(AEffect* /*plugin*/, // window ID to `effEditOpen`. This is of course not going to // work when the GUI is handled using Wine so we'll ignore it. if (query == "hasCockosViewAsConfig") { - logger.log_event(true, opcode, index, value, query, option); + logger.log_event(true, opcode, index, value, query, option, + std::nullopt); logger.log( " The host requests libSwell GUI support which is not " "supported using Wine, ignoring the request."); - logger.log_event_response(true, opcode, -1, nullptr); + logger.log_event_response(true, opcode, -1, nullptr, + std::nullopt); return -1; } } break;