Compare commits

..

No commits in common. "4adf80e51a8ebae30c8cb6f403b68741ca1e5cbb" and "8aa65958d046012c0ceab023e3943c8f94acb380" have entirely different histories.

6 changed files with 21 additions and 22 deletions

View file

@ -97,7 +97,7 @@ pub fn temporaryName(allocator: *std.mem.Allocator) ![]u8 {
var tmp_file: std.fs.File = std.fs.cwd().openFile( var tmp_file: std.fs.File = std.fs.cwd().openFile(
nam, nam,
.{ .read = true, .write = false }, .{ .read = true, .write = false },
) catch |err| { ) catch |err| blk: {
if (err == error.FileNotFound) return nam else continue; if (err == error.FileNotFound) return nam else continue;
}; };
@ -321,7 +321,7 @@ pub const Image = struct {
defer self.allocator.free(sym_cstr); defer self.allocator.free(sym_cstr);
var sym = c.lilv_new_string(ctx.world, sym_cstr.ptr); var sym = c.lilv_new_string(ctx.world, sym_cstr.ptr);
const port = c.lilv_plugin_get_port_by_symbol(ctx.plugin, sym) orelse { const port = c.lilv_plugin_get_port_by_symbol(ctx.plugin, sym) orelse blk: {
std.debug.warn("assert fail: symbol {} not found on port\n", .{param.sym}); std.debug.warn("assert fail: symbol {} not found on port\n", .{param.sym});
return ImageError.InvalidSymbol; return ImageError.InvalidSymbol;
}; };

View file

@ -135,6 +135,8 @@ pub const Command = struct {
.embed => Embed, .embed => Embed,
.rotate => Rotate, .rotate => Rotate,
else => @panic("TODO"),
}; };
} }

View file

@ -81,20 +81,20 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port {
defer ctx.allocator.free(values); defer ctx.allocator.free(values);
c.lilv_plugin_get_port_ranges_float(ctx.plugin, null, null, values.ptr); c.lilv_plugin_get_port_ranges_float(ctx.plugin, null, null, values.ptr);
var lv2_InputPort = c.lilv_new_uri(world, LV2_CORE__InputPort.ptr).?; var lv2_InputPort = c.lilv_new_uri(world, LV2_CORE__InputPort.ptr);
//defer std.heap.c_allocator.destroy(lv2_InputPort); defer std.heap.c_allocator.destroy(lv2_InputPort);
var lv2_OutputPort = c.lilv_new_uri(world, LV2_CORE__OutputPort.ptr).?; var lv2_OutputPort = c.lilv_new_uri(world, LV2_CORE__OutputPort.ptr);
//defer std.heap.c_allocator.destroy(lv2_OutputPort); defer std.heap.c_allocator.destroy(lv2_OutputPort);
var lv2_AudioPort = c.lilv_new_uri(world, LV2_CORE__AudioPort.ptr).?; var lv2_AudioPort = c.lilv_new_uri(world, LV2_CORE__AudioPort.ptr);
//defer std.heap.c_allocator.destroy(lv2_AudioPort); defer std.heap.c_allocator.destroy(lv2_AudioPort);
var lv2_ControlPort = c.lilv_new_uri(world, LV2_CORE__ControlPort.ptr).?; var lv2_ControlPort = c.lilv_new_uri(world, LV2_CORE__ControlPort.ptr);
//defer std.heap.c_allocator.destroy(lv2_ControlPort); defer std.heap.c_allocator.destroy(lv2_ControlPort);
var lv2_connection_string = c.lilv_new_uri(world, LV2_CORE__connectionOptional.ptr).?; var lv2_connectionOptional = c.lilv_new_uri(world, LV2_CORE__connectionOptional.ptr);
//defer std.heap.c_allocator.destroy(lv2_connection_string); defer std.heap.c_allocator.destroy(lv2_connectionOptional);
var i: u32 = 0; var i: u32 = 0;
while (i < n_ports) : (i += 1) { while (i < n_ports) : (i += 1) {
@ -111,7 +111,7 @@ pub fn setupPorts(ctx: *plugin.Context) ![]Port {
port.value = values[i]; port.value = values[i];
} }
port.optional = c.lilv_port_has_property(ctx.plugin, lport, lv2_connection_string); port.optional = c.lilv_port_has_property(ctx.plugin, lport, lv2_connectionOptional);
if (c.lilv_port_is_a(ctx.plugin, lport, lv2_InputPort)) { if (c.lilv_port_is_a(ctx.plugin, lport, lv2_InputPort)) {
port.is_input = true; port.is_input = true;

View file

@ -104,7 +104,7 @@ pub const RunContext = struct {
switch (port.ptype) { switch (port.ptype) {
.Control => lv2.lilv_instance_connect_port(self.instance, p, &port.value), .Control => lv2.lilv_instance_connect_port(self.instance, p, &port.value),
.Audio => { .Audio => blk: {
if (port.is_input) { if (port.is_input) {
lv2.lilv_instance_connect_port( lv2.lilv_instance_connect_port(
self.instance, self.instance,
@ -121,7 +121,7 @@ pub const RunContext = struct {
o += 1; o += 1;
} }
}, },
// else => lv2.lilv_instance_connect_port(self.instance, p, null), else => lv2.lilv_instance_connect_port(self.instance, p, null),
} }
} }
} }
@ -136,7 +136,7 @@ pub fn makeContext(allocator: *std.mem.Allocator, plugin_uri: []const u8) !Conte
c.lilv_world_load_all(world); c.lilv_world_load_all(world);
var uri: *c.LilvNode = c.lilv_new_uri(world, cstr_plugin_uri.ptr) orelse { var uri: *c.LilvNode = c.lilv_new_uri(world, cstr_plugin_uri.ptr) orelse blk: {
std.debug.warn("Invalid plugin URI <{}>\n", .{plugin_uri}); std.debug.warn("Invalid plugin URI <{}>\n", .{plugin_uri});
return ImageError.InvalidPlugin; return ImageError.InvalidPlugin;
}; };
@ -144,7 +144,7 @@ pub fn makeContext(allocator: *std.mem.Allocator, plugin_uri: []const u8) !Conte
const plugins: *const c.LilvPlugins = c.lilv_world_get_all_plugins(world).?; const plugins: *const c.LilvPlugins = c.lilv_world_get_all_plugins(world).?;
var plugin: *const c.LilvPlugin = c.lilv_plugins_get_by_uri(plugins, uri) orelse { var plugin: *const c.LilvPlugin = c.lilv_plugins_get_by_uri(plugins, uri) orelse blk: {
std.debug.warn("Plugin <{}> not found\n", .{plugin_uri}); std.debug.warn("Plugin <{}> not found\n", .{plugin_uri});
return ImageError.UnknownPlugin; return ImageError.UnknownPlugin;
}; };

View file

@ -27,6 +27,7 @@ fn printCommand(stream: anytype, cmd: *langs.Command, comptime tag: langs.Comman
switch (ctype) { switch (ctype) {
.lv2_command => try printCommandWithParams(stream, casted), .lv2_command => try printCommandWithParams(stream, casted),
.custom_command => try printCommandWithParams(stream, casted), .custom_command => try printCommandWithParams(stream, casted),
else => @panic("TODO support command type"),
} }
} }

View file

@ -40,8 +40,6 @@ pub const Runner = struct {
if (self.image) |image| { if (self.image) |image| {
image.close(); image.close();
} }
std.process.argsFree(self.allocator, self.args);
} }
pub fn clone(self: *Runner) !Runner { pub fn clone(self: *Runner) !Runner {
@ -119,7 +117,6 @@ pub const Runner = struct {
} }
} }
/// Caller owns returned memory.
fn makeGlitchedPath(self: *Runner) ![]const u8 { fn makeGlitchedPath(self: *Runner) ![]const u8 {
// we want to transform basename, if it is "x.bmp" to "x_gN.bmp", where // we want to transform basename, if it is "x.bmp" to "x_gN.bmp", where
// N is the maximum non-used integer. // N is the maximum non-used integer.
@ -183,7 +180,6 @@ pub const Runner = struct {
fn quicksaveCmd(self: *Runner) !void { fn quicksaveCmd(self: *Runner) !void {
var image = try self.getImage(); var image = try self.getImage();
const out_path = try self.makeGlitchedPath(); const out_path = try self.makeGlitchedPath();
defer self.allocator.free(out_path);
try image.saveTo(out_path); try image.saveTo(out_path);
} }
@ -191,7 +187,6 @@ pub const Runner = struct {
const runqs = cmd.cast(lang.Command.RunQS).?; const runqs = cmd.cast(lang.Command.RunQS).?;
var image = try self.getImage(); var image = try self.getImage();
const out_path = try self.makeGlitchedPath(); const out_path = try self.makeGlitchedPath();
defer self.allocator.free(out_path);
try image.saveTo(out_path); try image.saveTo(out_path);
var proc = try std.ChildProcess.init( var proc = try std.ChildProcess.init(
@ -257,6 +252,7 @@ pub const Runner = struct {
switch (ctype) { switch (ctype) {
.lv2_command => try self.executeLV2Command(command.*), .lv2_command => try self.executeLV2Command(command.*),
.custom_command => try self.executeCustomCommand(command.*), .custom_command => try self.executeCustomCommand(command.*),
else => @panic("TODO support command type"),
} }
} }