mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Fully implement the audio ports extension
This commit is contained in:
@@ -201,8 +201,9 @@ clap_plugin_proxy::ext_audio_ports_count(const clap_plugin_t* plugin,
|
|||||||
assert(plugin && plugin->plugin_data);
|
assert(plugin && plugin->plugin_data);
|
||||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||||
|
|
||||||
// TODO: Implement
|
return self->bridge_.send_main_thread_message(
|
||||||
return 0;
|
clap::ext::audio_ports::plugin::Count{
|
||||||
|
.instance_id = self->instance_id(), .is_input = is_input});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLAP_ABI
|
bool CLAP_ABI
|
||||||
@@ -213,6 +214,17 @@ clap_plugin_proxy::ext_audio_ports_get(const clap_plugin_t* plugin,
|
|||||||
assert(plugin && plugin->plugin_data && info);
|
assert(plugin && plugin->plugin_data && info);
|
||||||
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
auto self = static_cast<const clap_plugin_proxy*>(plugin->plugin_data);
|
||||||
|
|
||||||
// TODO: Implement
|
const clap::ext::audio_ports::plugin::GetResponse response =
|
||||||
|
self->bridge_.send_main_thread_message(
|
||||||
|
clap::ext::audio_ports::plugin::Get{
|
||||||
|
.instance_id = self->instance_id(),
|
||||||
|
.index = index,
|
||||||
|
.is_input = is_input});
|
||||||
|
if (response.result) {
|
||||||
|
response.result->reconstruct(*info);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -81,6 +81,36 @@ ClapPluginBridge::ClapPluginBridge(const ghc::filesystem::path& plugin_path)
|
|||||||
|
|
||||||
return Ack{};
|
return Ack{};
|
||||||
},
|
},
|
||||||
|
[&](const clap::ext::audio_ports::host::IsRescanFlagSupported&
|
||||||
|
request)
|
||||||
|
-> clap::ext::audio_ports::host::IsRescanFlagSupported::
|
||||||
|
Response {
|
||||||
|
const auto& [plugin_proxy, _] =
|
||||||
|
get_proxy(request.owner_instance_id);
|
||||||
|
|
||||||
|
// We'll ignore the main thread requirement for
|
||||||
|
// simple lookup functions like this for
|
||||||
|
// performance's sake
|
||||||
|
return plugin_proxy.extensions_.audio_ports
|
||||||
|
->is_rescan_flag_supported(plugin_proxy.host_,
|
||||||
|
request.flag);
|
||||||
|
},
|
||||||
|
[&](const clap::ext::audio_ports::host::Rescan& request)
|
||||||
|
-> clap::ext::audio_ports::host::Rescan::Response {
|
||||||
|
const auto& [plugin_proxy, _] =
|
||||||
|
get_proxy(request.owner_instance_id);
|
||||||
|
|
||||||
|
plugin_proxy
|
||||||
|
.run_on_main_thread(
|
||||||
|
[&, host = plugin_proxy.host_,
|
||||||
|
audio_ports =
|
||||||
|
plugin_proxy.extensions_.audio_ports]() {
|
||||||
|
audio_ports->rescan(host, request.flags);
|
||||||
|
})
|
||||||
|
.wait();
|
||||||
|
|
||||||
|
return Ack{};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ if with_clap
|
|||||||
'../common/notifications.cpp',
|
'../common/notifications.cpp',
|
||||||
'../common/plugins.cpp',
|
'../common/plugins.cpp',
|
||||||
'../common/process.cpp',
|
'../common/process.cpp',
|
||||||
|
'../common/serialization/clap/ext/audio-ports.cpp',
|
||||||
'../common/serialization/clap/host.cpp',
|
'../common/serialization/clap/host.cpp',
|
||||||
'../common/serialization/clap/plugin.cpp',
|
'../common/serialization/clap/plugin.cpp',
|
||||||
'../common/utils.cpp',
|
'../common/utils.cpp',
|
||||||
|
|||||||
@@ -118,8 +118,9 @@ bool CLAP_ABI clap_host_proxy::ext_audio_ports_is_rescan_flag_supported(
|
|||||||
assert(host && host->host_data);
|
assert(host && host->host_data);
|
||||||
auto self = static_cast<clap_host_proxy*>(host->host_data);
|
auto self = static_cast<clap_host_proxy*>(host->host_data);
|
||||||
|
|
||||||
// TODO: Implement
|
return self->bridge_.send_main_thread_message(
|
||||||
return false;
|
clap::ext::audio_ports::host::IsRescanFlagSupported{
|
||||||
|
.owner_instance_id = self->owner_instance_id(), .flag = flag});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLAP_ABI clap_host_proxy::ext_audio_ports_rescan(const clap_host_t* host,
|
void CLAP_ABI clap_host_proxy::ext_audio_ports_rescan(const clap_host_t* host,
|
||||||
@@ -127,5 +128,6 @@ void CLAP_ABI clap_host_proxy::ext_audio_ports_rescan(const clap_host_t* host,
|
|||||||
assert(host && host->host_data);
|
assert(host && host->host_data);
|
||||||
auto self = static_cast<clap_host_proxy*>(host->host_data);
|
auto self = static_cast<clap_host_proxy*>(host->host_data);
|
||||||
|
|
||||||
// TODO: Implement
|
self->bridge_.send_main_thread_message(clap::ext::audio_ports::host::Rescan{
|
||||||
|
.owner_instance_id = self->owner_instance_id(), .flags = flags});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,6 +310,30 @@ void ClapBridge::run() {
|
|||||||
})
|
})
|
||||||
.get();
|
.get();
|
||||||
},
|
},
|
||||||
|
[&](const clap::ext::audio_ports::plugin::Count& request)
|
||||||
|
-> clap::ext::audio_ports::plugin::Count::Response {
|
||||||
|
const auto& [instance, _] = get_instance(request.instance_id);
|
||||||
|
|
||||||
|
// We'll ignore the main thread requirement for simple lookup
|
||||||
|
// functions like this for performance's sake
|
||||||
|
return instance.extensions.audio_ports->count(
|
||||||
|
instance.plugin.get(), request.is_input);
|
||||||
|
},
|
||||||
|
[&](const clap::ext::audio_ports::plugin::Get& request)
|
||||||
|
-> clap::ext::audio_ports::plugin::Get::Response {
|
||||||
|
const auto& [instance, _] = get_instance(request.instance_id);
|
||||||
|
|
||||||
|
clap_audio_port_info_t info{};
|
||||||
|
if (instance.extensions.audio_ports->get(
|
||||||
|
instance.plugin.get(), request.index, request.is_input,
|
||||||
|
&info)) {
|
||||||
|
return clap::ext::audio_ports::plugin::GetResponse{
|
||||||
|
.result = info};
|
||||||
|
} else {
|
||||||
|
return clap::ext::audio_ports::plugin::GetResponse{
|
||||||
|
.result = std::nullopt};
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user