audio: add InStream and more functiosn coverage to soundio binding

This commit is contained in:
alichraghi 2022-07-08 00:41:56 +04:30 committed by Stephen Gutekanst
parent 751cceb94a
commit f1845c0f41
4 changed files with 97 additions and 0 deletions

View file

@ -1,6 +1,8 @@
const std = @import("std");
const c = @import("c.zig");
const InStream = @import("InStream.zig");
const OutStream = @import("OutStream.zig");
const Format = @import("enums.zig").Format;
const Device = @This();
@ -10,10 +12,22 @@ pub fn unref(self: Device) void {
c.soundio_device_unref(self.handle);
}
pub fn id(self: Device) [:0]const u8 {
return std.mem.span(self.handle.*.id);
}
pub fn name(self: Device) [:0]const u8 {
return std.mem.span(self.handle.*.name);
}
pub fn createInStream(self: Device) error{OutOfMemory}!InStream {
return InStream{ .handle = c.soundio_instream_create(self.handle) orelse return error.OutOfMemory };
}
pub fn createOutStream(self: Device) error{OutOfMemory}!OutStream {
return OutStream{ .handle = c.soundio_outstream_create(self.handle) orelse return error.OutOfMemory };
}
pub fn supportsFormat(self: Device, format: Format) bool {
return c.soundio_device_supports_format(self.handle, @enumToInt(format));
}