mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 12:10:09 +02:00
Move CLAP version clamping to a function
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
#include "version.h"
|
||||
|
||||
namespace clap {
|
||||
namespace plugin {
|
||||
|
||||
@@ -46,14 +48,7 @@ descriptor::descriptor(const clap_plugin_descriptor_t& original)
|
||||
const clap_plugin_descriptor_t* descriptor::get() const {
|
||||
// This should be the minimum of yabridge's supported CLAP version and
|
||||
// the plugin's supported CLAP version
|
||||
clap_version_t supported_clap_version = clap_version;
|
||||
if (CLAP_VERSION_MAJOR < clap_version.major ||
|
||||
(clap_version.major == CLAP_VERSION_MAJOR &&
|
||||
(CLAP_VERSION_MINOR < clap_version.minor ||
|
||||
(clap_version.minor == CLAP_VERSION_MINOR &&
|
||||
CLAP_VERSION_REVISION < clap_version.revision)))) {
|
||||
supported_clap_version = CLAP_VERSION;
|
||||
}
|
||||
clap_version_t supported_clap_version = clamp_clap_version(clap_version);
|
||||
|
||||
// `features_ptrs` needs to be populated as an envp-style null terminated
|
||||
// array
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// 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 <compare>
|
||||
|
||||
#include <clap/version.h>
|
||||
|
||||
/**
|
||||
* Return the minimum of the given CLAP version and the CLAP version currently
|
||||
* supported by the SDK.
|
||||
*/
|
||||
inline clap_version_t clamp_clap_version(clap_version_t version) {
|
||||
if (CLAP_VERSION_MAJOR < version.major ||
|
||||
(version.major == CLAP_VERSION_MAJOR &&
|
||||
(CLAP_VERSION_MINOR < version.minor ||
|
||||
(version.minor == CLAP_VERSION_MINOR &&
|
||||
CLAP_VERSION_REVISION < version.revision)))) {
|
||||
return CLAP_VERSION;
|
||||
} else {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user