mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 20:10:13 +02:00
Add serialization structs for audio ports
This commit is contained in:
@@ -39,13 +39,16 @@
|
||||
*/
|
||||
// FIXME: Remove the `WantsConfiguration`. For some reason bitsery just won't
|
||||
// serialize this without it.
|
||||
using ClapMainThreadControlRequest = std::variant<WantsConfiguration,
|
||||
clap::plugin_factory::List,
|
||||
clap::plugin_factory::Create,
|
||||
clap::plugin::Init,
|
||||
clap::plugin::Destroy,
|
||||
clap::plugin::Activate,
|
||||
clap::plugin::Deactivate>;
|
||||
using ClapMainThreadControlRequest =
|
||||
std::variant<WantsConfiguration,
|
||||
clap::plugin_factory::List,
|
||||
clap::plugin_factory::Create,
|
||||
clap::plugin::Init,
|
||||
clap::plugin::Destroy,
|
||||
clap::plugin::Activate,
|
||||
clap::plugin::Deactivate,
|
||||
clap::ext::audio_ports::plugin::Count,
|
||||
clap::ext::audio_ports::plugin::Get>;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s, ClapMainThreadControlRequest& payload) {
|
||||
@@ -124,9 +127,12 @@ struct ClapAudioThreadControlRequest {
|
||||
* type `ClapMainThreadCallbackRequest(T)` should send back a `T::Response`.
|
||||
*/
|
||||
// TODO: Placeholder
|
||||
using ClapMainThreadCallbackRequest = std::variant<WantsConfiguration,
|
||||
clap::host::RequestRestart,
|
||||
clap::host::RequestProcess>;
|
||||
using ClapMainThreadCallbackRequest =
|
||||
std::variant<WantsConfiguration,
|
||||
clap::host::RequestRestart,
|
||||
clap::host::RequestProcess,
|
||||
clap::ext::audio_ports::host::IsRescanFlagSupported,
|
||||
clap::ext::audio_ports::host::Rescan>;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s, ClapMainThreadCallbackRequest& payload) {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// 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 "audio-ports.h"
|
||||
|
||||
namespace clap {
|
||||
namespace ext {
|
||||
namespace audio_ports {
|
||||
|
||||
AudioPortInfo::AudioPortInfo(const clap_audio_port_info_t& original)
|
||||
: id(original.id),
|
||||
name(original.name),
|
||||
flags(original.flags),
|
||||
channel_count(original.channel_count),
|
||||
port_type(original.port_type),
|
||||
in_place_pair(original.in_place_pair) {}
|
||||
|
||||
} // namespace audio_ports
|
||||
} // namespace ext
|
||||
} // namespace clap
|
||||
@@ -0,0 +1,160 @@
|
||||
// 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/audio-ports.h>
|
||||
|
||||
#include "../../../bitsery/ext/in-place-optional.h"
|
||||
#include "../../common.h"
|
||||
|
||||
// Serialization messages for `clap/ext/audio-ports.h`
|
||||
|
||||
namespace clap {
|
||||
namespace ext {
|
||||
namespace audio_ports {
|
||||
|
||||
/**
|
||||
* A serializable version of `clap_audio_port_info` that owns all of the data it
|
||||
* references.
|
||||
*/
|
||||
struct AudioPortInfo {
|
||||
/**
|
||||
* Parse a host descriptor so it can be serialized and sent to the Wine
|
||||
* plugin host.
|
||||
*/
|
||||
AudioPortInfo(const clap_audio_port_info_t& original);
|
||||
|
||||
/**
|
||||
* Default constructor for bitsery.
|
||||
*/
|
||||
AudioPortInfo() {}
|
||||
|
||||
clap_id id;
|
||||
std::string name;
|
||||
uint32_t flags;
|
||||
uint32_t channel_count;
|
||||
// We could create an enum for this and only serialize the predefined types,
|
||||
// but store the actual string is easier and more future proof without
|
||||
// having a noticeable impact on performance.
|
||||
std::string port_type;
|
||||
clap_id in_place_pair;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value4b(id);
|
||||
s.text1b(name, 4096);
|
||||
s.value4b(flags);
|
||||
s.value4b(channel_count);
|
||||
s.text1b(port_type);
|
||||
s.value4b(in_place_pair);
|
||||
}
|
||||
};
|
||||
|
||||
namespace plugin {
|
||||
|
||||
/**
|
||||
* Message struct for `clap_plugin_audio_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::audio_ports::Get` message defined below.
|
||||
*/
|
||||
struct GetResponse {
|
||||
std::optional<AudioPortInfo> 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_audio_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_audio_ports::is_rescan_flag_supported()`.
|
||||
*/
|
||||
struct IsRescanFlagSupported {
|
||||
using Response = PrimitiveResponse<bool>;
|
||||
|
||||
native_size_t owner_instance_id;
|
||||
uint32_t flag;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(owner_instance_id);
|
||||
s.value4b(flag);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Message struct for `clap_host_audio_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 audio_ports
|
||||
} // namespace ext
|
||||
} // namespace clap
|
||||
@@ -80,6 +80,7 @@ host_sources = files(
|
||||
if with_clap
|
||||
host_sources += files(
|
||||
'../common/logging/clap.cpp',
|
||||
'../common/serialization/clap/ext/audio-ports.cpp',
|
||||
'../common/serialization/clap/plugin.cpp',
|
||||
'bridges/clap-impls/host-proxy.cpp',
|
||||
'bridges/clap.cpp',
|
||||
|
||||
Reference in New Issue
Block a user