summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--examples/hrtf.zig15
-rw-r--r--examples/play.zig17
-rw-r--r--src/cimport.zig2
-rw-r--r--src/zeal.zig6
4 files changed, 19 insertions, 21 deletions
diff --git a/examples/hrtf.zig b/examples/hrtf.zig
index 2db3d78..76e1257 100644
--- a/examples/hrtf.zig
+++ b/examples/hrtf.zig
@@ -1,5 +1,5 @@
 // Positional audio example with HRTF
-// Copyright (C) 2021  Nguyễn Gia Phong
+// Copyright (C) 2021, 2023  Nguyễn Gia Phong
 //
 // This file is part of zeal.
 //
@@ -18,7 +18,7 @@
 
 const std = @import("std");
 const allocator = std.heap.c_allocator;
-const args = std.process.args;
+const args = std.process.argsWithAllocator;
 const print = std.debug.print;
 const sleep = std.time.sleep;
 
@@ -35,18 +35,17 @@ pub fn main() !void {
     const device = try Device.init(null);
     defer device.deinit() catch unreachable;
 
-    const context = try Context.init(device, &.{ alc.HRTF, alc.TRUE });
+    const context = try Context.init(device, &.{ alc.HRTF, alc.TRUE, 0 });
     if (try device.enabledHrtf())
         print("HRTF enabled!\n", .{})
     else
         print("HRTF not enabled!\n", .{});
     defer context.deinit() catch unreachable;
 
-    var argv = args();
-    allocator.free(try argv.next(allocator).?);
-    const path = try argv.next(allocator).?;
-    defer allocator.free(path);
-    const audio = try Audio.read(allocator, path);
+    var argv = try args(allocator);
+    defer argv.deinit();
+    _ = argv.next().?;
+    const audio = try Audio.read(allocator, argv.next().?);
     defer audio.free();
 
     try context.makeCurrent();
diff --git a/examples/play.zig b/examples/play.zig
index 210972c..fab8f3f 100644
--- a/examples/play.zig
+++ b/examples/play.zig
@@ -1,5 +1,5 @@
 // Playing audio example
-// Copyright (C) 2021  Nguyễn Gia Phong
+// Copyright (C) 2021, 2023  Nguyễn Gia Phong
 //
 // This file is part of zeal.
 //
@@ -18,7 +18,7 @@
 
 const std = @import("std");
 const allocator = std.heap.c_allocator;
-const args = std.process.args;
+const args = std.process.argsWithAllocator;
 const print = std.debug.print;
 const sleep = std.time.sleep;
 
@@ -33,14 +33,13 @@ const Source = zeal.Source;
 pub fn main() !void {
     const device = try Device.init(null);
     defer device.deinit() catch unreachable;
-    const context = try Context.init(device, &.{});
+    const context = try Context.init(device, &.{ 0 });
     defer context.deinit() catch unreachable;
 
-    var argv = args();
-    allocator.free(try argv.next(allocator).?);
-    const path = try argv.next(allocator).?;
-    defer allocator.free(path);
-    const audio = try Audio.read(allocator, path);
+    var argv = try args(allocator);
+    defer argv.deinit();
+    _ = argv.next().?;
+    const audio = try Audio.read(allocator, argv.next().?);
     defer audio.free();
 
     try context.makeCurrent();
@@ -53,7 +52,7 @@ pub fn main() !void {
     try source.play();
     defer print("\n", .{});
     while (try source.isPlaying()) {
+        print("\r{d:.1} s", .{ try source.getSecOffset() });
         sleep(10_000_000);
-        print("\r{d:.1} s", .{ source.getSecOffset() });
     }
 }
diff --git a/src/cimport.zig b/src/cimport.zig
index dc19cc9..00a40c6 100644
--- a/src/cimport.zig
+++ b/src/cimport.zig
@@ -1,4 +1,4 @@
-usingnamespace @cImport({
+pub usingnamespace @cImport({
     @cInclude("AL/al.h");
     @cInclude("AL/alc.h");
     @cInclude("AL/alext.h");
diff --git a/src/zeal.zig b/src/zeal.zig
index 416c9d2..7103f59 100644
--- a/src/zeal.zig
+++ b/src/zeal.zig
@@ -1,5 +1,5 @@
 // Zig easy audio library
-// Copyright (C) 2021-2022  Nguyễn Gia Phong
+// Copyright (C) 2021-2023  Nguyễn Gia Phong
 //
 // This file is part of zeal.
 //
@@ -198,7 +198,7 @@ const expectEqual = std.testing.expectEqual;
 test "Context" {
     const device = try Device.init(null);
     defer device.deinit() catch unreachable;
-    const context = try Context.init(device, &.{ alc.HRTF, alc.TRUE });
+    const context = try Context.init(device, &.{ alc.HRTF, alc.TRUE, 0 });
     defer context.deinit() catch unreachable;
 
     try expectEqual(Context.getCurrent(), null);
@@ -214,7 +214,7 @@ test "Context" {
 }
 
 test "listener" {
-    const context = try Context.init(try Device.init(null), &.{});
+    const context = try Context.init(try Device.init(null), &.{ 0 });
     defer context.device.deinit() catch unreachable;
     defer context.deinit() catch unreachable;