diff --git a/src/common/logging/clap.cpp b/src/common/logging/clap.cpp index ad3ff8d0..861b220d 100644 --- a/src/common/logging/clap.cpp +++ b/src/common/logging/clap.cpp @@ -377,6 +377,74 @@ bool ClapLogger::log_request(bool is_host_plugin, }); } +bool ClapLogger::log_request( + bool is_host_plugin, + const MessageReference& request_wrapper) { + return log_request_base( + is_host_plugin, Logger::Verbosity::all_events, [&](auto& message) { + // This is incredibly verbose, but if you're really a plugin that + // handles processing in a weird way you're going to need all of + // this + const clap::plugin::Process& request = request_wrapper.get(); + + // TODO: The channel counts are now capped at what the plugin + // supports (based on the audio buffers we set up during + // `IAudioProcessor::setActive()`). Some hosts may send more + // buffers, but we don't reflect that in the output right now. + std::ostringstream num_input_channels; + num_input_channels << "["; + bool is_first = true; + for (size_t i = 0; i < request.process.audio_inputs_.size(); i++) { + const auto& port = request.process.audio_inputs_[i]; + num_input_channels << (is_first ? "" : ", ") + << port.channel_count; + if (port.latency) { + num_input_channels << " (" << port.latency + << " sample latency)"; + } + if (port.constant_mask > 0) { + num_input_channels << " (silence)"; + } + + is_first = false; + } + num_input_channels << "]"; + + std::ostringstream num_output_channels; + num_output_channels << "["; + is_first = true; + for (size_t i = 0; i < request.process.audio_outputs_.size(); i++) { + const auto& port = request.process.audio_outputs_[i]; + num_output_channels << (is_first ? "" : ", ") + << port.channel_count; + if (port.latency) { + num_output_channels << " (" << port.latency + << " sample latency)"; + } + if (port.constant_mask > 0) { + num_output_channels << " (silence)"; + } + + is_first = false; + } + num_output_channels << "]"; + + message << request.instance_id + << ": clap_plugin::process(process = " + : "") + << ", audio_input_channels = " << num_input_channels.str() + << ", audio_output_channels = " << num_output_channels.str() + << ", in_events = , out_events = >)"; + }); +} + bool ClapLogger::log_request(bool is_host_plugin, const clap::ext::params::plugin::Flush& request) { return log_request_base(is_host_plugin, [&](auto& message) { @@ -765,6 +833,61 @@ void ClapLogger::log_response( }); } +void ClapLogger::log_response(bool is_host_plugin, + const clap::plugin::ProcessResponse& response) { + log_response_base(is_host_plugin, [&](auto& message) { + // This is incredibly verbose, but if you're really a plugin that + // handles processing in a weird way you're going to need all of this + assert(response.output_data.audio_outputs && + response.output_data.out_events); + + std::ostringstream num_output_channels; + num_output_channels << "["; + bool is_first = true; + for (size_t i = 0; i < response.output_data.audio_outputs->size(); + i++) { + const auto& port = (*response.output_data.audio_outputs)[i]; + num_output_channels << (is_first ? "" : ", ") << port.channel_count; + if (port.latency) { + num_output_channels << " (" << port.latency + << " sample latency)"; + } + if (port.constant_mask > 0) { + num_output_channels << " (silence)"; + } + + is_first = false; + } + num_output_channels << "]"; + + switch (response.result) { + case CLAP_PROCESS_ERROR: + message << "CLAP_PROCESS_ERROR"; + break; + case CLAP_PROCESS_CONTINUE: + message << "CLAP_PROCESS_CONTINUE"; + break; + case CLAP_PROCESS_CONTINUE_IF_NOT_QUIET: + message << "CLAP_PROCESS_CONTINUE_IF_NOT_QUIET"; + break; + case CLAP_PROCESS_TAIL: + message << "CLAP_PROCESS_TAIL"; + break; + case CLAP_PROCESS_SLEEP: + message << "CLAP_PROCESS_SLEEP"; + break; + default: + message << "unknown status " << response.result; + break; + } + + message << ", , size() << " events>"; + }); +} + void ClapLogger::log_response(bool is_host_plugin, const Configuration&) { log_response_base(is_host_plugin, [&](auto& message) { message << ""; }); diff --git a/src/common/logging/clap.h b/src/common/logging/clap.h index 9266c3f4..b42b85a0 100644 --- a/src/common/logging/clap.h +++ b/src/common/logging/clap.h @@ -129,6 +129,8 @@ class ClapLogger { bool log_request(bool is_host_plugin, const clap::plugin::StartProcessing&); bool log_request(bool is_host_plugin, const clap::plugin::StopProcessing&); bool log_request(bool is_host_plugin, const clap::plugin::Reset&); + bool log_request(bool is_host_plugin, + const MessageReference&); bool log_request(bool is_host_plugin, const clap::ext::params::plugin::Flush&); bool log_request(bool is_host_plugin, const clap::ext::tail::plugin::Get&); @@ -202,6 +204,10 @@ class ClapLogger { void log_response(bool is_host_plugin, const clap::ext::state::plugin::SaveResponse&); + // Audio thread control message responses + void log_response(bool is_host_plugin, + const clap::plugin::ProcessResponse&); + // Main thread callback responses void log_response(bool is_host_plugin, const Configuration&);