summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/al.zig16
-rw-r--r--src/zeal.zig3
2 files changed, 13 insertions, 6 deletions
diff --git a/src/al.zig b/src/al.zig
index ccabc7e..1eea14e 100644
--- a/src/al.zig
+++ b/src/al.zig
@@ -116,15 +116,21 @@ pub const buffer = struct {
 
     /// Fill a buffer with audio data.
     pub fn fill(reference: u32, data: Data, freq: i32) Error!void {
-        c.alBufferData(reference, switch (data) {
+        const format = switch (data) {
             .mono8 => c.AL_FORMAT_MONO8,
             .mono16 => c.AL_FORMAT_MONO16,
             .stereo8 => c.AL_FORMAT_STEREO8,
             .stereo16 => c.AL_FORMAT_STEREO16,
-        }, switch (data) { else => |slice| slice.ptr }, switch (data) {
-            .mono8, .stereo8 => |slice| @intCast(slice.len),
-            .mono16, .stereo16 => |slice| @intCast(slice.len * 2),
-        }, freq);
+        };
+
+        switch (data) {
+            .mono8, .stereo8 => |slice|
+                c.alBufferData(reference, format,
+                               slice.ptr, @intCast(slice.len), freq),
+            .mono16, .stereo16 => |slice|
+                c.alBufferData(reference, format,
+                               slice.ptr, @intCast(slice.len * 2), freq),
+        }
 
         switch (c.alGetError()) {
             c.AL_NO_ERROR => {},
diff --git a/src/zeal.zig b/src/zeal.zig
index 3be59fb..cf88b11 100644
--- a/src/zeal.zig
+++ b/src/zeal.zig
@@ -201,7 +201,8 @@ pub const Source = struct {
     }
 
     pub fn bind(self: Source, buffer: Buffer) Error!void {
-        try al.source.set(self.reference, .buffer, @intCast(buffer.reference));
+        const reference: i32 = @intCast(buffer.reference);
+        try al.source.set(self.reference, .buffer, reference);
     }
 
     /// Specify if the source always has 3D spatialization features (true),