audio: rename to 'sysaudio'
This commit is contained in:
parent
0fb712d19e
commit
f8f4dcf55f
22 changed files with 3 additions and 3 deletions
11
sysaudio/soundio/ChannelLayout.zig
Normal file
11
sysaudio/soundio/ChannelLayout.zig
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
const c = @import("c.zig");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
|
||||
const ChannelLayout = @This();
|
||||
|
||||
handle: c.SoundIoChannelLayout,
|
||||
|
||||
pub fn channelCount(self: ChannelLayout) i32 {
|
||||
return self.handle.channel_count;
|
||||
}
|
||||
33
sysaudio/soundio/Device.zig
Normal file
33
sysaudio/soundio/Device.zig
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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();
|
||||
|
||||
handle: *c.SoundIoDevice,
|
||||
|
||||
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));
|
||||
}
|
||||
55
sysaudio/soundio/InStream.zig
Normal file
55
sysaudio/soundio/InStream.zig
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
const c = @import("c.zig");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const Format = @import("enums.zig").Format;
|
||||
const ChannelLayout = @import("ChannelLayout.zig");
|
||||
|
||||
const InStream = @This();
|
||||
|
||||
pub const WriteCallback = fn (stream: ?[*]c.SoundIoInStream, frame_count_min: c_int, frame_count_max: c_int) callconv(.C) void;
|
||||
|
||||
handle: *c.SoundIoInStream,
|
||||
|
||||
pub fn deinit(self: InStream) void {
|
||||
c.soundio_instream_destroy(self.handle);
|
||||
}
|
||||
|
||||
pub fn open(self: InStream) Error!void {
|
||||
try intToError(c.soundio_instream_open(self.handle));
|
||||
}
|
||||
|
||||
pub fn start(self: InStream) Error!void {
|
||||
try intToError(c.soundio_instream_start(self.handle));
|
||||
}
|
||||
|
||||
pub fn beginWrite(self: InStream, areas: [*]?[*]c.SoundIoChannelArea, frame_count: *i32) Error!void {
|
||||
try intToError(c.soundio_instream_begin_write(
|
||||
self.handle,
|
||||
areas,
|
||||
frame_count,
|
||||
));
|
||||
}
|
||||
|
||||
pub fn endWrite(self: InStream) Error!void {
|
||||
try intToError(c.soundio_instream_end_write(self.handle));
|
||||
}
|
||||
|
||||
pub fn setFormat(self: InStream, format: Format) void {
|
||||
self.handle.*.format = @enumToInt(format);
|
||||
}
|
||||
|
||||
pub fn setWriteCallback(self: InStream, callback: WriteCallback) void {
|
||||
self.handle.*.write_callback = callback;
|
||||
}
|
||||
|
||||
pub fn layout(self: InStream) ChannelLayout {
|
||||
return ChannelLayout{ .handle = self.handle.*.layout };
|
||||
}
|
||||
|
||||
pub fn sampleRate(self: InStream) i32 {
|
||||
return self.handle.*.sample_rate;
|
||||
}
|
||||
|
||||
pub fn layoutError(self: InStream) Error!void {
|
||||
try intToError(self.handle.*.layout_error);
|
||||
}
|
||||
55
sysaudio/soundio/OutStream.zig
Normal file
55
sysaudio/soundio/OutStream.zig
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
const c = @import("c.zig");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const Format = @import("enums.zig").Format;
|
||||
const ChannelLayout = @import("ChannelLayout.zig");
|
||||
|
||||
const OutStream = @This();
|
||||
|
||||
pub const WriteCallback = fn (stream: ?[*]c.SoundIoOutStream, frame_count_min: c_int, frame_count_max: c_int) callconv(.C) void;
|
||||
|
||||
handle: *c.SoundIoOutStream,
|
||||
|
||||
pub fn deinit(self: OutStream) void {
|
||||
c.soundio_outstream_destroy(self.handle);
|
||||
}
|
||||
|
||||
pub fn open(self: OutStream) Error!void {
|
||||
try intToError(c.soundio_outstream_open(self.handle));
|
||||
}
|
||||
|
||||
pub fn start(self: OutStream) Error!void {
|
||||
try intToError(c.soundio_outstream_start(self.handle));
|
||||
}
|
||||
|
||||
pub fn beginWrite(self: OutStream, areas: [*]?[*]c.SoundIoChannelArea, frame_count: *i32) Error!void {
|
||||
try intToError(c.soundio_outstream_begin_write(
|
||||
self.handle,
|
||||
areas,
|
||||
frame_count,
|
||||
));
|
||||
}
|
||||
|
||||
pub fn endWrite(self: OutStream) Error!void {
|
||||
try intToError(c.soundio_outstream_end_write(self.handle));
|
||||
}
|
||||
|
||||
pub fn setFormat(self: OutStream, format: Format) void {
|
||||
self.handle.*.format = @enumToInt(format);
|
||||
}
|
||||
|
||||
pub fn setWriteCallback(self: OutStream, callback: WriteCallback) void {
|
||||
self.handle.*.write_callback = callback;
|
||||
}
|
||||
|
||||
pub fn layout(self: OutStream) ChannelLayout {
|
||||
return ChannelLayout{ .handle = self.handle.*.layout };
|
||||
}
|
||||
|
||||
pub fn sampleRate(self: OutStream) i32 {
|
||||
return self.handle.*.sample_rate;
|
||||
}
|
||||
|
||||
pub fn layoutError(self: OutStream) Error!void {
|
||||
try intToError(self.handle.*.layout_error);
|
||||
}
|
||||
86
sysaudio/soundio/SoundIo.zig
Normal file
86
sysaudio/soundio/SoundIo.zig
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
const c = @import("c.zig");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const Aim = @import("enums.zig").Aim;
|
||||
const Backend = @import("enums.zig").Backend;
|
||||
const Device = @import("Device.zig");
|
||||
|
||||
const SoundIo = @This();
|
||||
|
||||
handle: *c.SoundIo,
|
||||
|
||||
pub fn init() error{OutOfMemory}!SoundIo {
|
||||
return SoundIo{ .handle = c.soundio_create() orelse return error.OutOfMemory };
|
||||
}
|
||||
|
||||
pub fn deinit(self: SoundIo) void {
|
||||
c.soundio_destroy(self.handle);
|
||||
}
|
||||
|
||||
pub fn connect(self: SoundIo) Error!void {
|
||||
try intToError(c.soundio_connect(self.handle));
|
||||
}
|
||||
|
||||
pub fn connectBackend(self: SoundIo, backend: Backend) Error!void {
|
||||
try intToError(c.soundio_connect_backend(self.handle, @enumToInt(backend)));
|
||||
}
|
||||
|
||||
pub fn disconnect(self: SoundIo) void {
|
||||
c.soundio_disconnect(self.handle);
|
||||
}
|
||||
|
||||
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 wakeup(self: SoundIo) void {
|
||||
c.soundio_wakeup(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);
|
||||
}
|
||||
|
||||
pub fn defaultOutputDeviceIndex(self: SoundIo) ?u16 {
|
||||
const index = c.soundio_default_output_device_index(self.handle);
|
||||
return if (index < 0) null else @intCast(u16, index);
|
||||
}
|
||||
|
||||
pub fn inputDeviceCount(self: SoundIo) ?u16 {
|
||||
const count = c.soundio_input_device_count(self.handle);
|
||||
return if (count < 0) null else @intCast(u16, count);
|
||||
}
|
||||
|
||||
pub fn outputDeviceCount(self: SoundIo) ?u16 {
|
||||
const count = c.soundio_output_device_count(self.handle);
|
||||
return if (count < 0) null else @intCast(u16, count);
|
||||
}
|
||||
|
||||
pub fn getInputDevice(self: SoundIo, index: u16) ?Device {
|
||||
return Device{
|
||||
.handle = c.soundio_get_input_device(self.handle, index) orelse return null,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn getOutputDevice(self: SoundIo, index: u16) ?Device {
|
||||
return Device{
|
||||
.handle = c.soundio_get_output_device(self.handle, index) orelse return null,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn getInputDeviceFromID(self: SoundIo, id: [:0]const u8, is_raw: bool) ?Device {
|
||||
return Device{
|
||||
.handle = c.soundio_get_input_device_from_id(self.handle, id.ptr, is_raw) orelse return null,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn getOutputDeviceFromID(self: SoundIo, id: [:0]const u8, is_raw: bool) ?Device {
|
||||
return Device{
|
||||
.handle = c.soundio_get_output_device_from_id(self.handle, id.ptr, is_raw) orelse return null,
|
||||
};
|
||||
}
|
||||
3
sysaudio/soundio/c.zig
Normal file
3
sysaudio/soundio/c.zig
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
pub usingnamespace @cImport({
|
||||
@cInclude("soundio/soundio.h");
|
||||
});
|
||||
149
sysaudio/soundio/enums.zig
Normal file
149
sysaudio/soundio/enums.zig
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
const c = @import("c.zig");
|
||||
|
||||
pub const ChannelId = enum(u7) {
|
||||
invalid = c.SoundIoChannelIdInvalid,
|
||||
|
||||
front_left = c.SoundIoChannelIdFrontLeft,
|
||||
front_right = c.SoundIoChannelIdFrontRight,
|
||||
front_center = c.SoundIoChannelIdFrontCenter,
|
||||
lfe = c.SoundIoChannelIdLfe,
|
||||
back_left = c.SoundIoChannelIdBackLeft,
|
||||
back_right = c.SoundIoChannelIdBackRight,
|
||||
front_left_center = c.SoundIoChannelIdFrontLeftCenter,
|
||||
front_right_center = c.SoundIoChannelIdFrontRightCenter,
|
||||
back_center = c.SoundIoChannelIdBackCenter,
|
||||
side_left = c.SoundIoChannelIdSideLeft,
|
||||
side_right = c.SoundIoChannelIdSideRight,
|
||||
top_center = c.SoundIoChannelIdTopCenter,
|
||||
top_front_left = c.SoundIoChannelIdTopFrontLeft,
|
||||
top_front_center = c.SoundIoChannelIdTopFrontCenter,
|
||||
top_front_right = c.SoundIoChannelIdTopFrontRight,
|
||||
top_back_left = c.SoundIoChannelIdTopBackLeft,
|
||||
top_back_center = c.SoundIoChannelIdTopBackCenter,
|
||||
top_back_right = c.SoundIoChannelIdTopBackRight,
|
||||
|
||||
back_left_center = c.SoundIoChannelIdBackLeftCenter,
|
||||
back_right_center = c.SoundIoChannelIdBackRightCenter,
|
||||
front_left_wide = c.SoundIoChannelIdFrontLeftWide,
|
||||
front_right_wide = c.SoundIoChannelIdFrontRightWide,
|
||||
front_left_high = c.SoundIoChannelIdFrontLeftHigh,
|
||||
front_center_high = c.SoundIoChannelIdFrontCenterHigh,
|
||||
front_right_high = c.SoundIoChannelIdFrontRightHigh,
|
||||
top_front_left_center = c.SoundIoChannelIdTopFrontLeftCenter,
|
||||
top_front_right_center = c.SoundIoChannelIdTopFrontRightCenter,
|
||||
top_side_left = c.SoundIoChannelIdTopSideLeft,
|
||||
top_side_right = c.SoundIoChannelIdTopSideRight,
|
||||
left_lfe = c.SoundIoChannelIdLeftLfe,
|
||||
right_lfe = c.SoundIoChannelIdRightLfe,
|
||||
lfe2 = c.SoundIoChannelIdLfe2,
|
||||
bottom_center = c.SoundIoChannelIdBottomCenter,
|
||||
bottom_left_center = c.SoundIoChannelIdBottomLeftCenter,
|
||||
bottom_right_center = c.SoundIoChannelIdBottomRightCenter,
|
||||
|
||||
// Mid/side recording
|
||||
ms_mid = c.SoundIoChannelIdMsMid,
|
||||
ms_side = c.SoundIoChannelIdMsSide,
|
||||
|
||||
// first order ambisonic channels
|
||||
ambisonic_w = c.SoundIoChannelIdAmbisonicW,
|
||||
ambisonic_x = c.SoundIoChannelIdAmbisonicX,
|
||||
ambisonic_y = c.SoundIoChannelIdAmbisonicY,
|
||||
ambisonic_z = c.SoundIoChannelIdAmbisonicZ,
|
||||
|
||||
// X-Y Recording
|
||||
x_y_x = c.SoundIoChannelIdXyX,
|
||||
x_y_y = c.SoundIoChannelIdXyY,
|
||||
|
||||
headphones_left = c.SoundIoChannelIdHeadphonesLeft,
|
||||
headphones_right = c.SoundIoChannelIdHeadphonesRight,
|
||||
click_track = c.SoundIoChannelIdClickTrack,
|
||||
foreign_language = c.SoundIoChannelIdForeignLanguage,
|
||||
hearing_impaired = c.SoundIoChannelIdHearingImpaired,
|
||||
narration = c.SoundIoChannelIdNarration,
|
||||
haptic = c.SoundIoChannelIdHaptic,
|
||||
dialog_centric_mix = c.SoundIoChannelIdDialogCentricMix,
|
||||
|
||||
aux = c.SoundIoChannelIdAux,
|
||||
aux0 = c.SoundIoChannelIdAux0,
|
||||
aux1 = c.SoundIoChannelIdAux1,
|
||||
aux2 = c.SoundIoChannelIdAux2,
|
||||
aux3 = c.SoundIoChannelIdAux3,
|
||||
aux4 = c.SoundIoChannelIdAux4,
|
||||
aux5 = c.SoundIoChannelIdAux5,
|
||||
aux6 = c.SoundIoChannelIdAux6,
|
||||
aux7 = c.SoundIoChannelIdAux7,
|
||||
aux8 = c.SoundIoChannelIdAux8,
|
||||
aux9 = c.SoundIoChannelIdAux9,
|
||||
aux10 = c.SoundIoChannelIdAux10,
|
||||
aux11 = c.SoundIoChannelIdAux11,
|
||||
aux12 = c.SoundIoChannelIdAux12,
|
||||
aux13 = c.SoundIoChannelIdAux13,
|
||||
aux14 = c.SoundIoChannelIdAux14,
|
||||
aux15 = c.SoundIoChannelIdAux15,
|
||||
};
|
||||
|
||||
pub const ChannelLayoutId = enum(u5) {
|
||||
mono = c.SoundIoChannelLayoutIdMono,
|
||||
stereo = c.SoundIoChannelLayoutIdStereo,
|
||||
_2point1 = c.SoundIoChannelLayoutId2Point1,
|
||||
_3point0 = c.SoundIoChannelLayoutId3Point0,
|
||||
_3point0_back = c.SoundIoChannelLayoutId3Point0Back,
|
||||
_3point1 = c.SoundIoChannelLayoutId3Point1,
|
||||
_4point0 = c.SoundIoChannelLayoutId4Point0,
|
||||
quad = c.SoundIoChannelLayoutIdQuad,
|
||||
quadSide = c.SoundIoChannelLayoutIdQuadSide,
|
||||
_4point1 = c.SoundIoChannelLayoutId4Point1,
|
||||
_5point0_back = c.SoundIoChannelLayoutId5Point0Back,
|
||||
_5point0_side = c.SoundIoChannelLayoutId5Point0Side,
|
||||
_5point1 = c.SoundIoChannelLayoutId5Point1,
|
||||
_5point1_back = c.SoundIoChannelLayoutId5Point1Back,
|
||||
_6point0_side = c.SoundIoChannelLayoutId6Point0Side,
|
||||
_6point0_front = c.SoundIoChannelLayoutId6Point0Front,
|
||||
hexagonal = c.SoundIoChannelLayoutIdHexagonal,
|
||||
_6point1 = c.SoundIoChannelLayoutId6Point1,
|
||||
_6point1_back = c.SoundIoChannelLayoutId6Point1Back,
|
||||
_6point1_front = c.SoundIoChannelLayoutId6Point1Front,
|
||||
_7point0 = c.SoundIoChannelLayoutId7Point0,
|
||||
_7point0_front = c.SoundIoChannelLayoutId7Point0Front,
|
||||
_7point1 = c.SoundIoChannelLayoutId7Point1,
|
||||
_7point1_wide = c.SoundIoChannelLayoutId7Point1Wide,
|
||||
_7point1_wide_back = c.SoundIoChannelLayoutId7Point1WideBack,
|
||||
octagonal = c.SoundIoChannelLayoutIdOctagonal,
|
||||
};
|
||||
|
||||
pub const Backend = enum(u3) {
|
||||
none = c.SoundIoBackendNone,
|
||||
jack = c.SoundIoBackendJack,
|
||||
pulseaudio = c.SoundIoBackendPulseAudio,
|
||||
alsa = c.SoundIoBackendAlsa,
|
||||
coreaudio = c.SoundIoBackendCoreAudio,
|
||||
wasapi = c.SoundIoBackendWasapi,
|
||||
dummy = c.SoundIoBackendDummy,
|
||||
};
|
||||
|
||||
pub const Aim = enum(u1) {
|
||||
input = c.SoundIoDeviceAimInput,
|
||||
output = c.SoundIoDeviceAimOutput,
|
||||
};
|
||||
|
||||
pub const Format = enum(u5) {
|
||||
invalid = c.SoundIoFormatInvalid,
|
||||
S8 = c.SoundIoFormatS8,
|
||||
U8 = c.SoundIoFormatU8,
|
||||
S16LE = c.SoundIoFormatS16LE,
|
||||
S16BE = c.SoundIoFormatS16BE,
|
||||
U16LE = c.SoundIoFormatU16LE,
|
||||
U16BE = c.SoundIoFormatU16BE,
|
||||
S24LE = c.SoundIoFormatS24LE,
|
||||
S24BE = c.SoundIoFormatS24BE,
|
||||
U24LE = c.SoundIoFormatU24LE,
|
||||
U24BE = c.SoundIoFormatU24BE,
|
||||
S32LE = c.SoundIoFormatS32LE,
|
||||
S32BE = c.SoundIoFormatS32BE,
|
||||
U32LE = c.SoundIoFormatU32LE,
|
||||
U32BE = c.SoundIoFormatU32BE,
|
||||
float32LE = c.SoundIoFormatFloat32LE,
|
||||
float32BE = c.SoundIoFormatFloat32BE,
|
||||
float64LE = c.SoundIoFormatFloat64LE,
|
||||
float64BE = c.SoundIoFormatFloat64BE,
|
||||
};
|
||||
62
sysaudio/soundio/error.zig
Normal file
62
sysaudio/soundio/error.zig
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
|
||||
pub const Error = error{
|
||||
OutOfMemory,
|
||||
/// The backend does not appear to be active or running.
|
||||
InitAudioBackend,
|
||||
/// A system resource other than memory was not available.
|
||||
SystemResources,
|
||||
/// Attempted to open a device and failed.
|
||||
OpeningDevice,
|
||||
NoSuchDevice,
|
||||
/// The programmer did not comply with the API.
|
||||
Invalid,
|
||||
/// libsoundio was compiled without support for that backend.
|
||||
BackendUnavailable,
|
||||
/// An open stream had an error that can only be recovered from by
|
||||
/// destroying the stream and creating it again.
|
||||
Streaming,
|
||||
/// Attempted to use a device with parameters it cannot support.
|
||||
IncompatibleDevice,
|
||||
/// When JACK returns `JackNoSuchClient`
|
||||
NoSuchClient,
|
||||
/// Attempted to use parameters that the backend cannot support.
|
||||
IncompatibleBackend,
|
||||
/// Backend server shutdown or became inactive.
|
||||
BackendDisconnected,
|
||||
Interrupted,
|
||||
/// Buffer underrun occurred.
|
||||
Underflow,
|
||||
/// Unable to convert to or from UTF-8 to the native string format.
|
||||
EncodingString,
|
||||
};
|
||||
|
||||
pub fn intToError(err: c_int) Error!void {
|
||||
return switch (err) {
|
||||
c.SoundIoErrorNone => {},
|
||||
c.SoundIoErrorNoMem => Error.OutOfMemory,
|
||||
c.SoundIoErrorInitAudioBackend => Error.InitAudioBackend,
|
||||
c.SoundIoErrorSystemResources => Error.SystemResources,
|
||||
c.SoundIoErrorOpeningDevice => Error.OpeningDevice,
|
||||
c.SoundIoErrorNoSuchDevice => Error.NoSuchDevice,
|
||||
c.SoundIoErrorInvalid => Error.Invalid,
|
||||
c.SoundIoErrorBackendUnavailable => Error.BackendUnavailable,
|
||||
c.SoundIoErrorStreaming => Error.Streaming,
|
||||
c.SoundIoErrorIncompatibleDevice => Error.IncompatibleDevice,
|
||||
c.SoundIoErrorNoSuchClient => Error.NoSuchClient,
|
||||
c.SoundIoErrorIncompatibleBackend => Error.IncompatibleBackend,
|
||||
c.SoundIoErrorBackendDisconnected => Error.BackendDisconnected,
|
||||
c.SoundIoErrorInterrupted => Error.Interrupted,
|
||||
c.SoundIoErrorUnderflow => Error.Underflow,
|
||||
c.SoundIoErrorEncodingString => Error.EncodingString,
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
|
||||
test "error convertion" {
|
||||
const expectError = @import("std").testing.expectError;
|
||||
|
||||
try intToError(c.SoundIoErrorNone);
|
||||
try expectError(Error.OutOfMemory, intToError(c.SoundIoErrorNoMem));
|
||||
}
|
||||
29
sysaudio/soundio/main.zig
Normal file
29
sysaudio/soundio/main.zig
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
pub usingnamespace @import("enums.zig");
|
||||
pub const c = @import("c.zig");
|
||||
pub const SoundIo = @import("SoundIo.zig");
|
||||
pub const Device = @import("Device.zig");
|
||||
pub const InStream = @import("InStream.zig");
|
||||
pub const OutStream = @import("OutStream.zig");
|
||||
pub const Error = @import("error.zig").Error;
|
||||
|
||||
test {
|
||||
refAllDecls(@import("SoundIo.zig"));
|
||||
refAllDecls(@import("Device.zig"));
|
||||
refAllDecls(@import("OutStream.zig"));
|
||||
refAllDecls(@import("ChannelLayout.zig"));
|
||||
}
|
||||
|
||||
fn refAllDecls(comptime T: type) void {
|
||||
@setEvalBranchQuota(10000);
|
||||
inline for (comptime @import("std").meta.declarations(T)) |decl| {
|
||||
if (decl.is_pub) {
|
||||
if (@TypeOf(@field(T, decl.name)) == type) {
|
||||
switch (@typeInfo(@field(T, decl.name))) {
|
||||
.Struct, .Enum, .Union, .Opaque => refAllDecls(@field(T, decl.name)),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
_ = @field(T, decl.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue