sysaudio: improve compatibility with self-hosted compiler

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-08-20 11:41:15 -07:00
parent 72b081c97a
commit 7bc7caaec4
4 changed files with 17 additions and 4 deletions

View file

@ -6,7 +6,10 @@ 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;
pub const WriteCallback = if (@import("builtin").zig_backend == .stage1)
fn (stream: ?[*]c.SoundIoInStream, frame_count_min: c_int, frame_count_max: c_int) callconv(.C) void
else
*const fn (stream: ?[*]c.SoundIoInStream, frame_count_min: c_int, frame_count_max: c_int) callconv(.C) void;
handle: *c.SoundIoInStream,

View file

@ -6,7 +6,10 @@ 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;
pub const WriteCallback = if (@import("builtin").zig_backend == .stage1)
fn (stream: ?[*]c.SoundIoOutStream, frame_count_min: c_int, frame_count_max: c_int) callconv(.C) void
else
*const fn (stream: ?[*]c.SoundIoOutStream, frame_count_min: c_int, frame_count_max: c_int) callconv(.C) void;
handle: *c.SoundIoOutStream,

View file

@ -14,7 +14,11 @@ const SoundIoStream = union(Mode) {
const Audio = @This();
pub const DataCallback = fn (device: Device, frame_count: u32) void;
pub const DataCallback = if (@import("builtin").zig_backend == .stage1)
fn (device: Device, frame_count: u32) void
else
fn (device: Device, frame_count: u32) void;
pub const Device = struct {
handle: SoundIoStream,
data_callback: ?DataCallback = null,

View file

@ -5,7 +5,10 @@ const js = @import("sysjs");
const Audio = @This();
pub const DataCallback = fn (device: *Device, user_data: ?*anyopaque, sample: *f32) void;
pub const DataCallback = if (@import("builtin").zig_backend == .stage1)
fn (device: *Device, user_data: ?*anyopaque, sample: *f32) void
else
*const fn (device: *Device, user_data: ?*anyopaque, sample: *f32) void;
pub const Device = struct {
context: js.Object,