mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-16 13:40:05 +02:00
Fix some of the clang-tidy lints
This commit is contained in:
@@ -304,6 +304,7 @@ class Vst3Sockets : public Sockets {
|
||||
listen),
|
||||
io_context(io_context) {}
|
||||
|
||||
// NOLINTNEXTLINE(clang-analyzer-optin.cplusplus.VirtualCall)
|
||||
~Vst3Sockets() { close(); }
|
||||
|
||||
void connect() override {
|
||||
|
||||
@@ -36,14 +36,16 @@ VstEvents& DynamicVstEvents::as_c_events() {
|
||||
// number of events minus one pointers.
|
||||
static_assert(std::extent_v<decltype(VstEvents::events)> == 1);
|
||||
const size_t buffer_size =
|
||||
sizeof(VstEvents) + ((events.size() - 1) * sizeof(VstEvent*));
|
||||
sizeof(VstEvents) +
|
||||
((events.size() - 1) *
|
||||
sizeof(VstEvent*)); // NOLINT(bugprone-sizeof-expression)
|
||||
vst_events_buffer.resize(buffer_size);
|
||||
|
||||
// Now we can populate the VLA with pointers to the objects in the `events`
|
||||
// vector
|
||||
VstEvents* vst_events =
|
||||
reinterpret_cast<VstEvents*>(vst_events_buffer.data());
|
||||
vst_events->numEvents = events.size();
|
||||
vst_events->numEvents = static_cast<int>(events.size());
|
||||
std::transform(events.begin(), events.end(), vst_events->events,
|
||||
[](VstEvent& event) -> VstEvent* { return &event; });
|
||||
|
||||
@@ -76,7 +78,7 @@ VstSpeakerArrangement& DynamicSpeakerArrangement::as_c_speaker_arrangement() {
|
||||
reinterpret_cast<VstSpeakerArrangement*>(
|
||||
speaker_arrangement_buffer.data());
|
||||
speaker_arrangement->flags = flags;
|
||||
speaker_arrangement->num_speakers = speakers.size();
|
||||
speaker_arrangement->num_speakers = static_cast<int>(speakers.size());
|
||||
std::copy(speakers.begin(), speakers.end(), speaker_arrangement->speakers);
|
||||
|
||||
return *speaker_arrangement;
|
||||
|
||||
@@ -40,7 +40,8 @@ YaBStream::YaBStream(Steinberg::IBStream* stream) {
|
||||
int32 num_bytes_read = 0;
|
||||
buffer.resize(size);
|
||||
stream->seek(0, Steinberg::IBStream::IStreamSeekMode::kIBSeekSet);
|
||||
stream->read(buffer.data(), size, &num_bytes_read);
|
||||
stream->read(buffer.data(), static_cast<int32>(size),
|
||||
&num_bytes_read);
|
||||
assert(num_bytes_read == 0 || num_bytes_read == size);
|
||||
}
|
||||
}
|
||||
@@ -103,7 +104,8 @@ tresult YaBStream::write_back(Steinberg::IBStream* stream) const {
|
||||
// A `stream->seek(0, kIBSeekSet)` breaks restoring states in Bitwig. Not
|
||||
// sure if Bitwig is prepending a header or if this is expected behaviour.
|
||||
int32 num_bytes_written = 0;
|
||||
if (stream->write(const_cast<uint8_t*>(buffer.data()), buffer.size(),
|
||||
if (stream->write(const_cast<uint8_t*>(buffer.data()),
|
||||
static_cast<int32>(buffer.size()),
|
||||
&num_bytes_written) == Steinberg::kResultOk) {
|
||||
// Some implementations will return `kResultFalse` when writing 0 bytes
|
||||
assert(num_bytes_written == 0 ||
|
||||
@@ -145,7 +147,7 @@ tresult PLUGIN_API YaBStream::read(void* buffer,
|
||||
|
||||
seek_position += bytes_to_read;
|
||||
if (numBytesRead) {
|
||||
*numBytesRead = bytes_to_read;
|
||||
*numBytesRead = static_cast<int32>(bytes_to_read);
|
||||
}
|
||||
|
||||
return Steinberg::kResultOk;
|
||||
@@ -163,7 +165,7 @@ tresult PLUGIN_API YaBStream::write(void* buffer,
|
||||
}
|
||||
|
||||
std::copy_n(reinterpret_cast<uint8_t*>(buffer), numBytes,
|
||||
this->buffer.begin() + seek_position);
|
||||
this->buffer.begin() + static_cast<int>(seek_position));
|
||||
|
||||
seek_position += numBytes;
|
||||
if (numBytesWritten) {
|
||||
@@ -190,7 +192,7 @@ tresult PLUGIN_API YaBStream::seek(int64 pos, int32 mode, int64* result) {
|
||||
}
|
||||
|
||||
if (result) {
|
||||
*result = seek_position;
|
||||
*result = static_cast<int64>(seek_position);
|
||||
}
|
||||
|
||||
return Steinberg::kResultOk;
|
||||
@@ -198,7 +200,7 @@ tresult PLUGIN_API YaBStream::seek(int64 pos, int32 mode, int64* result) {
|
||||
|
||||
tresult PLUGIN_API YaBStream::tell(int64* pos) {
|
||||
if (pos) {
|
||||
*pos = seek_position;
|
||||
*pos = static_cast<int64>(seek_position);
|
||||
return Steinberg::kResultOk;
|
||||
} else {
|
||||
return Steinberg::kInvalidArgument;
|
||||
@@ -206,7 +208,7 @@ tresult PLUGIN_API YaBStream::tell(int64* pos) {
|
||||
}
|
||||
|
||||
tresult PLUGIN_API YaBStream::getStreamSize(int64& size) {
|
||||
size = seek_position;
|
||||
size = static_cast<int64>(seek_position);
|
||||
return Steinberg::kResultOk;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ IMPLEMENT_FUNKNOWN_METHODS(YaEventList,
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
int32 PLUGIN_API YaEventList::getEventCount() {
|
||||
return events.size();
|
||||
return static_cast<int32>(events.size());
|
||||
}
|
||||
|
||||
tresult PLUGIN_API YaEventList::getEvent(int32 index,
|
||||
@@ -231,8 +231,10 @@ tresult PLUGIN_API YaEventList::getEvent(int32 index,
|
||||
if (index >= static_cast<int32>(num_already_reconstructed_events)) {
|
||||
reconstructed_events.resize(events.size());
|
||||
std::transform(
|
||||
events.begin() + num_already_reconstructed_events, events.end(),
|
||||
reconstructed_events.begin() + num_already_reconstructed_events,
|
||||
events.begin() + static_cast<int>(num_already_reconstructed_events),
|
||||
events.end(),
|
||||
reconstructed_events.begin() +
|
||||
static_cast<int>(num_already_reconstructed_events),
|
||||
[](const YaEvent& event) { return event.get(); });
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ Steinberg::Vst::ParamID PLUGIN_API YaParamValueQueue::getParameterId() {
|
||||
}
|
||||
|
||||
int32 PLUGIN_API YaParamValueQueue::getPointCount() {
|
||||
return queue.size();
|
||||
return static_cast<int32>(queue.size());
|
||||
}
|
||||
|
||||
tresult PLUGIN_API
|
||||
@@ -81,7 +81,7 @@ YaParamValueQueue::getPoint(int32 index,
|
||||
tresult PLUGIN_API YaParamValueQueue::addPoint(int32 sampleOffset,
|
||||
Steinberg::Vst::ParamValue value,
|
||||
int32& index /*out*/) {
|
||||
index = queue.size();
|
||||
index = static_cast<int32>(queue.size());
|
||||
queue.push_back({sampleOffset, value});
|
||||
|
||||
return Steinberg::kResultOk;
|
||||
|
||||
@@ -59,7 +59,7 @@ void YaParameterChanges::write_back_outputs(
|
||||
}
|
||||
|
||||
int32 PLUGIN_API YaParameterChanges::getParameterCount() {
|
||||
return queues.size();
|
||||
return static_cast<int32>(queues.size());
|
||||
}
|
||||
|
||||
Steinberg::Vst::IParamValueQueue* PLUGIN_API
|
||||
@@ -74,7 +74,7 @@ YaParameterChanges::getParameterData(int32 index) {
|
||||
Steinberg::Vst::IParamValueQueue* PLUGIN_API
|
||||
YaParameterChanges::addParameterData(const Steinberg::Vst::ParamID& id,
|
||||
int32& index /*out*/) {
|
||||
index = queues.size();
|
||||
index = static_cast<int32>(queues.size());
|
||||
queues.push_back(YaParamValueQueue(id));
|
||||
|
||||
return &queues[index];
|
||||
|
||||
@@ -72,7 +72,8 @@ Steinberg::Vst::AudioBusBuffers YaAudioBusBuffers::get() {
|
||||
buffer_pointers.push_back(buffer.data());
|
||||
}
|
||||
|
||||
reconstructed_buffers.numChannels = buffers.size();
|
||||
reconstructed_buffers.numChannels =
|
||||
static_cast<int32>(buffers.size());
|
||||
reconstructed_buffers.channelBuffers64 =
|
||||
reinterpret_cast<double**>(buffer_pointers.data());
|
||||
},
|
||||
@@ -82,7 +83,8 @@ Steinberg::Vst::AudioBusBuffers YaAudioBusBuffers::get() {
|
||||
buffer_pointers.push_back(buffer.data());
|
||||
}
|
||||
|
||||
reconstructed_buffers.numChannels = buffers.size();
|
||||
reconstructed_buffers.numChannels =
|
||||
static_cast<int32>(buffers.size());
|
||||
reconstructed_buffers.channelBuffers32 =
|
||||
reinterpret_cast<float**>(buffer_pointers.data());
|
||||
},
|
||||
@@ -194,8 +196,9 @@ Steinberg::Vst::ProcessData& YaProcessData::get() {
|
||||
reconstructed_process_data.processMode = process_mode;
|
||||
reconstructed_process_data.symbolicSampleSize = symbolic_sample_size;
|
||||
reconstructed_process_data.numSamples = num_samples;
|
||||
reconstructed_process_data.numInputs = inputs.size();
|
||||
reconstructed_process_data.numOutputs = outputs_num_channels.size();
|
||||
reconstructed_process_data.numInputs = static_cast<int32>(inputs.size());
|
||||
reconstructed_process_data.numOutputs =
|
||||
static_cast<int32>(outputs_num_channels.size());
|
||||
reconstructed_process_data.inputs = inputs_audio_bus_buffers.data();
|
||||
reconstructed_process_data.outputs = outputs_audio_bus_buffers.data();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ size_t Vst3PluginProxyImpl::register_context_menu(
|
||||
std::lock_guard lock(context_menus_mutex);
|
||||
|
||||
const size_t context_menu_id = current_context_menu_id.fetch_add(1);
|
||||
context_menus.emplace(context_menu_id, std::move(menu));
|
||||
context_menus.emplace(context_menu_id, menu);
|
||||
|
||||
return context_menu_id;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ Vst3PluginBridge::Vst3PluginBridge()
|
||||
const size_t context_menu_id =
|
||||
plugin_proxies.at(request.owner_instance_id)
|
||||
.get()
|
||||
.register_context_menu(std::move(context_menu));
|
||||
.register_context_menu(context_menu);
|
||||
|
||||
return YaComponentHandler3::CreateContextMenuResponse{
|
||||
.context_menu_args =
|
||||
|
||||
@@ -163,6 +163,7 @@ fs::path find_plugin_library(const fs::path& this_plugin_path,
|
||||
// _actual_ (with yabridgectl `x86_64-win` should only contain a
|
||||
// 64-bit plugin and `x86-win` should only contain a 32-bit plugin,
|
||||
// but you never know!)
|
||||
// NOLINTNEXTLINE(bugprone-branch-clone)
|
||||
if (prefer_32bit_vst3 && fs::exists(candidate_path_32bit)) {
|
||||
return fs::canonical(candidate_path_32bit);
|
||||
} else if (fs::exists(candidate_path_64bit)) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
// as close to the vanilla SDK as possible.
|
||||
#define InitModule init_module
|
||||
#define DeinitModule deinit_module
|
||||
// NOLINTNEXTLINE(bugprone-suspicious-include)
|
||||
#include <public.sdk/source/main/linuxmain.cpp>
|
||||
|
||||
// Because VST3 plugins consist of completely independent components that have
|
||||
|
||||
@@ -100,8 +100,11 @@ Vst2Bridge::Vst2Bridge(MainContext& main_context,
|
||||
// `get_bridge_instance` trick as in `plugin/bridges/vst2.cpp`, but since
|
||||
// the plugin will probably call the host callback while it's initializing
|
||||
// we sadly have to use a global here.
|
||||
// Note that this reinterpret cast is not needed at all since the function
|
||||
// pointer types are exactly the same, but clangd will complain otherwise
|
||||
current_bridge_instance = this;
|
||||
plugin = vst_entry_point(host_callback_proxy);
|
||||
plugin = vst_entry_point(
|
||||
reinterpret_cast<audioMasterCallback>(host_callback_proxy));
|
||||
if (!plugin) {
|
||||
throw std::runtime_error("VST plugin at '" + plugin_dll_path +
|
||||
"' failed to initialize.");
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
//
|
||||
// https://bugs.winehq.org/show_bug.cgi?id=50670
|
||||
#define __IFileOperation_INTERFACE_DEFINED__
|
||||
// NOLINTNEXTLINE(bugprone-suspicious-include)
|
||||
#include <public.sdk/source/vst/hosting/module_win32.cpp>
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user