summary refs log tree commit diff
path: root/src/al.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/al.zig')
-rw-r--r--src/al.zig16
1 files changed, 11 insertions, 5 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 => {},