all: fix issue with glfw vulkan createWindowSurface; update to new for loop syntax (#713)
This commit is contained in:
parent
5aecbb0ee6
commit
2b6f3fb1d9
14 changed files with 28 additions and 27 deletions
|
|
@ -364,7 +364,7 @@ pub const Context = struct {
|
|||
if (chmap[0] == null) continue;
|
||||
|
||||
var channels = try self.allocator.alloc(main.Channel, chmap.*.*.map.channels);
|
||||
for (channels) |*ch, i|
|
||||
for (channels, 0..) |*ch, i|
|
||||
ch.*.id = fromAlsaChannel(chmap[0][0].map.pos()[i]) catch return error.OpeningDevice;
|
||||
break :blk channels;
|
||||
} else {
|
||||
|
|
@ -580,7 +580,7 @@ pub const Player = struct {
|
|||
}
|
||||
|
||||
fn writeLoop(self: *Player) void {
|
||||
for (self.channels) |*ch, i| {
|
||||
for (self.channels, 0..) |*ch, i| {
|
||||
ch.*.ptr = self.sample_buffer.ptr + self.format.frameSize(i);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ pub const Context = struct {
|
|||
var ports = try self.allocator.alloc(*c.jack_port_t, device.channels.len);
|
||||
var dest_ports = try self.allocator.alloc([:0]const u8, ports.len);
|
||||
var buf: [64]u8 = undefined;
|
||||
for (device.channels) |_, i| {
|
||||
for (device.channels, 0..) |_, i| {
|
||||
const port_name = std.fmt.bufPrintZ(&buf, "playback_{d}", .{i + 1}) catch unreachable;
|
||||
const dest_name = try std.fmt.allocPrintZ(self.allocator, "{s}:{s}", .{ device.id, port_name });
|
||||
ports[i] = lib.jack_port_register(self.client, port_name.ptr, c.JACK_DEFAULT_AUDIO_TYPE, c.JackPortIsOutput, 0) orelse
|
||||
|
|
@ -259,7 +259,7 @@ pub const Player = struct {
|
|||
if (lib.jack_activate(self.client) != 0)
|
||||
return error.CannotPlay;
|
||||
|
||||
for (self.ports) |port, i| {
|
||||
for (self.ports, 0..) |port, i| {
|
||||
if (lib.jack_connect(self.client, lib.jack_port_name(port), self.dest_ports[i].ptr) != 0)
|
||||
return error.CannotPlay;
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ pub const Player = struct {
|
|||
fn processCallback(n_frames: c.jack_nframes_t, self_opaque: ?*anyopaque) callconv(.C) c_int {
|
||||
const self = @ptrCast(*Player, @alignCast(@alignOf(*Player), self_opaque.?));
|
||||
|
||||
for (self.channels) |*ch, i| {
|
||||
for (self.channels, 0..) |*ch, i| {
|
||||
ch.*.ptr = @ptrCast([*]u8, lib.jack_port_get_buffer(self.ports[i], n_frames));
|
||||
}
|
||||
self.writeFn(self.user_data, n_frames);
|
||||
|
|
@ -279,7 +279,7 @@ pub const Player = struct {
|
|||
pub fn play(self: *Player) !void {
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
for (self.ports) |port, i| {
|
||||
for (self.ports, 0..) |port, i| {
|
||||
if (lib.jack_connect(self.client, lib.jack_port_name(port), self.dest_ports[i].ptr) != 0)
|
||||
return error.CannotPlay;
|
||||
}
|
||||
|
|
@ -288,7 +288,7 @@ pub const Player = struct {
|
|||
pub fn pause(self: *Player) !void {
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
for (self.ports) |port, i| {
|
||||
for (self.ports, 0..) |port, i| {
|
||||
if (lib.jack_disconnect(self.client, lib.jack_port_name(port), self.dest_ports[i].ptr) != 0)
|
||||
return error.CannotPause;
|
||||
}
|
||||
|
|
@ -297,7 +297,7 @@ pub const Player = struct {
|
|||
pub fn paused(self: *Player) bool {
|
||||
self.mutex.lock();
|
||||
defer self.mutex.unlock();
|
||||
for (self.ports) |port, i| {
|
||||
for (self.ports, 0..) |port, i| {
|
||||
if (lib.jack_port_connected_to(port, self.dest_ports[i].ptr) == 1)
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ pub const Context = struct {
|
|||
std.meta.fieldInfo(backends.BackendContext, b).type,
|
||||
).Pointer.child.init(allocator, options);
|
||||
} else {
|
||||
inline for (std.meta.fields(Backend)) |b, i| {
|
||||
inline for (std.meta.fields(Backend), 0..) |b, i| {
|
||||
if (@typeInfo(
|
||||
std.meta.fieldInfo(backends.BackendContext, @intToEnum(Backend, b.value)).type,
|
||||
).Pointer.child.init(allocator, options)) |d| {
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ pub const Player = struct {
|
|||
buf.*.buffer.*.datas[0].chunk.*.stride = stride;
|
||||
buf.*.buffer.*.datas[0].chunk.*.size = n_frames * stride;
|
||||
|
||||
for (self.channels) |*ch, i| {
|
||||
for (self.channels, 0..) |*ch, i| {
|
||||
ch.ptr = @ptrCast([*]u8, buf.*.buffer.*.datas[0].data.?) + self.format.frameSize(i);
|
||||
}
|
||||
self.writeFn(self.user_data, n_frames);
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ pub const Context = struct {
|
|||
if (self.default_source) |d|
|
||||
self.allocator.free(d);
|
||||
}
|
||||
for (self.devices_info.list.items) |device, i| {
|
||||
for (self.devices_info.list.items, 0..) |device, i| {
|
||||
if ((device.mode == .playback and
|
||||
self.default_sink != null and
|
||||
std.mem.eql(u8, device.id, self.default_sink.?)) or
|
||||
|
|
@ -295,7 +295,7 @@ pub const Context = struct {
|
|||
.mode = mode,
|
||||
.channels = blk: {
|
||||
var channels = try self.allocator.alloc(main.Channel, info.*.channel_map.channels);
|
||||
for (channels) |*ch, i|
|
||||
for (channels, 0..) |*ch, i|
|
||||
ch.*.id = fromPAChannelPos(info.*.channel_map.map[i]) catch unreachable;
|
||||
break :blk channels;
|
||||
},
|
||||
|
|
@ -473,7 +473,7 @@ pub const Player = struct {
|
|||
return;
|
||||
}
|
||||
|
||||
for (self.channels) |*ch, i| {
|
||||
for (self.channels, 0..) |*ch, i| {
|
||||
ch.*.ptr = self.write_ptr + self.format.frameSize(i);
|
||||
}
|
||||
|
||||
|
|
@ -644,7 +644,7 @@ pub fn toPAFormat(format: main.Format) !c.pa_sample_format_t {
|
|||
pub fn toPAChannelMap(channels: []const main.Channel) !c.pa_channel_map {
|
||||
var channel_map: c.pa_channel_map = undefined;
|
||||
channel_map.channels = @intCast(u5, channels.len);
|
||||
for (channels) |ch, i|
|
||||
for (channels, 0..) |ch, i|
|
||||
channel_map.map[i] = try toPAChannelPos(ch.id);
|
||||
return channel_map;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -742,7 +742,7 @@ pub const Player = struct {
|
|||
else => unreachable,
|
||||
}
|
||||
|
||||
for (self.channels) |*ch, i| {
|
||||
for (self.channels, 0..) |*ch, i| {
|
||||
ch.*.ptr = data + self.format.frameSize(i);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub const Guid = extern union {
|
|||
};
|
||||
pub fn initString(s: []const u8) Guid {
|
||||
var guid = Guid{ .Bytes = undefined };
|
||||
for (hex_offsets) |hex_offset, i| {
|
||||
for (hex_offsets, 0..) |hex_offset, i| {
|
||||
guid.Bytes[i] = decodeHexByte([2]u8{ s[hex_offset], s[hex_offset + 1] });
|
||||
}
|
||||
return guid;
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ pub const Context = struct {
|
|||
.write_step = @sizeOf(f32),
|
||||
};
|
||||
|
||||
for (player.channels) |*ch, i| {
|
||||
for (player.channels, 0..) |*ch, i| {
|
||||
ch.*.ptr = player.buf.ptr + i * channel_size_bytes;
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ pub const Player = struct {
|
|||
|
||||
self.writeFn(self.user_data, channel_size);
|
||||
|
||||
for (self.channels) |_, i| {
|
||||
for (self.channels, 0..) |_, i| {
|
||||
self.buf_js.copyBytes(self.buf[i * channel_size_bytes .. (i + 1) * channel_size_bytes]);
|
||||
const buf_f32_js = js.constructType("Float32Array", &.{ self.buf_js.get("buffer"), self.buf_js.get("byteOffset"), js.createNumber(channel_size) });
|
||||
defer buf_f32_js.deinit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue