Add logging for the input speaker configuration

This commit is contained in:
Robbert van der Helm
2020-05-07 18:17:11 +02:00
parent f0761343f7
commit 99ecb2803e
4 changed files with 55 additions and 20 deletions
+6 -4
View File
@@ -155,7 +155,8 @@ intptr_t send_event(boost::asio::local::stream_protocol::socket& socket,
if (logging.has_value()) { if (logging.has_value()) {
auto [logger, is_dispatch] = logging.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}; 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()) { if (logging.has_value()) {
auto [logger, is_dispatch] = logging.value(); auto [logger, is_dispatch] = logging.value();
logger.log_event_response(is_dispatch, opcode, response.return_value, logger.log_event_response(is_dispatch, opcode, response.return_value,
response.payload); response.payload, response.value_payload);
} }
data_converter.write(opcode, data, response); data_converter.write(opcode, data, response);
@@ -211,14 +212,15 @@ void receive_event(boost::asio::local::stream_protocol::socket& socket,
if (logging.has_value()) { if (logging.has_value()) {
auto [logger, is_dispatch] = logging.value(); auto [logger, is_dispatch] = logging.value();
logger.log_event(is_dispatch, event.opcode, event.index, event.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); EventResult response = callback(event);
if (logging.has_value()) { if (logging.has_value()) {
auto [logger, is_dispatch] = logging.value(); auto [logger, is_dispatch] = logging.value();
logger.log_event_response(is_dispatch, event.opcode, 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); write_object(socket, response);
+34 -7
View File
@@ -138,7 +138,8 @@ void Logger::log_event(bool is_dispatch,
int index, int index,
intptr_t value, intptr_t value,
const EventPayload& payload, const EventPayload& payload,
float option) { float option,
const std::optional<EventPayload>& value_payload) {
if (BOOST_UNLIKELY(verbosity >= Verbosity::most_events)) { if (BOOST_UNLIKELY(verbosity >= Verbosity::most_events)) {
if (should_filter_event(is_dispatch, opcode)) { if (should_filter_event(is_dispatch, opcode)) {
return; return;
@@ -161,7 +162,19 @@ void Logger::log_event(bool is_dispatch,
message << "(index = " << index << ", value = " << value message << "(index = " << index << ", value = " << value
<< ", option = " << option << ", data = "; << ", 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( std::visit(
overload{ overload{
[&](const std::nullptr_t&) { message << "<nullptr>"; }, [&](const std::nullptr_t&) { message << "<nullptr>"; },
@@ -207,10 +220,12 @@ void Logger::log_event(bool is_dispatch,
} }
} }
void Logger::log_event_response(bool is_dispatch, void Logger::log_event_response(
int opcode, bool is_dispatch,
intptr_t return_value, int opcode,
const EventResultPayload& payload) { intptr_t return_value,
const EventResultPayload& payload,
const std::optional<EventResultPayload>& value_payload) {
if (BOOST_UNLIKELY(verbosity >= Verbosity::most_events)) { if (BOOST_UNLIKELY(verbosity >= Verbosity::most_events)) {
if (should_filter_event(is_dispatch, opcode)) { if (should_filter_event(is_dispatch, opcode)) {
return; return;
@@ -225,7 +240,19 @@ void Logger::log_event_response(bool is_dispatch,
message << return_value; 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( std::visit(
overload{ overload{
[&](const std::nullptr_t&) {}, [&](const std::nullptr_t&) {},
+8 -5
View File
@@ -104,11 +104,14 @@ class Logger {
int index, int index,
intptr_t value, intptr_t value,
const EventPayload& payload, const EventPayload& payload,
float option); float option,
void log_event_response(bool is_dispatch, const std::optional<EventPayload>& value_payload);
int opcode, void log_event_response(
intptr_t return_value, bool is_dispatch,
const EventResultPayload& payload); int opcode,
intptr_t return_value,
const EventResultPayload& payload,
const std::optional<EventResultPayload>& value_payload);
private: private:
/** /**
+7 -4
View File
@@ -523,12 +523,13 @@ intptr_t PluginBridge::dispatch(AEffect* /*plugin*/,
// once Ardour 6.0 gets released. // once Ardour 6.0 gets released.
// https://tracker.ardour.org/view.php?id=7668 // https://tracker.ardour.org/view.php?id=7668
if (BOOST_UNLIKELY(plugin.magic == 0)) { 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( logger.log(
" WARNING: The host has dispatched an event before the plugin " " WARNING: The host has dispatched an event before the plugin "
"has finished initializing, ignoring the event. (are we running " "has finished initializing, ignoring the event. (are we running "
"Ardour 5.X?)"); "Ardour 5.X?)");
logger.log_event_response(true, opcode, 0, nullptr); logger.log_event_response(true, opcode, 0, nullptr, std::nullopt);
return 0; return 0;
} }
@@ -598,11 +599,13 @@ intptr_t PluginBridge::dispatch(AEffect* /*plugin*/,
// window ID to `effEditOpen`. This is of course not going to // window ID to `effEditOpen`. This is of course not going to
// work when the GUI is handled using Wine so we'll ignore it. // work when the GUI is handled using Wine so we'll ignore it.
if (query == "hasCockosViewAsConfig") { 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( logger.log(
" The host requests libSwell GUI support which is not " " The host requests libSwell GUI support which is not "
"supported using Wine, ignoring the request."); "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; return -1;
} }
} break; } break;