summary refs log tree commit diff
path: root/src/alc.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/alc.zig')
-rw-r--r--src/alc.zig27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/alc.zig b/src/alc.zig
index 8e478e8..ca83bf6 100644
--- a/src/alc.zig
+++ b/src/alc.zig
@@ -48,8 +48,8 @@ pub const DONT_CARE  = ALC_DONT_CATE_SOFT;
 pub const HRTF = ALC_HRTF_SOFT;
 
 /// Create and attach a context to the given device.
-pub fn createContext(device: *Device, attributes: [:0]const i32) !*Context {
-    if (alcCreateContext(device, attributes.ptr)) |context|
+pub fn createContext(device: *Device, attrlist: [:0]const i32) Error!*Context {
+    if (alcCreateContext(device, attrlist.ptr)) |context|
         return context;
     return switch (alcGetError(device)) {
         ALC_INVALID_DEVICE => Error.InvalidDevice,
@@ -60,7 +60,7 @@ pub fn createContext(device: *Device, attributes: [:0]const i32) !*Context {
 
 /// Make the given context the active process-wide context.
 /// Passing NULL clears the active context.
-pub fn makeContextCurrent(context: ?*Context) !void {
+pub fn makeContextCurrent(context: ?*Context) Error!void {
     if (alcMakeContextCurrent(context) == TRUE)
         return;
     if (alcGetError(null) == ALC_INVALID_CONTEXT)
@@ -69,7 +69,7 @@ pub fn makeContextCurrent(context: ?*Context) !void {
 }
 
 /// Remove a context from its device and destroys it.
-pub fn destroyContext(context: *Context) !void {
+pub fn destroyContext(context: *Context) Error!void {
     alcDestroyContext(context);
     if (alcGetError(null) == ALC_INVALID_CONTEXT)
         return Error.InvalidContext;
@@ -81,7 +81,7 @@ pub fn getCurrentContext() ?*Context {
 }
 
 /// Return the device that a particular context is attached to.
-pub fn getContextsDevice(context: *Context) !*Device {
+pub fn getContextsDevice(context: *Context) Error!*Device {
     if (alcGetContextsDevice(context)) |device|
         return device;
     if (alcGetError(null) == ALC_INVALID_CONTEXT)
@@ -90,7 +90,7 @@ pub fn getContextsDevice(context: *Context) !*Device {
 }
 
 /// Open the named playback device.
-pub fn openDevice(name: ?[:0]const u8) !*Device {
+pub fn openDevice(name: ?[:0]const u8) Error!*Device {
     const name_ptr = if (name == null) null else name.?.ptr;
     if (alcOpenDevice(name_ptr)) |device|
         return device;
@@ -102,10 +102,23 @@ pub fn openDevice(name: ?[:0]const u8) !*Device {
 }
 
 /// Close the given playback device.
-pub fn closeDevice(device: *Device) !void {
+pub fn closeDevice(device: *Device) Error!void {
     if (alcCloseDevice(device) == TRUE)
         return;
     if (alcGetError(device) == ALC_INVALID_DEVICE)
         return Error.InvalidDevice;
     unreachable;
 }
+
+pub fn getInt(device: *Device, param: ALCenum) Error!i32 {
+    var data: i32 = undefined;
+    alcGetIntegerv(device, param, 1, &data);
+    return switch (alcGetError(device)) {
+        ALC_NO_ERROR => data,
+        ALC_INVALID_VALUE => Error.InvalidValue,
+        ALC_INVALID_ENUM => Error.InvalidEnum,
+        ALC_INVALID_DEVICE => Error.InvalidDevice,
+        ALC_INVALID_CONTEXT => Error.InvalidContext,
+        else => unreachable,
+    };
+}