Add a way to reconstruct audio port info

This commit is contained in:
Robbert van der Helm
2022-09-12 20:11:19 +02:00
parent b2b01b5447
commit 31fdf9c3d8
2 changed files with 17 additions and 0 deletions
@@ -16,6 +16,8 @@
#include "audio-ports.h" #include "audio-ports.h"
#include "../../../utils.h"
namespace clap { namespace clap {
namespace ext { namespace ext {
namespace audio_ports { namespace audio_ports {
@@ -56,6 +58,16 @@ AudioPortInfo::AudioPortInfo(const clap_audio_port_info_t& original)
port_type(parse_port_type(original.port_type)), port_type(parse_port_type(original.port_type)),
in_place_pair(original.in_place_pair) {} in_place_pair(original.in_place_pair) {}
void AudioPortInfo::reconstruct(clap_audio_port_info_t& port_info) const {
port_info = clap_audio_port_info_t{};
port_info.id = id;
strlcpy_buffer<sizeof(port_info.name)>(port_info.name, name);
port_info.flags = flags;
port_info.channel_count = channel_count;
port_info.port_type = audio_port_type_to_string(port_type);
port_info.in_place_pair = in_place_pair;
}
} // namespace audio_ports } // namespace audio_ports
} // namespace ext } // namespace ext
} // namespace clap } // namespace clap
@@ -76,6 +76,11 @@ struct AudioPortInfo {
*/ */
AudioPortInfo() {} AudioPortInfo() {}
/**
* Write the stored information to a host provided info struct.
*/
void reconstruct(clap_audio_port_info_t& port_info) const;
clap_id id; clap_id id;
std::string name; std::string name;
uint32_t flags; uint32_t flags;