audio: increase soundio binding coverage for running sine-wine example

This commit is contained in:
alichraghi 2022-06-30 20:30:50 +04:30 committed by Stephen Gutekanst
parent d3b7df882e
commit 0e3461e25f
6 changed files with 114 additions and 6 deletions

View file

@ -8,8 +8,8 @@ const SoundIo = @This();
handle: *c.SoundIo,
pub fn init() Error!SoundIo {
return SoundIo{ .handle = c.soundio_create() orelse return Error.OutOfMemory };
pub fn init() error{OutOfMemory}!SoundIo {
return SoundIo{ .handle = c.soundio_create() orelse return error.OutOfMemory };
}
pub fn deinit(self: SoundIo) void {
@ -32,6 +32,10 @@ pub fn flushEvents(self: SoundIo) void {
c.soundio_flush_events(self.handle);
}
pub fn waitEvents(self: SoundIo) void {
c.soundio_wait_events(self.handle);
}
pub fn defaultInputDeviceIndex(self: SoundIo) ?u16 {
const index = c.soundio_default_input_device_index(self.handle);
return if (index < 0) null else @intCast(u16, index);