mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
229 lines
8.0 KiB
C++
229 lines
8.0 KiB
C++
// yabridge: a Wine plugin bridge
|
|
// Copyright (C) 2020-2022 Robbert van der Helm
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#include "clap.h"
|
|
|
|
#include <bitset>
|
|
|
|
#include <clap/ext/audio-ports.h>
|
|
|
|
#include "../serialization/clap.h"
|
|
|
|
ClapLogger::ClapLogger(Logger& generic_logger) : logger_(generic_logger) {}
|
|
|
|
void ClapLogger::log_callback_request(size_t instance_id) {
|
|
log_request_base(false, Logger::Verbosity::all_events, [&](auto& message) {
|
|
message << instance_id << ": clap_host::request_callback()";
|
|
});
|
|
}
|
|
|
|
void ClapLogger::log_on_main_thread(size_t instance_id) {
|
|
log_request_base(true, Logger::Verbosity::all_events, [&](auto& message) {
|
|
message << instance_id << ": clap_plugin::on_main_thread()";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin_factory::List&) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << "clap_plugin_factory::list()";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin_factory::Create& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << "clap_plugin_factory::create(host = <clap_host_t*>, "
|
|
"plugin_id = \""
|
|
<< request.plugin_id << "\")";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin::Init& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.instance_id
|
|
<< ": clap_plugin::init(), supported host extensions: ";
|
|
|
|
bool first = true;
|
|
const auto& supported_extensions = request.supported_host_extensions;
|
|
for (const auto& [supported, extension_name] :
|
|
{std::pair(supported_extensions.supports_audio_ports,
|
|
CLAP_EXT_AUDIO_PORTS)}) {
|
|
if (!supported) {
|
|
continue;
|
|
}
|
|
|
|
if (first) {
|
|
message << '"' << extension_name << '"';
|
|
} else {
|
|
message << ", \"" << extension_name << '"';
|
|
}
|
|
|
|
first = false;
|
|
}
|
|
|
|
if (first) {
|
|
message << "<none>";
|
|
}
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin::Destroy& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.instance_id << ": clap_plugin::destroy()";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin::Activate& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.instance_id
|
|
<< ": clap_plugin::activate(sample_rate = "
|
|
<< request.sample_rate
|
|
<< ", min_frames_count = " << request.min_frames_count
|
|
<< ", max_frames_count = " << request.max_frames_count << ")";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin::Deactivate& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.instance_id << ": clap_plugin::deactivate()";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin::StartProcessing& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.instance_id << ": clap_plugin::start_processing()";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin::StopProcessing& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.instance_id << ": clap_plugin::stop_processing()";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::plugin::Reset& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.instance_id << ": clap_plugin::reset()";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin, const WantsConfiguration&) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << "Requesting <Configuration>";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::host::RequestRestart& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.owner_instance_id
|
|
<< ": clap_host::request_restart()";
|
|
});
|
|
}
|
|
|
|
bool ClapLogger::log_request(bool is_host_plugin,
|
|
const clap::host::RequestProcess& request) {
|
|
return log_request_base(is_host_plugin, [&](auto& message) {
|
|
message << request.owner_instance_id
|
|
<< ": clap_host::request_process()";
|
|
});
|
|
}
|
|
|
|
void ClapLogger::log_response(bool is_host_plugin, const Ack&) {
|
|
log_response_base(is_host_plugin, [&](auto& message) { message << "ACK"; });
|
|
}
|
|
|
|
void ClapLogger::log_response(
|
|
bool is_host_plugin,
|
|
const clap::plugin_factory::ListResponse& response) {
|
|
return log_response_base(is_host_plugin, [&](auto& message) {
|
|
if (response.descriptors) {
|
|
message << "<clap_plugin_factory* containing "
|
|
<< response.descriptors->size() << " plugin descriptors>";
|
|
} else {
|
|
message << "<not supported>";
|
|
}
|
|
});
|
|
}
|
|
|
|
void ClapLogger::log_response(
|
|
bool is_host_plugin,
|
|
const clap::plugin_factory::CreateResponse& response) {
|
|
return log_response_base(is_host_plugin, [&](auto& message) {
|
|
if (response.instance_id) {
|
|
message << "<clap_plugin_t* with instance ID "
|
|
<< *response.instance_id << ">";
|
|
} else {
|
|
message << "<nullptr*>";
|
|
}
|
|
});
|
|
}
|
|
|
|
void ClapLogger::log_response(bool is_host_plugin,
|
|
const clap::plugin::InitResponse& response) {
|
|
return log_response_base(is_host_plugin, [&](auto& message) {
|
|
message << (response.result ? "true" : "false")
|
|
<< ", supported plugin extensions: ";
|
|
|
|
bool first = true;
|
|
const auto& supported_extensions = response.supported_plugin_extensions;
|
|
for (const auto& [supported, extension_name] :
|
|
{std::pair(supported_extensions.supports_audio_ports,
|
|
CLAP_EXT_AUDIO_PORTS)}) {
|
|
if (!supported) {
|
|
continue;
|
|
}
|
|
|
|
if (first) {
|
|
message << '"' << extension_name << '"';
|
|
} else {
|
|
message << ", \"" << extension_name << '"';
|
|
}
|
|
|
|
first = false;
|
|
}
|
|
|
|
if (first) {
|
|
message << "<none>";
|
|
}
|
|
});
|
|
}
|
|
|
|
void ClapLogger::log_response(bool is_host_plugin,
|
|
const clap::plugin::ActivateResponse& response) {
|
|
return log_response_base(is_host_plugin, [&](auto& message) {
|
|
message << (response.result ? "true" : "false");
|
|
if (response.result && response.updated_audio_buffers_config) {
|
|
message << ", <new shared memory configuration for \""
|
|
<< response.updated_audio_buffers_config->name << "\", "
|
|
<< response.updated_audio_buffers_config->size << " bytes>";
|
|
}
|
|
});
|
|
}
|
|
|
|
void ClapLogger::log_response(bool is_host_plugin, const Configuration&) {
|
|
log_response_base(is_host_plugin,
|
|
[&](auto& message) { message << "<Configuration>"; });
|
|
}
|