diff options
Diffstat (limited to 'src/zeal.zig')
-rw-r--r-- | src/zeal.zig | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/zeal.zig b/src/zeal.zig index e5984bf..3be59fb 100644 --- a/src/zeal.zig +++ b/src/zeal.zig @@ -23,7 +23,7 @@ const alc = @import("alc.zig"); const sf = @import("sf.zig"); const std = @import("std"); -pub const Error = al.Error || error { +pub const Error = al.Error || error{ UncurrentContext, }; @@ -74,8 +74,8 @@ pub const Context = struct { stereo_sources: ?i32 = null, /// Maximum number of auxiliary source sends. max_auxiliary_sends: ?i32 = null, - /// Enabling HRTF. + /// Enabling HRTF. hrtf: ?alc.Logical = null, /// The HRTF to be used. hrtf_id: ?i32 = null, @@ -90,11 +90,11 @@ pub const Context = struct { var attr_list = [_]i32{ 0 } ** (fields.len * 2 + 1); var i: u8 = 0; inline for (fields) |f| if (@field(attributes, f.name)) |v| { - attr_list[i] = @enumToInt(@field(alc.Enum, f.name)); - attr_list[i + 1] = if (@TypeOf(v) == i32) v else @enumToInt(v); + attr_list[i] = @intFromEnum(@field(alc.Enum, f.name)); + attr_list[i + 1] = if (@TypeOf(v) == i32) v else @intFromEnum(v); i += 2; }; - return Context { + return Context{ .pimpl = try alc.createContext(device.pimpl, attr_list[0..i:0]), .device = device, }; @@ -111,9 +111,9 @@ pub const Context = struct { pub fn getCurrent() ?alc.Error!Context { if (alc.getCurrentContext()) |pimpl| - return Context { + return Context{ .pimpl = pimpl, - .device = Device { .pimpl = try alc.getContextsDevice(pimpl) }, + .device = Device{ .pimpl = try alc.getContextsDevice(pimpl) }, }; return null; } @@ -153,7 +153,7 @@ pub const Audio = struct { const sound = try SndFile.open(path, sf.Mode.read); defer sound.close(); const data = try sound.readAll(allocator); - return Audio { + return Audio{ .allocator = allocator, .data = switch (sound.channels) { 1 => al.Data{ .mono16 = data }, @@ -201,8 +201,7 @@ pub const Source = struct { } pub fn bind(self: Source, buffer: Buffer) Error!void { - try al.source.set(self.reference, .buffer, - @intCast(i32, buffer.reference)); + try al.source.set(self.reference, .buffer, @intCast(buffer.reference)); } /// Specify if the source always has 3D spatialization features (true), |