Use an enum for the audio port type

Otherwise we can't provide a static lifetime string pointer in the info
struct.
This commit is contained in:
Robbert van der Helm
2022-09-12 19:38:03 +02:00
parent 51edef4427
commit ec5b02815d
2 changed files with 60 additions and 6 deletions
@@ -20,12 +20,40 @@ namespace clap {
namespace ext {
namespace audio_ports {
AudioPortType parse_port_type(const char* port_type) {
if (!port_type) {
return AudioPortType::Unknown;
}
if (strcmp(port_type, CLAP_PORT_MONO) == 0) {
return AudioPortType::Mono;
} else if (strcmp(port_type, CLAP_PORT_STEREO) == 0) {
return AudioPortType::Stereo;
} else {
return AudioPortType::Unknown;
}
}
const char* audio_port_type_to_string(AudioPortType port_type) {
switch (port_type) {
case AudioPortType::Mono:
return CLAP_PORT_MONO;
break;
case AudioPortType::Stereo:
return CLAP_PORT_STEREO;
break;
default:
return nullptr;
break;
}
}
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),
port_type(parse_port_type(original.port_type)),
in_place_pair(original.in_place_pair) {}
} // namespace audio_ports