mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Add serialization structs for note ports extension
This commit is contained in:
@@ -66,8 +66,8 @@ const char* audio_port_type_to_string(AudioPortType port_type);
|
|||||||
*/
|
*/
|
||||||
struct AudioPortInfo {
|
struct AudioPortInfo {
|
||||||
/**
|
/**
|
||||||
* Parse a host descriptor so it can be serialized and sent to the Wine
|
* Parse a native `clap_audio_port_info` struct so it can be serialized and
|
||||||
* plugin host.
|
* sent to the Wine plugin host.
|
||||||
*/
|
*/
|
||||||
AudioPortInfo(const clap_audio_port_info_t& original);
|
AudioPortInfo(const clap_audio_port_info_t& original);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// 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 "note-ports.h"
|
||||||
|
|
||||||
|
#include "../../../utils.h"
|
||||||
|
|
||||||
|
namespace clap {
|
||||||
|
namespace ext {
|
||||||
|
namespace note_ports {
|
||||||
|
|
||||||
|
NotePortInfo::NotePortInfo(const clap_note_port_info_t& original)
|
||||||
|
: id(original.id),
|
||||||
|
supported_dialects(original.supported_dialects),
|
||||||
|
preferred_dialect(original.preferred_dialect),
|
||||||
|
name(original.name) {}
|
||||||
|
|
||||||
|
void NotePortInfo::reconstruct(clap_note_port_info_t& port_info) const {
|
||||||
|
port_info = clap_note_port_info_t{};
|
||||||
|
port_info.id = id;
|
||||||
|
port_info.supported_dialects = supported_dialects;
|
||||||
|
port_info.preferred_dialect = preferred_dialect;
|
||||||
|
strlcpy_buffer<sizeof(port_info.name)>(port_info.name, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace note_ports
|
||||||
|
} // namespace ext
|
||||||
|
} // namespace clap
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
// 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/>.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <clap/ext/note-ports.h>
|
||||||
|
|
||||||
|
#include "../../../bitsery/ext/in-place-optional.h"
|
||||||
|
#include "../../common.h"
|
||||||
|
|
||||||
|
// Serialization messages for `clap/ext/note-ports.h`
|
||||||
|
|
||||||
|
namespace clap {
|
||||||
|
namespace ext {
|
||||||
|
namespace note_ports {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A serializable version of `clap_note_port_info` that owns all of the data it
|
||||||
|
* references.
|
||||||
|
*/
|
||||||
|
struct NotePortInfo {
|
||||||
|
/**
|
||||||
|
* Parse a native `clap_note_port_info` struct so it can be serialized and
|
||||||
|
* sent to the Wine plugin host.
|
||||||
|
*/
|
||||||
|
NotePortInfo(const clap_note_port_info_t& original);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor for bitsery.
|
||||||
|
*/
|
||||||
|
NotePortInfo() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write the stored information to a host provided info struct.
|
||||||
|
*/
|
||||||
|
void reconstruct(clap_note_port_info_t& port_info) const;
|
||||||
|
|
||||||
|
clap_id id;
|
||||||
|
uint32_t supported_dialects;
|
||||||
|
uint32_t preferred_dialect;
|
||||||
|
std::string name;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value4b(id);
|
||||||
|
s.value4b(supported_dialects);
|
||||||
|
s.value4b(preferred_dialect);
|
||||||
|
s.text1b(name, 4096);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace plugin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message struct for `clap_plugin_note_ports::count()`.
|
||||||
|
*/
|
||||||
|
struct Count {
|
||||||
|
using Response = PrimitiveResponse<uint32_t>;
|
||||||
|
|
||||||
|
native_size_t instance_id;
|
||||||
|
bool is_input;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value8b(instance_id);
|
||||||
|
s.value1b(is_input);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The response to the `clap::ext::note_ports::Get` message defined below.
|
||||||
|
*/
|
||||||
|
struct GetResponse {
|
||||||
|
std::optional<NotePortInfo> result;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.ext(result, bitsery::ext::InPlaceOptional(),
|
||||||
|
[](S& s, auto& v) { s.object(v); });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message struct for `clap_plugin_note_ports::get()`.
|
||||||
|
*/
|
||||||
|
struct Get {
|
||||||
|
using Response = GetResponse;
|
||||||
|
|
||||||
|
native_size_t instance_id;
|
||||||
|
uint32_t index;
|
||||||
|
bool is_input;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value8b(instance_id);
|
||||||
|
s.value4b(index);
|
||||||
|
s.value1b(is_input);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace plugin
|
||||||
|
|
||||||
|
namespace host {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message struct for `clap_host_note_ports::supported_dialects()`.
|
||||||
|
*/
|
||||||
|
struct SupportedDialects {
|
||||||
|
using Response = PrimitiveResponse<uint32_t>;
|
||||||
|
|
||||||
|
native_size_t owner_instance_id;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value8b(owner_instance_id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Message struct for `clap_host_note_ports::rescan()`.
|
||||||
|
*/
|
||||||
|
struct Rescan {
|
||||||
|
using Response = Ack;
|
||||||
|
|
||||||
|
native_size_t owner_instance_id;
|
||||||
|
uint32_t flags;
|
||||||
|
|
||||||
|
template <typename S>
|
||||||
|
void serialize(S& s) {
|
||||||
|
s.value8b(owner_instance_id);
|
||||||
|
s.value4b(flags);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace host
|
||||||
|
|
||||||
|
} // namespace note_ports
|
||||||
|
} // namespace ext
|
||||||
|
} // namespace clap
|
||||||
@@ -78,6 +78,7 @@ if with_clap
|
|||||||
'../common/plugins.cpp',
|
'../common/plugins.cpp',
|
||||||
'../common/process.cpp',
|
'../common/process.cpp',
|
||||||
'../common/serialization/clap/ext/audio-ports.cpp',
|
'../common/serialization/clap/ext/audio-ports.cpp',
|
||||||
|
'../common/serialization/clap/ext/note-ports.cpp',
|
||||||
'../common/serialization/clap/host.cpp',
|
'../common/serialization/clap/host.cpp',
|
||||||
'../common/serialization/clap/plugin.cpp',
|
'../common/serialization/clap/plugin.cpp',
|
||||||
'../common/utils.cpp',
|
'../common/utils.cpp',
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ if with_clap
|
|||||||
host_sources += files(
|
host_sources += files(
|
||||||
'../common/logging/clap.cpp',
|
'../common/logging/clap.cpp',
|
||||||
'../common/serialization/clap/ext/audio-ports.cpp',
|
'../common/serialization/clap/ext/audio-ports.cpp',
|
||||||
|
'../common/serialization/clap/ext/note-ports.cpp',
|
||||||
'../common/serialization/clap/plugin.cpp',
|
'../common/serialization/clap/plugin.cpp',
|
||||||
'bridges/clap-impls/host-proxy.cpp',
|
'bridges/clap-impls/host-proxy.cpp',
|
||||||
'bridges/clap.cpp',
|
'bridges/clap.cpp',
|
||||||
|
|||||||
Reference in New Issue
Block a user