mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-06 19:40:10 +02:00
Add structs and utils for audio-ports-config
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "../bitsery/ext/message-reference.h"
|
||||
#include "../utils.h"
|
||||
#include "clap/events.h"
|
||||
#include "clap/ext/audio-ports-config.h"
|
||||
#include "clap/ext/audio-ports.h"
|
||||
#include "clap/ext/gui.h"
|
||||
#include "clap/ext/latency.h"
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// 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-config.h"
|
||||
|
||||
#include "../../../utils.h"
|
||||
|
||||
namespace clap {
|
||||
namespace ext {
|
||||
namespace audio_ports_config {
|
||||
|
||||
AudioPortsConfig::AudioPortsConfig(const clap_audio_ports_config_t& original)
|
||||
: id(original.id),
|
||||
name(original.name),
|
||||
input_port_count(original.input_port_count),
|
||||
output_port_count(original.output_port_count),
|
||||
has_main_input(original.has_main_input),
|
||||
main_input_channel_count(original.main_input_channel_count),
|
||||
main_input_port_type(clap::ext::audio_ports::parse_audio_port_type(
|
||||
original.main_input_port_type)),
|
||||
has_main_output(original.has_main_output),
|
||||
main_output_channel_count(original.main_output_channel_count),
|
||||
main_output_port_type(clap::ext::audio_ports::parse_audio_port_type(
|
||||
original.main_output_port_type)) {}
|
||||
|
||||
void AudioPortsConfig::reconstruct(clap_audio_ports_config_t& config) const {
|
||||
config = clap_audio_ports_config_t{};
|
||||
config.id = id;
|
||||
strlcpy_buffer<sizeof(config.name)>(config.name, name);
|
||||
config.input_port_count = input_port_count;
|
||||
config.output_port_count = output_port_count;
|
||||
config.has_main_input = has_main_input;
|
||||
config.main_input_channel_count = main_input_channel_count;
|
||||
config.main_input_port_type =
|
||||
clap::ext::audio_ports::audio_port_type_to_string(main_input_port_type);
|
||||
config.has_main_output = has_main_output;
|
||||
config.main_output_channel_count = main_output_channel_count;
|
||||
config.main_output_port_type =
|
||||
clap::ext::audio_ports::audio_port_type_to_string(
|
||||
main_output_port_type);
|
||||
}
|
||||
|
||||
} // namespace audio_ports_config
|
||||
} // namespace ext
|
||||
} // namespace clap
|
||||
@@ -0,0 +1,167 @@
|
||||
// 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-config.h>
|
||||
|
||||
#include "../../../bitsery/ext/in-place-optional.h"
|
||||
#include "../../common.h"
|
||||
#include "audio-ports.h"
|
||||
|
||||
// Serialization messages for `clap/ext/audio-ports-config.h`
|
||||
|
||||
namespace clap {
|
||||
namespace ext {
|
||||
namespace audio_ports_config {
|
||||
|
||||
/**
|
||||
* A serializable version of `clap_audio_ports_config_t` that owns all of the
|
||||
* data it references.
|
||||
*/
|
||||
struct AudioPortsConfig {
|
||||
/**
|
||||
* Parse a native `clap_audio_ports_config` struct so it can be serialized
|
||||
* and sent to the Wine plugin host.
|
||||
*/
|
||||
AudioPortsConfig(const clap_audio_ports_config_t& original);
|
||||
|
||||
/**
|
||||
* Default constructor for bitsery.
|
||||
*/
|
||||
AudioPortsConfig() {}
|
||||
|
||||
/**
|
||||
* Write the stored configuration to a host provided struct.
|
||||
*/
|
||||
void reconstruct(clap_audio_ports_config_t& config) const;
|
||||
|
||||
clap_id id;
|
||||
std::string name;
|
||||
uint32_t input_port_count;
|
||||
uint32_t output_port_count;
|
||||
|
||||
bool has_main_input;
|
||||
uint32_t main_input_channel_count;
|
||||
clap::ext::audio_ports::AudioPortType main_input_port_type;
|
||||
|
||||
bool has_main_output;
|
||||
uint32_t main_output_channel_count;
|
||||
clap::ext::audio_ports::AudioPortType main_output_port_type;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value4b(id);
|
||||
s.text1b(name, 4096);
|
||||
s.value4b(input_port_count);
|
||||
s.value4b(output_port_count);
|
||||
s.value1b(has_main_input);
|
||||
s.value4b(main_input_channel_count);
|
||||
s.value4b(main_input_port_type);
|
||||
s.value1b(has_main_output);
|
||||
s.value4b(main_output_channel_count);
|
||||
s.value4b(main_output_port_type);
|
||||
}
|
||||
};
|
||||
|
||||
namespace plugin {
|
||||
|
||||
/**
|
||||
* Message struct for `clap_plugin_audio_ports_config::count()`.
|
||||
*/
|
||||
struct Count {
|
||||
using Response = PrimitiveResponse<uint32_t>;
|
||||
|
||||
native_size_t instance_id;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The response to the `clap::ext::audio_ports_config::plugin::Get` message
|
||||
* defined below.
|
||||
*/
|
||||
struct GetResponse {
|
||||
std::optional<AudioPortsConfig> result;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.ext(result, bitsery::ext::InPlaceOptional());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Message struct for `clap_plugin_audio_ports_config::get()`.
|
||||
*/
|
||||
struct Get {
|
||||
using Response = GetResponse;
|
||||
|
||||
native_size_t instance_id;
|
||||
uint32_t index;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.value4b(index);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Message struct for `clap_plugin_audio_ports_config::select()`.
|
||||
*/
|
||||
struct Select {
|
||||
using Response = PrimitiveResponse<bool>;
|
||||
|
||||
native_size_t instance_id;
|
||||
clap_id config_id;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(instance_id);
|
||||
s.value4b(config_id);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace plugin
|
||||
|
||||
namespace host {
|
||||
|
||||
/**
|
||||
* Message struct for `clap_host_audio_ports_config::rescan()`.
|
||||
*/
|
||||
struct Rescan {
|
||||
using Response = Ack;
|
||||
|
||||
native_size_t owner_instance_id;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value8b(owner_instance_id);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace host
|
||||
|
||||
} // namespace audio_ports_config
|
||||
} // namespace ext
|
||||
} // namespace clap
|
||||
@@ -61,8 +61,8 @@ AudioPortType parse_audio_port_type(const char* port_type);
|
||||
const char* audio_port_type_to_string(AudioPortType port_type);
|
||||
|
||||
/**
|
||||
* A serializable version of `clap_audio_port_info` that owns all of the data it
|
||||
* references.
|
||||
* A serializable version of `clap_audio_port_info_t` that owns all of the data
|
||||
* it references.
|
||||
*/
|
||||
struct AudioPortInfo {
|
||||
/**
|
||||
|
||||
@@ -78,6 +78,7 @@ if with_clap
|
||||
'../common/plugins.cpp',
|
||||
'../common/process.cpp',
|
||||
'../common/serialization/clap/ext/audio-ports.cpp',
|
||||
'../common/serialization/clap/ext/audio-ports-config.cpp',
|
||||
'../common/serialization/clap/ext/note-ports.cpp',
|
||||
'../common/serialization/clap/ext/params.cpp',
|
||||
'../common/serialization/clap/events.cpp',
|
||||
|
||||
@@ -81,6 +81,7 @@ if with_clap
|
||||
host_sources += files(
|
||||
'../common/logging/clap.cpp',
|
||||
'../common/serialization/clap/ext/audio-ports.cpp',
|
||||
'../common/serialization/clap/ext/audio-ports-config.cpp',
|
||||
'../common/serialization/clap/ext/note-ports.cpp',
|
||||
'../common/serialization/clap/ext/params.cpp',
|
||||
'../common/serialization/clap/events.cpp',
|
||||
|
||||
Reference in New Issue
Block a user