make internal ports a slice of Port structs
This commit is contained in:
parent
1d86abff5b
commit
cfec45eb6c
3 changed files with 9 additions and 10 deletions
|
@ -285,7 +285,7 @@ pub const Image = struct {
|
|||
idx,
|
||||
param.value,
|
||||
);
|
||||
ports[idx].value = param.value;
|
||||
(&ports[idx]).value = param.value;
|
||||
}
|
||||
|
||||
// now we need to generate a temporary file and put the output of
|
||||
|
|
|
@ -59,14 +59,14 @@ pub const Port = struct {
|
|||
/// Setup ports for a given plugin. Gives an array to pointers of Port structs.
|
||||
/// This setup is required so we link the plugin to the ports later on, and
|
||||
/// also link our buffers, and control values.
|
||||
pub fn setupPorts(ctx: *plugin.Context) ![]*Port {
|
||||
pub fn setupPorts(ctx: *plugin.Context) ![]Port {
|
||||
var world = ctx.world;
|
||||
const n_ports: u32 = c.lilv_plugin_get_num_ports(ctx.plugin);
|
||||
|
||||
var ports = try ctx.allocator.alloc(*Port, n_ports);
|
||||
var ports = try ctx.allocator.alloc(Port, n_ports);
|
||||
|
||||
for (ports) |port_ptr, idx| {
|
||||
var port = try ctx.allocator.create(Port);
|
||||
for (ports) |_, idx| {
|
||||
var port: *Port = &ports[idx];
|
||||
port.* = Port{
|
||||
.lilv_port = null,
|
||||
.ptype = .Control,
|
||||
|
@ -75,8 +75,6 @@ pub fn setupPorts(ctx: *plugin.Context) ![]*Port {
|
|||
.is_input = false,
|
||||
.optional = false,
|
||||
};
|
||||
|
||||
ports[idx] = port;
|
||||
}
|
||||
|
||||
var values: []f32 = try ctx.allocator.alloc(f32, n_ports);
|
||||
|
@ -100,7 +98,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]*Port {
|
|||
|
||||
var i: u32 = 0;
|
||||
while (i < n_ports) : (i += 1) {
|
||||
var port: *Port = ports[i];
|
||||
var port: *Port = &ports[i];
|
||||
|
||||
const lport = c.lilv_plugin_get_port_by_index(ctx.plugin, i).?;
|
||||
|
||||
|
|
|
@ -112,15 +112,16 @@ pub const RunContext = struct {
|
|||
self.buffers.deinit();
|
||||
}
|
||||
|
||||
pub fn connectPorts(self: *RunContext, ports: []*lv2.Port) void {
|
||||
pub fn connectPorts(self: *RunContext, ports: []lv2.Port) void {
|
||||
var i: usize = 0;
|
||||
var o: usize = 0;
|
||||
|
||||
var in_buf = self.buffers.in;
|
||||
var out_buf = self.buffers.out;
|
||||
|
||||
for (ports) |port, p_idx| {
|
||||
for (ports) |_, p_idx| {
|
||||
var p = @intCast(u32, p_idx);
|
||||
var port: *lv2.Port = &ports[p_idx];
|
||||
|
||||
switch (port.ptype) {
|
||||
.Control => lv2.lilv_instance_connect_port(self.instance, p, &port.value),
|
||||
|
|
Loading…
Reference in a new issue